A dynamic power optimization distribution method and system for TWS earphones
Patent Information
- Application Number
- CN202611249031.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-18
- Publication Date
- 2026-10-23
AI Technical Summary
[0003]本发明提供一种用于TWS耳机的动态电量优化分配方法及系统,解决相关技术中的主副耳电量失衡导致续航能力下降、切换过程音频中断影响用户体验、电压监测精度不足导致误判和频繁切换的技术问题
通过自适应采样与多级滤波技术,有效抑制高频噪声与负载波动,获取精准电池电压数据。利用多维度评估与加权评分模型,综合电压差值、变化速率、趋势预测及切换历史等参数,避免频繁切换与误判,实现智能切换判定。结合音频流特征提取与场景感知策略,识别通话、音乐等场景,在静音间隙或用户暂停时执行切换,最大限度减少对用户体验的影响;
Smart Images

Figure CN122970425A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of wireless audio device technology, and more specifically, to a dynamic power optimization allocation method and system for TWS earphones. Background Technology
[0002] True wireless stereo (TWS) earbuds feature a separate left and right earbud design, connecting to the audio source device via Bluetooth. Typically, one earbud acts as the primary earbud, responsible for establishing a main connection with the audio source and receiving and forwarding audio data to the secondary earbud. While this master-slave architecture enables stereo playback, it also causes the primary earbud to consume power much faster than the secondary earbud due to handling more power-intensive tasks, resulting in a power imbalance. When the primary earbud's battery is depleted prematurely, even if the secondary earbud has sufficient power, the entire earbud system will be unable to function, wasting power and severely impacting battery life and user experience. Existing solutions to this problem have significant shortcomings. For example, simple timed switching strategies fail to adjust based on actual battery status, potentially leading to untimely or unnecessary switching; some solutions require disconnection and reconnection during switching, causing audio interruption and impacting the user experience; others rely solely on unfiltered instantaneous voltage data, making them susceptible to load fluctuations, which may cause misjudgments and frequent switching, ultimately increasing power consumption. These deficiencies limit the effective application of power balancing technology in TWS earphones, making it a key bottleneck in improving battery life. Summary of the Invention
[0003] This invention provides a dynamic power optimization allocation method and system for TWS earphones, solving the technical problems in related technologies such as power imbalance between the primary and secondary earphones leading to reduced battery life, audio interruption during switching affecting user experience, and insufficient voltage monitoring accuracy leading to misjudgment and frequent switching.
[0004] This invention provides a dynamic power optimization allocation method for TWS earphones, comprising the following steps: S1, acquire the real-time voltage signals of the left and right ear batteries, and use adaptive sampling frequency configuration and multi-level filtering processing method to obtain voltage state data with timestamps; S2, receive voltage status data with timestamps, and use bidirectional transmission and timestamp alignment mechanism of inter-ear communication link to obtain a synchronized voltage status dataset containing complete information of the left and right ears; S3. Obtain the synchronization voltage state dataset, construct multi-dimensional evaluation indicators and use a weighted scoring intelligent decision-making method to obtain the switching trigger determination result that includes the trigger signal state and comprehensive score; S4, receive the switching trigger determination result, and use audio stream feature extraction and scene awareness strategy optimization methods to obtain a switching execution strategy that includes execution timing and scene parameters; S5, start the preparation process according to the switching execution strategy, and use the dual-link parallel mechanism and state data pre-synchronization method to obtain the switching ready signal of the new master ear and the old master ear; S6 receives the handover readiness signals from the new master ear and the old master ear, and uses a gradual data stream transition control and dual-link weight dynamic adjustment method to obtain a stable connection and handover completion flag under the new master-slave architecture. S7, based on the stable connection and switching completion flags under the new master-slave architecture, uses a modular task migration and power redistribution method to obtain the power consumption status and return to the voltage monitoring loop.
[0005] In a preferred embodiment, S1 includes: Configure a voltage acquisition channel with an adaptive sampling frequency. When the battery voltage is higher than the first voltage threshold, the sampling frequency is set to the first frequency value. When the battery voltage is between the first and second voltage thresholds, the sampling frequency is increased to the second frequency value. When the battery voltage is lower than the second voltage threshold, the sampling frequency is increased to the third frequency value. Perform periodic voltage sampling and record the raw data; apply moving average filtering to eliminate high-frequency noise; Kalman filtering is used to eliminate transient drops caused by load fluctuations. A Kalman filter state-space model is established, with the actual battery voltage and voltage change rate as the state variables and the moving average filter output value as the observed variable. Accurate voltage state data with timestamps is generated.
[0006] In a preferred embodiment, S2 includes: Establish a stable two-way communication link between the ears and enable the automatic retransmission request mechanism; Encapsulate voltage status data and send it to the other earphone. The data packet format includes three parts: header, payload, and check. The check part adopts a cyclic redundancy check algorithm. Receive voltage data from the other earphone and perform integrity verification; perform timestamp alignment and data interpolation processing. If the absolute value of the timestamp difference is less than the preset time alignment window threshold, it is directly compared. If the absolute value of the timestamp difference is greater than the preset time alignment window threshold, the data with the newer timestamp is selected as the reference time and the data with the older timestamp is interpolated and estimated. Generate a synchronous voltage state dataset containing complete information for both left and right ears.
[0007] In a preferred embodiment, S3 includes: Identify the current primary and secondary earbud roles and extract the corresponding voltage values; Calculate the absolute voltage difference and the relative percentage difference. The absolute voltage difference is equal to the secondary ear voltage value minus the primary ear voltage value. The relative percentage difference is equal to the absolute voltage difference divided by the primary ear voltage value and then multiplied by 100. The voltage change rate is calculated and the future trend is predicted. The least squares method is used to fit a linear regression model to obtain the voltage change rate of the primary ear and the voltage change rate of the secondary ear. Based on the current voltage value and the voltage change rate, the linear extrapolation method is used to predict the voltage values of the primary and secondary ears at future times. The system collects historical data on switching and calculates time interval parameters. It integrates multi-dimensional parameters to perform intelligent decision-making. The decision-making model adopts a weighted scoring mechanism, with the relative difference percentage as the first weight, the voltage change rate difference and future trend prediction as the second weight, and the time interval since the last switching as the third weight. The system calculates a comprehensive score and compares it with a preset switching trigger threshold.
[0008] In a preferred embodiment, S4 includes: The audio stream feature parameters are collected and scene fingerprints are extracted. The feature parameters include audio sampling rate, audio encoding format, audio data packet size, data packet arrival interval, audio stream direction, and audio signal energy distribution. Based on feature matching, scenario type classification is performed. Feature templates for multiple typical scenarios are pre-stored, including call mode template, music playback mode template, video viewing mode template and game mode template. The similarity between the scenario fingerprint vector and each template is calculated. Adjust the switching priority and timing according to the recognition scenario. If the recognition result is a call mode, set a delayed execution flag and wait for the call to end before switching. If the recognition result is a music playback mode, monitor the silent segments in the audio stream and switch during the silence interval. Detect user interaction operations and identify active pause events; generate a switching execution strategy that includes execution timing and scenario parameters.
[0009] In a preferred embodiment, S5 includes: Activate the Bluetooth master mode function module of the new master earbud and initialize the hardware resources and software protocol stack related to master mode; Transmit Bluetooth connection parameters and establish a backup connection channel. The connection parameters include the Bluetooth address, device name, pairing key, link key, connection handle, link monitoring timeout parameters, transmit power level, and frequency hopping sequence of the audio source device. The new master ear initiates a backup connection request to the audio source device. There are two parallel Bluetooth connections between the audio source device and the TWS earphone system. Synchronize audio decoder configuration and playback status. Playback status information includes the currently decoded audio frame number, playback clock timestamp, audio buffer fill level, and number of decoded but not played frames. Preload audio buffer data and verify decoding capabilities; establish a dual-link coordination mechanism and generate a switching ready signal.
[0010] In a preferred embodiment, S6 includes: A gradual data stream transition mechanism is initiated, in which the audio source device sends audio data bidirectionally to both the old master ear and the new master ear. The old master ear gradually reduces the proportion of audio data received and processed, while the new master ear gradually increases the proportion of audio data received and processed. The processing weights and output mixing of the dual links are dynamically adjusted, and the transition time axis is divided into multiple stages. In the first stage, the old master ear is processed with the first weight value and the new master ear is processed with the second weight value. In the second stage, the old master ear weight is reduced to the third weight value and the new master ear weight is increased to the fourth weight value. In the third stage, the old master ear weight is reduced to the fifth weight value and the new master ear weight is increased to the sixth weight value. The data forwarding direction is switched and the inter-ear communication link is adjusted, changing the data flow of the inter-ear communication link from the old master ear to the new master ear to the new master ear; Disconnect the old master ear connection and confirm that the new master ear connection is stable; verify the new master-slave architecture and generate a switchover completion flag.
[0011] In a preferred embodiment, S7 includes: The new master ear takes over all Bluetooth connection management tasks, including link quality monitoring, connection parameter negotiation, power control, frequency hopping management, retransmission control, and flow control. The new master ear continuously performs audio decoding and data forwarding tasks. The decoding process includes data packet decapsulation, compression format parsing, frequency domain or time domain transformation, and audio sampling point reconstruction. The data forwarding task includes encapsulation, compression or encoding of forwarded data, transmission through the inter-ear link, and reception of forwarding confirmation. The new secondary ear disables the main mode function and reduces power consumption, disabling the main mode RF transmit power amplifier, multi-connection management unit, active scanning and connection initiation unit; Dynamically monitor the changes in the charge level of the new primary and secondary earpieces and record the consumption curve; adaptively optimize decision parameters and prepare for the next switching cycle.
[0012] In a preferred embodiment, the intelligent decision-making process, which integrates multi-dimensional parameters, determines that the switching conditions are met if the overall score is greater than a preset switching trigger threshold, the relative difference percentage is positive, and the time interval since the last switching is greater than a preset minimum switching interval threshold. This results in the generation of a switching trigger signal and the setting of the trigger signal to be active. If any condition is not met, the process determines that switching is not necessary and the trigger signal to be inactive. The generated switching trigger determination result includes the trigger signal status, the overall score value, and the values of each dimension parameter.
[0013] In a preferred embodiment, a dynamic power optimization allocation system for TWS earphones is used to perform the steps of the aforementioned dynamic power optimization allocation method for TWS earphones, including: The voltage acquisition module is used to acquire the real-time voltage signals of the left and right ear batteries. It adopts adaptive sampling frequency configuration and multi-level filtering technology to obtain voltage status data with timestamps. The data synchronization module is used to receive voltage status data with timestamps, and uses bidirectional transmission via inter-ear communication link and timestamp alignment mechanism to obtain a synchronized voltage status dataset containing complete information of the left and right ears. The decision-making module is used to acquire the synchronization voltage state dataset, and adopts a multi-dimensional evaluation index construction and weighted scoring intelligent decision-making method to obtain the switching trigger determination result including the trigger signal state and comprehensive score; The scene recognition module is used to receive the switching trigger determination result and use audio stream feature extraction and scene perception strategy optimization methods to obtain a switching execution strategy that includes execution timing and scene parameters. The switching preparation module is used to start the preparation process according to the switching execution strategy. It adopts a dual-link parallel mechanism and a state data pre-synchronization method to obtain the switching ready signals of the new master ear and the old master ear. The switching execution module is used to receive the switching readiness signals of the new master ear and the old master ear. It adopts a gradual data flow transition control and a dual-link weight dynamic adjustment method to obtain a stable connection and switching completion flag under the new master-slave architecture. The load management module is used to obtain the power consumption status and return it to the voltage monitoring loop based on the stable connection and switching completion flags under the new master-slave architecture, using modular task migration and power redistribution methods.
[0014] The beneficial effects of this invention are as follows: Through adaptive sampling and multi-level filtering techniques, high-frequency noise and load fluctuations are effectively suppressed to obtain accurate battery voltage data. Utilizing a multi-dimensional evaluation and weighted scoring model, parameters such as voltage difference, rate of change, trend prediction, and switching history are integrated to avoid frequent switching and misjudgments, achieving intelligent switching determination. Combining audio stream feature extraction and scene awareness strategies, scenarios such as calls and music are identified, and switching is performed during silent intervals or when the user pauses, minimizing the impact on user experience. Employing a dual-link parallel and state pre-synchronization approach, a backup connection is established and decoder configuration and playback status are synchronized before switching, pre-loading buffered data to ensure the new master ear is ready to take over at any time. Through gradual data stream transition and dynamic adjustment of dual-link weights, a smooth audio stream migration is achieved in stages, avoiding abrupt changes or stuttering, and completing a zero-stutter master-slave switch. Modular task migration and power redistribution ensure that high-power tasks are transferred to the new master ear, while the new slave ear enters a low-power state, achieving dynamic power balance and improving overall battery life. Attached Figure Description
[0015] Figure 1This is a flowchart of a dynamic power optimization allocation method for TWS earphones according to the present invention; Figure 2 This is a block diagram of a dynamic power optimization distribution system for TWS earphones according to the present invention. Detailed Implementation
[0016] The subject matter described herein will now be discussed with reference to exemplary embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and implement the subject matter described herein, and changes may be made to the function and arrangement of the elements discussed without departing from the scope of this specification. Various processes or components may be omitted, substituted, or added as needed in the examples. Furthermore, some features described in the examples may be combined in other examples.
[0017] At least one embodiment of the present invention discloses a dynamic power optimization allocation method for TWS earphones, such as... Figure 1 As shown, it includes the following steps: S1, acquire the real-time voltage signals of the left and right ear batteries, and use adaptive sampling frequency configuration and multi-level filtering processing method to obtain voltage state data with timestamps; The purpose of this step is to obtain the true voltage state of the left and right ear batteries, providing an accurate data foundation for subsequent capacity difference assessment. Since battery voltage is affected by various factors such as load fluctuations, temperature changes, and measurement noise, precise acquisition and filtering techniques are needed to extract the true voltage trend; specifically, the following steps are included: S11, Configures a voltage acquisition channel with an adaptive sampling frequency; Based on battery voltage acquisition requirements, the controller initializes the analog-to-digital converter (ADC) acquisition channel in the power management module. The ADC is configured in 12-bit resolution mode, capable of mapping the battery voltage range to 4096 quantization levels, achieving millivolt-level measurement accuracy. The sampling frequency is set to adaptive adjustment mode, with the controller dynamically adjusting the sampling frequency according to the current battery voltage state. When the battery voltage is higher than a first voltage threshold, it is determined to be in a fully charged state, and the sampling frequency is set to the first frequency value, which meets basic monitoring requirements and has low power consumption. When the battery voltage is between the first and second voltage thresholds, it is determined to be in a moderately charged state, and the sampling frequency is increased to the second frequency value, which is higher than the first frequency value, ensuring timely capture of voltage changes. When the battery voltage is lower than the second voltage threshold, it is determined to be in a low-charge state, and the sampling frequency is further increased to the third frequency value, achieving high-frequency monitoring. This adaptive sampling mechanism ensures monitoring accuracy while avoiding unnecessary high-frequency sampling and associated power consumption.
[0018] S12 performs periodic voltage sampling and records the raw data; The control processor periodically triggers the ADC to sample voltage according to the configured sampling frequency. During each sampling, the ADC converts the voltage difference between the positive and negative terminals of the battery into a digital value. The control processor reads the ADC conversion result to obtain the raw sampled voltage value. To improve measurement reliability, multiple consecutive samples are performed within each sampling cycle, with the number of samples set to a preset number. The control processor averages the results of these multiple samples to obtain the average voltage value for that cycle. The average voltage value is stored in the sampling data buffer, and a timestamp of the sampling time is recorded simultaneously. The timestamp is provided by the system clock with millisecond precision and is used for subsequent timing analysis and data synchronization.
[0019] S13, apply moving average filtering to eliminate high-frequency noise; Based on the voltage sampled average value sequence in the sampling data buffer, a moving average filtering algorithm is used to eliminate high-frequency noise interference. The control processor maintains a sliding window of length N, where N is the preset filtering window length. For the current sampling time, the average value of the most recent N voltage samples is taken, and the arithmetic mean of these N values is calculated to obtain the moving average filtered output value. Moving average filtering can effectively smooth voltage fluctuations and suppress random noise and high-frequency interference introduced during the measurement process. As new sampling data arrives, the sliding window moves forward one position, discarding the oldest sampled value and adding the latest sampled value, continuously calculating the moving average. The moving average filtered output value serves as the initially filtered voltage data and is passed to the next stage of filtering processing.
[0020] S14 uses Kalman filtering to eliminate transient drops caused by load fluctuations; Based on the moving average filter output, a Kalman filter algorithm is used to further eliminate voltage transient drops caused by load fluctuations. During battery power supply, when the load current suddenly increases, the battery's internal resistance causes a momentary drop in terminal voltage, forming a transient drop. This drop does not represent the true change in battery capacity and needs to be eliminated by a filtering algorithm. The control processor establishes a Kalman filter state-space model, with the actual battery voltage and voltage change rate as state variables, and the moving average filter output value as the observed variable. The Kalman filter algorithm includes a prediction step and an update step. In the prediction step, based on the state estimate value and state transition model of the previous time step, the prior estimate value and error covariance value of the current time step are predicted. In the update step, based on the observed value of the current time step, i.e., the moving average filter output value, the Kalman gain is calculated, and combined with the prior estimate value and the observed value, the posterior estimate value of the state is updated to obtain the estimated value of the actual battery voltage at the current time step. The Kalman filter, through its state-space model and recursive update mechanism, can effectively track the true voltage change trend while suppressing the interference of transient fluctuations.
[0021] S15, generate accurate voltage state data with timestamps; Accurate voltage state data is generated based on the battery's true voltage estimate output by the Kalman filter, combined with the timestamp of the sampling time. The voltage state data contains three fields: voltage value, timestamp, and data validity flag. The voltage value is the battery's true voltage estimate after Kalman filtering; the timestamp records the sampling time; and the data validity flag indicates whether the data has passed quality checks. The control processor performs a reasonableness check on the voltage value, determining whether it is within the expected voltage range. If the voltage value exceeds the reasonable range, the data validity flag is set to invalid, the data is discarded, and the previously valid data is used; if the voltage value is within the reasonable range, the data validity flag is set to valid. The generated voltage state data is stored in a local voltage data register for use in subsequent steps and is also prepared to be sent to the other earphone via the inter-ear communication link. Through the above multi-level filtering and quality checks, the accuracy and reliability of the voltage state data are ensured, laying a solid foundation for power difference assessment.
[0022] S2, receive voltage status data with timestamps, and use bidirectional transmission and timestamp alignment mechanism of inter-ear communication link to obtain a synchronized voltage status dataset containing complete information of the left and right ears; The purpose of this step is to bidirectionally transmit and synchronize the voltage status data collected by the left and right ears, enabling both ears to obtain each other's real-time voltage information and providing data support for subsequent calculations of power differences. Since there may be slight discrepancies in the sampling times of the left and right ears, a timestamp alignment mechanism is needed to ensure the consistency of data timing; specifically, the following steps are included: S21, establish a stable two-way interaural communication link; The inter-ear communication function, based on the Bluetooth communication module, establishes a dedicated bidirectional communication link between the left and right ears. This communication link is independent of the main connection link with the audio source device and is dedicated to data exchange and control signaling transmission between the left and right ears. The control processor configures the inter-ear communication parameters of the Bluetooth communication module, including communication frequency, data packet format, and retransmission mechanism. Inter-ear communication adopts a low-latency mode, prioritizing the real-time performance of data transmission. To improve communication reliability, an Automatic Repeat Request (ARQ) mechanism is enabled; when the receiver detects a data packet error, it requests a retransmission from the sender. The control processor periodically sends heartbeat packets to check the link status; if no response is received from the other party for several consecutive heartbeat cycles, the link is considered abnormal, and an attempt is made to re-establish the connection. A stable inter-ear communication link is the physical basis for voltage and data synchronization, ensuring that data can be reliably transmitted between the left and right ears.
[0023] S22, encapsulate voltage status data and send it to the other earphone; Based on the accurate voltage status data generated in step S1, the control processor encapsulates the local voltage status data into an inter-ear communication data packet. The data packet format includes three parts: header, payload, and checksum. The header contains a data packet type identifier, source address, destination address, and sequence number. The data packet type identifier is set to voltage data type, the source address is the local earphone identifier, the destination address is the counterpart earphone identifier, and the sequence number is used for data packet order management and duplicate detection. The payload contains three fields: voltage value, timestamp, and data validity flag. The checksum uses a Cyclic Redundancy Check (CRC) algorithm to calculate the checksum of the header and payload, which is used by the receiver to detect whether errors occurred during data packet transmission. The control processor sends the encapsulated data packet to the counterpart earphone via the inter-ear communication link, and simultaneously starts a transmit acknowledgment waiting timer. If no receive acknowledgment is received within the timeout period, a retransmission mechanism is triggered, and the data packet is retransmitted.
[0024] S23, Receive voltage data from the other earphone and perform integrity verification; The control processor receives inter-ear communication data packets from the other earphone via the Bluetooth communication module. Upon receiving the data packet, it first extracts the CRC value of the checksum section, recalculates the CRC checksum for the packet header and payload, and compares the calculated result with the received CRC value. If they match, the data packet has passed the integrity check without errors during transmission; if they do not match, the data packet is corrupted, discarded, and a retransmission request is sent to the other earphone. For data packets that pass the integrity check, the control processor parses the packet header, extracts the sequence number, and compares it with the locally recorded received sequence number to determine if the data packet is a duplicate. If the sequence number already exists, it indicates a duplicate data packet, which is discarded to avoid duplicate processing; if the sequence number is new, the received sequence number record is updated, and the payload section is parsed to extract the voltage value, timestamp, and data validity flag of the other earphone, storing them in the other earphone's voltage data register. The integrity check and duplicate detection mechanism ensures that the received voltage data is accurate and reliable.
[0025] S24, perform timestamp alignment and data interpolation processing; Based on the local voltage status data in the local voltage data register and the opposite voltage status data in the opposite voltage data register, a timestamp alignment mechanism is used to achieve data timing synchronization. Since the voltage sampling times of the left and right ears may not be completely consistent, directly comparing their voltage values would introduce timing errors. The control processor extracts the timestamp T1 of the local voltage data and the timestamp T2 of the opposite voltage data, and calculates the absolute value of the timestamp difference. If the absolute value of the timestamp difference is less than a preset time alignment window threshold, the sampling times of the two data points are considered sufficiently close, and they can be directly compared, with the local voltage value and the opposite voltage value output as the synchronization voltage status. If the absolute value of the timestamp difference is greater than the time alignment window threshold, it indicates that the sampling times of the two data points differ significantly, requiring time alignment processing. The control processor selects the data with the newer timestamp as the reference time and performs interpolation estimation on the data with the older timestamp. The interpolation algorithm uses a linear interpolation method, estimating the voltage value corresponding to the reference time based on the older data and its preceding and following historical data points, according to the linear relationship of the timestamps. After interpolation processing, the timestamp-aligned local voltage value and the opposite voltage value are obtained and output as the synchronization voltage status.
[0026] S25, Generate a synchronous voltage state dataset containing complete information about the left and right ears; Based on the timestamp-aligned local and contralateral voltage values, the control processor generates a synchronization voltage state dataset. This dataset contains six fields: left ear voltage value, right ear voltage value, synchronization timestamp, left ear data validity flag, right ear data validity flag, and synchronization quality index. If the local voltage is the left ear, the left ear voltage value is the local voltage value, and the right ear voltage value is the contralateral voltage value; if the local voltage is the right ear, the right ear voltage value is the local voltage value, and the left ear voltage value is the contralateral voltage value. The synchronization timestamp is the reference time selected during the time alignment process. The data validity flags for the left and right ears inherit the validity flags of their respective voltage data. The synchronization quality index is comprehensively evaluated based on the absolute value of the timestamp difference and the data validity flags. If the timestamp difference is small and both data are valid, the synchronization quality index is set to high quality; if the timestamp difference is large or invalid data exists, the synchronization quality index is set to low quality. The generated synchronization voltage state dataset is stored in the synchronization data register for use in subsequent power difference assessment steps. The left and right ears execute the above synchronization process independently to ensure that both obtain a consistent synchronization voltage state dataset, laying the foundation for distributed decision-making.
[0027] S3. Obtain the synchronization voltage state dataset, construct multi-dimensional evaluation indicators and use a weighted scoring intelligent decision-making method to obtain the switching trigger determination result that includes the trigger signal state and comprehensive score; The purpose of this step is to comprehensively assess the degree of power difference between the primary and secondary earbuds based on the synchronized left and right ear voltage data, and to make intelligent decisions based on multi-dimensional parameters to determine whether a master-slave switch is necessary. The decision-making model needs to avoid the additional power consumption and user experience degradation caused by frequent switching, while ensuring timely intervention when the power imbalance reaches a certain level; specifically, it includes the following steps: S31, identify the current primary and secondary earbud roles and extract the corresponding voltage values; Based on the current working state of the TWS earbuds, the control processor identifies the current primary and secondary earbud roles. The primary earbud is the one currently establishing a Bluetooth primary connection with the audio source device, while the secondary earbud receives and forwards data via the inter-ear link. The control processor maintains a role status flag, recording whether the local earbud is currently the primary or secondary earbud. Based on the role status flag, the primary and secondary earbud voltage values are extracted from the synchronization voltage status dataset generated in step S2. If the local earbud is the primary earbud, the primary earbud voltage value is the corresponding value between the left and right earbuds, and the secondary earbud voltage value is the corresponding value on the opposite side; if the local earbud is the secondary earbud, the role correspondence is reversed. After extracting the primary and secondary earbud voltage values, a role consistency check is performed to ensure that the left and right earbuds perceive the primary and secondary roles consistently. If an inconsistency is found, a role synchronization process is triggered, and a unified role state is determined through inter-ear communication negotiation.
[0028] S32, calculate the absolute voltage difference and the relative percentage difference; Based on the extracted primary and secondary ear voltage values, the control processor calculates two basic indicators of the power difference: absolute voltage difference and relative difference percentage. The absolute voltage difference equals the secondary ear voltage value minus the primary ear voltage value; this value represents the absolute difference between the primary and secondary ear voltages, measured in millivolts. The relative difference percentage equals the absolute voltage difference divided by the primary ear voltage value and multiplied by 100; this value represents the relative degree of power difference with respect to the primary ear's power level. The relative difference percentage eliminates the influence of changes in absolute voltage value and accurately reflects the degree of imbalance at different power levels. If the relative difference percentage is positive, it indicates that the secondary ear's power is higher than the primary ear's, indicating an imbalance where the primary ear's power is being consumed too quickly. If the relative difference percentage is negative or close to zero, it indicates that the primary and secondary ear powers are basically balanced or that the secondary ear's power is actually lower, and no switching intervention is needed at this time. The control processor stores the calculated absolute voltage difference and relative difference percentage in a difference evaluation register as the basic data for the evaluation indicators.
[0029] S33, calculates the rate of voltage change and predicts future trends; Based on historical voltage data sequences, the control processor calculates the voltage change rates of the primary and secondary earpieces to predict future power consumption trends. The control processor maintains a historical voltage data buffer, storing voltage sampling sequences from the most recent period. For the primary earpiece, the voltage values and corresponding timestamps of the most recent N sampling moments are extracted. A linear regression model is fitted using the least squares method to obtain the slope of the primary earpiece voltage change over time; this slope is the primary earpiece voltage change rate, measured in millivolts per minute (mV / min). The secondary earpiece voltage change rate is calculated using the same method. A negative voltage change rate indicates a voltage drop, i.e., power consumption; a larger absolute value indicates faster power consumption. The control processor calculates the difference between the primary and secondary earpiece voltage change rates, representing the difference in power consumption rates between the two earpieces. Based on the current voltage value and voltage change rate, a linear extrapolation method is used to predict the primary and secondary earpiece voltage values at future moments, calculating the percentage difference in power consumption at the predicted moment. If the prediction shows that the power difference will continue to widen, it indicates that the current imbalance trend will continue to worsen, increasing the necessity for switching; if the prediction shows that the power difference will narrow, it indicates that the imbalance is naturally improving, reducing the necessity for switching.
[0030] S34, statistically analyze the switching history and calculate the time interval parameter; Based on historical handover records, the control processor statistically analyzes historical parameters related to the handover. The control processor maintains a handover history table, recording the timestamp of each master-slave handover, the battery status at the time of handover, and the reason for the handover. It extracts the timestamp of the most recent handover from the history table and calculates the difference between the current time and the most recent timestamp to obtain the time interval since the last handover. This time interval is used to avoid frequent handovers, ensuring sufficient time between handovers for the handover effect to manifest. Simultaneously, it counts the cumulative number of handovers within a certain time window. If the number of handovers is too high, it indicates that the system may be in an unstable state or the parameter settings are unreasonable, requiring adjustment of the decision threshold. The control processor also analyzes the battery data in the handover history, calculating the average percentage difference in battery power across handovers, as a reference for personalized threshold adjustments.
[0031] S35 integrates multi-dimensional parameters to perform intelligent decision-making; Based on the multi-dimensional evaluation parameters calculated in steps S32 to S34, the control processor constructs an intelligent decision-making model for handover determination. The decision-making model employs a weighted scoring mechanism, assigning weight coefficients to each evaluation parameter. The relative difference percentage is assigned the first weight as the core indicator; the voltage change rate difference and future trend prediction are assigned the second weight as important indicators; and the time interval since the last handover is assigned the third weight as a constraint indicator. The control processor calculates a comprehensive score using the formula: relative difference percentage multiplied by the first weight, plus the absolute value of the voltage change rate difference multiplied by the second weight, plus the normalized value of the time interval multiplied by the third weight. The calculated comprehensive score is compared with a preset handover trigger threshold. If the comprehensive score is greater than the handover trigger threshold, and the relative difference percentage is positive (indicating the secondary ear's battery level is indeed higher than the primary ear's), and the time interval since the last handover is greater than the minimum handover interval threshold, then the handover conditions are met, a handover trigger signal is generated, and the trigger signal's status is set to trigger valid. If any condition is not met, then handover is not required, and the trigger signal's status is set to trigger invalid. The generated handover trigger determination result includes the trigger signal status, comprehensive score value, and parameter values for each dimension, which are then passed to subsequent scene recognition and handover execution steps.
[0032] S4, receive the switching trigger determination result, and use audio stream feature extraction and scene awareness strategy optimization methods to obtain a switching execution strategy that includes execution timing and scene parameters; The purpose of this step is to avoid immediately executing the switch upon receiving the switch trigger signal. Instead, it first identifies the current usage scenario type and selects the optimal timing for the switch based on the characteristics of different scenarios, ensuring that the impact of the switch process on the user experience is minimized. Different usage scenarios have different requirements for the timing of the switch, necessitating a scenario-aware differentiated strategy; specifically, it includes the following steps: S41, collect audio stream feature parameters and extract scene fingerprint; Based on the currently processed audio data stream, the control processor collects characteristic parameters of the audio stream for scene recognition. These parameters include audio sampling rate, audio encoding format, audio data packet size, data packet arrival interval, audio stream direction, and audio signal energy distribution. The control processor obtains audio encoding format information from the audio processing module to determine the current audio codec used; different encoding formats correspond to different application scenarios. It extracts the arrival time series of audio data packets and calculates the statistical characteristics of the data packet arrival interval, including average interval, interval variance, and interval periodicity. It analyzes the direction information of the audio stream to detect the existence of bidirectional audio flow, i.e., both downlink audio flow from the sound source to the headphones and uplink audio flow from the headphones microphone to the sound source; bidirectional flow is a typical characteristic of call scenarios. It performs frequency domain analysis on the audio signal to extract the distribution of signal energy in different frequency bands. Music signals typically have energy distribution across the entire frequency band, while speech signals are mainly concentrated in the mid-to-low frequency band. The extracted multi-dimensional feature parameters are combined to form a scene fingerprint vector, which serves as the input for scene recognition.
[0033] S42, Scenario type classification based on feature matching; Based on the scene fingerprint vector extracted in step S41, the control processor performs scene type classification. The control processor pre-stores feature templates for several typical scenes, including call mode templates, music playback mode templates, video viewing mode templates, and game mode templates. The call mode template is characterized by the presence of bidirectional audio streams, with the uplink stream containing voice signals, relatively regular data packet arrival intervals, and encoding formats typically narrowband or wideband voice coding. The music playback mode template is characterized by the presence of only downlink audio streams, with the audio signal being a full-band high-fidelity signal, encoding format high-quality music coding, and stable data packet arrival intervals. The video viewing mode template is similar to the music mode template but with a higher data packet rate and the presence of video frame synchronization markers. The game mode template is characterized by high-frequency bursts in data packet arrival intervals, extremely high requirements for transmission latency, and may contain the characteristic spectrum of game sound effects. The control processor calculates the similarity between the scene fingerprint vector and each template, using Euclidean distance or cosine similarity as the similarity metric. The scene type corresponding to the template with the highest similarity is selected as the current scene identification result. If the similarity of all templates is below the confidence threshold, it is determined to be an unknown scene type, and the default strategy is used for processing.
[0034] S43, adjust the switching priority and timing according to the recognition scenario; Based on the scene recognition results from step S42, the control processor adjusts the switching execution strategy according to the characteristics of different scenes. If the recognition result is a call mode, since switching during a call may cause fluctuations in call quality or brief interruptions, affecting the call experience, the control processor lowers the switching priority, sets a delayed execution flag, monitors the call status, and waits for the call to end before executing the switch. The call ends when both the uplink and downlink audio streams stop, or when a silent gap occurs after the call duration exceeds a preset call timeout threshold. If the recognition result is a music playback mode, the control processor analyzes silent segments in the audio stream. There are usually brief silent gaps between music tracks, which are ideal times for switching. The control processor monitors the audio signal energy. When the signal energy is detected to be below the silence threshold and the duration exceeds the minimum silence duration, it is determined to be a silent gap, and the switch is executed immediately. If the recognition result is a game mode, the control processor assesses the impact of switching on audio latency. Game scenarios have high requirements for audio and video synchronization, and even a very brief switching process may be perceived by the user. The control processor calculates the expected latency increment for switching execution. If the latency increment exceeds the acceptable latency threshold for the game, the switch is postponed until the game ends or during a game break. If the identification result is a video viewing mode or an unknown scenario, a conservative strategy is adopted, and the switch is performed when the audio stream is detected to pause naturally or be paused by the user.
[0035] S44, detect user interaction operations and identify active pause events; Based on user interaction detection, the control processor identifies events where the user actively pauses playback, which represents the optimal time to perform a switch. The control processor monitors control commands from the audio source device; upon receiving a pause command, it determines that the user has actively paused audio playback. Simultaneously, it monitors touch or button inputs on the TWS earbuds; if a pause gesture or button press is detected, it is also considered a user-initiated pause. In the user-initiated pause state, audio streaming stops, and performing a switch at this time will not affect audio continuity, making it an ideal switching window. After detecting an active pause event, the control processor immediately checks if there is a pending switch task. If so, and the switch trigger signal is still valid, the switch execution timing is set to immediate execution, prioritizing the use of the pause window to complete the switch. If the pause time is short and the user quickly resumes playback, the control processor assesses whether the remaining time is sufficient to complete the switch; if not, it abandons the current switch opportunity and waits for a more suitable time.
[0036] S45, Generate a switching strategy that includes execution timing and scenario parameters; Based on scene recognition, timing analysis, and user interaction detection in steps S41 to S44, the control processor generates an optimized handover execution strategy. The handover execution strategy includes five fields: execution timing, scene type, priority, delay time, and special constraints. Execution timing is divided into three types: immediate execution, delayed execution, and conditional execution. Immediate execution means the handover process can begin immediately, suitable for situations where a silence interval is detected or the user actively pauses the call. Delayed execution means execution requires waiting for a certain period; the delay time field records the required waiting time. Conditional execution means execution requires waiting for a specific condition to be met; the special constraints field records the waiting conditions, such as waiting for a call to end or a game level to end. The scene type field records the currently identified scene for parameter configuration in subsequent steps. The priority field is set according to scene characteristics and battery urgency; the greater the battery difference and the smaller the scene's impact, the higher the priority. The generated handover execution strategy is passed to the handover preparation and execution steps, guiding the specific implementation of the handover process. Through scene-aware strategy optimization, the handover operation is ensured to be executed at the most appropriate time, minimizing the impact on user experience.
[0037] S5, start the preparation process according to the switching execution strategy, and use the dual-link parallel mechanism and state data pre-synchronization method to obtain the switching ready signal of the new master ear and the old master ear; The purpose of this step is to prepare the new master ear (i.e., the current slave ear) to take over the master ear's responsibilities before the formal master-slave role switch. This includes establishing a backup connection channel with the audio source device, synchronizing all necessary status data and configuration parameters, and ensuring the new master ear is ready to seamlessly take over audio stream processing at any time, laying the foundation for a zero-lag switch. Specifically, it includes the following steps: S51, the Bluetooth master mode function module for activating the new master earbud; Based on the switching execution strategy generated in step S4, when the switching execution time arrives, the control processor initiates the functional preparation process for the new master ear. The new master ear is the current slave ear, and its Bluetooth communication module is currently operating in slave mode, maintaining only the inter-ear communication link with the old master ear. The control processor sends a mode switching command to the Bluetooth communication module of the new master ear, instructing it to activate the master mode function. After receiving the command, the Bluetooth communication module initializes the hardware resources and software protocol stack related to the master mode. Hardware resources include RF transmit power amplifiers, receive sensitivity adjustment circuits, multi-connection management units, etc. These modules are in a powered-off or low-power state in slave mode and require power-on and configuration. Software protocol stack initialization includes loading modules such as the master mode link management layer, logical link control and adaptation protocol layer, and service discovery protocol layer, and allocating memory resources for multi-connection management and data buffering. After initialization, the Bluetooth communication module of the new master ear has the ability to establish a master connection with external audio source devices, while maintaining the inter-ear communication link with the old master ear, forming a dual-mode parallel operation state.
[0038] S52, transmits Bluetooth connection parameters and establishes a backup connection channel; Based on the activation of the new master ear's main mode function, the old master ear (the current master ear) transmits Bluetooth connection parameters with the audio source device to the new master ear via the inter-ear communication link. These connection parameters include the audio source device's Bluetooth address, device name, pairing key, link key, connection handle, link monitoring timeout parameters, transmit power level, and frequency hopping sequence. The old master ear's control processor extracts these parameters from the Bluetooth protocol stack, encapsulates them into a parameter transmission data packet, and sends it to the new master ear via the inter-ear communication link. Upon receiving the connection parameters, the new master ear parses the data packet and configures the parameters in its local Bluetooth protocol stack. Based on the configured connection parameters, the new master ear initiates a backup connection request to the audio source device. The backup connection is established using a fast connection mode, utilizing existing pairing information and link keys to skip the pairing and authentication processes and directly enter the connection establishment phase. Upon receiving the new master ear's connection request, the audio source device recognizes that it is a backup connection request from the same TWS earphone system, accepts the connection, and assigns a new connection handle to the new master ear. At this time, there are two parallel Bluetooth connections between the audio source device and the TWS earphone system: one is the original main connection of the old master earphone, and the other is the backup connection of the new master earphone. Both connections are active at the same time.
[0039] S53, synchronizes audio decoder configuration and playback status; Based on the successful establishment of the backup connection, the old master ear synchronizes the audio decoder configuration parameters and current playback status to the new master ear. Audio decoder configuration parameters include codec type, sampling rate, bit depth, channel configuration, decoding buffer size, equalizer settings, and audio processing parameters. The old master ear's control processor reads these configuration parameters from the audio processing module and transmits them to the new master ear via the inter-ear communication link. Playback status information includes the currently decoded audio frame number, playback clock timestamp, audio buffer fill level, and the number of decoded but unplayed frames. This status information is crucial for seamless switching, ensuring the new master ear can continue decoding and playback from the correct position. After receiving the configuration parameters and playback status, the new master ear configures its local audio processing module's decoder to be completely consistent with the old master ear's decoder configuration. Based on the playback status information, the new master ear's decoder locates the current playback position and prepares to take over audio stream processing from that position. To ensure clock synchronization, the old and new master earpieces perform a playback clock alignment process, exchanging clock information through an inter-ear communication link, calculating the deviation between their clocks, and the new master earpiece adjusts its local playback clock according to the deviation, achieving millisecond-level clock synchronization accuracy.
[0040] S54, preloads audio buffer data and verifies decoding capabilities; Based on the synchronized audio decoder configuration and playback status, the old master ear transmits audio buffer data to the new master ear, allowing the new master ear to preload a certain amount of audio data. The old master ear extracts the audio data packets to be played from the audio buffer. These data packets may be decoded PCM audio frames or compressed audio packets to be decoded, and the appropriate data type is selected for transmission according to the synchronization strategy. The audio buffer data is transmitted to the new master ear in batches through the inter-ear communication link, and the new master ear stores it in its local audio buffer after receiving it. The amount of preloaded data needs to cover the playback time that may be consumed during the switching process to ensure that audio playback will not be interrupted due to insufficient data during the switching. After receiving the audio buffer data, the new master ear starts the decoder to perform trial decoding verification, performs decoding operations on some data packets, checks whether the decoding output is normal, and verifies the integrity of the audio processing path. If the trial decoding is successful and outputs correct PCM audio data, it means that the new master ear's decoding capability is ready; if the trial decoding fails, it reports an abnormality to the old master ear, stops the switching process, and investigates the problem. Through preloading and verification, it is ensured that the new master ear can handle the audio stream immediately and seamlessly.
[0041] S55, establish a dual-link coordination mechanism and generate a handover ready signal; With the backup connection, state synchronization, and data preloading of the new master ear all completed, the control processor establishes a dual-link collaborative mechanism to make final preparations for the formal handover. The dual-link collaborative mechanism means that both the old and new master ears maintain connections with the audio source device simultaneously, working together to ensure a smooth transition during the handover process. The old master ear sends a handover preparation completion message to the new master ear via the inter-ear communication link, and the new master ear replies with a ready confirmation message. After exchanging ready states, the control processor synchronously sets handover collaborative parameters in both the old and new master ears, including the handover start time, transition duration, and data stream switching rate. The handover start time needs to be selected at an appropriate position in the audio stream, such as the end of the current audio frame, to avoid switching in the middle of a frame and causing audio discontinuity. The transition duration is dynamically adjusted according to the scenario type and link quality; a fast handover is used to shorten the transition time under good conditions, while a longer transition time is used to ensure stability under poor conditions. The data stream switching rate controls the speed at which audio data migrates from the old master ear to the new master ear, using a gradual rather than abrupt approach. Once all parameters are agreed upon, the old master ear and the new master ear each generate a switching ready signal. This signal indicates that the system is fully ready to perform a zero-lag switching and can enter the formal switching execution phase.
[0042] S6 receives the handover readiness signals from the new master ear and the old master ear, and uses a gradual data stream transition control and dual-link weight dynamic adjustment method to obtain a stable connection and handover completion flag under the new master-slave architecture. The purpose of this step is to formally switch the master-slave roles after the new master ear is ready, smoothly transitioning the audio data stream from the old master ear to the new master ear, while simultaneously adjusting the data forwarding direction, ultimately establishing a new master-slave architecture. The entire process ensures continuous and uninterrupted audio playback, without the user noticing. Specifically, it includes the following steps: S61, initiate the gradual data flow transition mechanism; Based on the handover readiness signal and coordination parameters generated in step S5, the control processor initiates a gradual data stream transition mechanism at the start of the negotiated handover. The core idea of gradual transition is that during the transition period, the audio source device sends audio data bidirectionally to both the old and new master ears. The old master ear gradually reduces the proportion of audio data reception and processing, while the new master ear gradually increases the proportion of audio data reception and processing, achieving seamless data stream migration through smooth changes in proportion. The control processor coordinates data stream allocation on both the audio source device and TWS earphone sides. Based on the handover negotiation message sent by the old master ear, the audio source device enters a dual-stream transmission mode, simultaneously sending the same audio data to both the old and new master ear connections. Initially, the transmission power and data packet priority of the two links are consistent. On the TWS earphone side, both the old and new master ears simultaneously receive audio data packets from the audio source device. Initially, the old master ear processes all received data packets and decodes and plays them, while the new master ear receives data packets but does not yet perform playback processing, only buffering the data and verifying the reception quality.
[0043] S62 dynamically adjusts the processing weights and output mixing of the dual links; The system starts with a gradual transition mechanism, where the control processor dynamically adjusts the processing weights of the two links according to a preset transition timeline. The transition timeline is divided into multiple stages, each lasting tens of milliseconds, with the weight distribution gradually changing in each stage. In the first stage, the old master ear receives a first weight value, and the new master ear receives a second weight value, with the first weight value significantly greater than the second. The old master ear fully decodes the received audio data, outputting the decoded PCM audio frames to the speaker driver module, and simultaneously forwarding them to the new slave ear according to the proportion of the first weight value. The new master ear partially decodes the received audio data, outputting the decoded PCM audio frames to the speaker driver module according to the proportion of the second weight value. The speaker driver module adjusts the mixing ratio of the two audio signals based on the weight values, initially prioritizing the audio from the old master ear and supplementing it with the audio from the new master ear. Upon entering the second stage, the weight of the old master ear decreases to a third weight value, while the weight of the new master ear increases to a fourth weight value, with the third and fourth weight values approaching equality, resulting in a proportional mixing of the two audio signals. Continuing into the third stage, the weight of the old master ear is further reduced to the fifth weight value, while the weight of the new master ear is further increased to the sixth weight value. The sixth weight value is significantly greater than the fifth weight value, and the audio output is dominated by the new master ear. Through multi-stage gradual weight changes, a smooth transition of the audio stream from the old master ear to the new master ear is achieved, avoiding audio jumps or stutters caused by abrupt changes.
[0044] S63, switch the data forwarding direction and adjust the inter-ear communication link; As audio stream control gradually shifts to the new master ear, the control processor synchronously adjusts the data forwarding direction and the role of the inter-ear communication link. In the original master-slave architecture, the old master ear was responsible for forwarding audio data to the old slave ear (i.e., the new master ear). With the new master ear taking over the main audio processing tasks, the data forwarding direction needs to be reversed, with the new master ear forwarding audio data to the new slave ear (i.e., the old master ear). In the second stage, when the weights of the two links are nearly equal, the control processor begins preparing for the forwarding direction switch. The new master ear's audio processing module initiates the data forwarding function, sending the received and decoded audio data to the old master ear via the inter-ear communication link. At this point, the old master ear can receive audio data from two sources: data received from the audio source device itself, and data forwarded from the new master ear. The old master ear's control processor compares the two data streams, verifying the correctness and synchronization of the data forwarded by the new master ear. After confirming that there are no errors, it gradually switches to receiving and forwarding data as the primary mode. In the third stage, the old master ear actively reduces the weight of data reception from its primary connection with the audio source device and increases the weight of receiving and forwarding data from the new master ear, gradually transitioning to slave mode. The new master ear increases the weight of data reception and forwarding in its connection with the main audio source device, gradually transitioning to the master mode operating state. The data flow of the inter-ear communication link is reversed, changing from the old master ear to the new master ear to the new master ear to the old master ear.
[0045] S64, Disconnect the old master ear connection and confirm that the new master ear connection is stable; As the data flow transitions into the third stage, the new master ear has become the dominant audio processor, and the old master ear's primary connection can be safely disconnected. The control processor monitors the connection quality metrics between the new master ear and the audio source device, including packet reception success rate, signal strength, and retransmission rate, confirming a stable and high-quality connection. Simultaneously, it monitors the audio output quality of the new master ear, analyzing the output waveform of the speaker driver module to detect audio distortion, stuttering, or interruptions, ensuring smooth audio playback. Once all metrics reach stable levels, the old master ear's control processor sends a disconnection request to the audio source device. This request includes a normal disconnection reason code, informing the audio source device that this is an expected master-slave switch rather than an abnormal disconnection. Upon receiving the disconnection request, the audio source device releases the old master ear's connection resources, retaining the new master ear's connection as the sole primary connection. The old master ear's Bluetooth communication module closes its primary mode connection with the audio source device, releasing corresponding hardware and protocol stack resources, and switches to a dedicated slave mode configuration. The new master ear's connection is upgraded from a backup connection to a formal primary connection, and the audio source device updates its connection table, marking the new master ear as the current primary connection target. At this point, the TWS earphone system has completed a substantial switch between master and slave roles, with the new master ear becoming the master ear and the old master ear becoming the slave ear.
[0046] S65, verify the new master-slave architecture and generate a switchover completion flag; With the old master ear connection disconnected and the new master ear connection stable, the control processor performs a comprehensive verification of the new master-slave architecture. The verification includes connection status verification, audio stream quality verification, data forwarding verification, and role consistency verification. Connection status verification checks whether the connection between the new master ear and the audio source device is active, whether the connection parameters are correct, and whether the link is stable. Audio stream quality verification analyzes the continuity, synchronization, and fidelity of the audio output to ensure that the switching process does not introduce audio quality degradation. Data forwarding verification checks whether the data forwarding function from the new master ear to the new slave ear is working properly, whether the new slave ear can correctly receive and play the forwarded audio data, and whether the audio synchronization error between the left and right ears is within acceptable limits. Role consistency verification confirms that both the new master ear and the new slave ear have a consistent understanding of their respective roles to avoid role confusion. The control processor checks all verification items one by one. If all pass, a switching completion flag is generated, recording the switching completion time, the new master ear identifier, the new slave ear identifier, and the switching time. The switching completion flag is written to the switching history table, the system's role status flag is updated, and the audio processing module and power management module are notified that the role has been switched. The new master-slave architecture has been officially established, and the system has entered a stable operating state, preparing for the next round of power monitoring and possible switching.
[0047] S7, based on the stable connection and switching completion flags under the new master-slave architecture, uses a modular task migration and power redistribution method to obtain the power consumption status and return to the voltage monitoring loop; The purpose of this step is to systematically migrate workloads and redistribute power consumption after the master-slave role switch is completed. This ensures that the new master ear fully takes over all high-power tasks, the new slave ear's power consumption drops to a low level, achieving a dynamic balance in power consumption, and continuously monitoring to prepare for the next switchover. Specifically, it includes the following steps: S71, the new master ear fully takes over Bluetooth connection management tasks; Based on the new master-slave architecture established by the S6 steps, the control processor of the new master ear fully takes over Bluetooth connection management tasks. Bluetooth connection management tasks include multiple sub-tasks such as link quality monitoring, connection parameter negotiation, power control, frequency hopping management, retransmission control, and flow control. The Bluetooth communication module of the new master ear initiates the link quality monitoring function, periodically checking the signal strength index (RSSI), packet error rate, round-trip time (RTT), and other indicators of the connection with the audio source device, and dynamically adjusting connection parameters based on the monitoring results. When a link quality degradation is detected, the new master ear proactively initiates a connection parameter update request to the audio source device, negotiating better connection intervals, slave device latency, monitoring timeouts, and other parameters to optimize connection performance. The power control module of the new master ear adaptively adjusts the transmission power according to the signal strength, reducing power to save energy when the signal is good and increasing power to ensure connection stability when the signal is weak. Frequency hopping management is responsible for dynamically selecting less interference frequencies within the 2.4GHz band, maintaining the frequency hopping sequence list, and keeping synchronized with the audio source device. Retransmission control and flow control ensure the reliability and efficiency of data transmission, adjusting retransmission strategies and transmission rates according to network conditions. The execution of these tasks requires the Bluetooth communication module to operate continuously in a high-power state, the radio frequency transceiver unit to start frequently, and the protocol stack to operate continuously, which is one of the main sources of the high power consumption of the main ear.
[0048] S72, the new master ear continuously performs audio decoding and data forwarding tasks; With the primary connection of the new master ear stable, the audio processing module continuously performs audio decoding tasks. The new master ear receives compressed audio data packets from the audio source device, and the decoder in the audio processing module performs real-time decoding processing on the data packets. The decoding process includes multiple computationally intensive steps such as data packet decapsulation, compression format parsing, frequency domain or time domain transformation, and audio sampling point reconstruction. It requires the processor to continuously perform complex calculations and is one of the high-power tasks. After decoding, the original PCM audio sampling data is obtained. One path is directly sent to the local speaker driver module for playback, and the other path needs to be forwarded to the new slave ear through the inter-ear communication link. The data forwarding task includes encapsulation, compression or encoding of forwarded data, transmission through the inter-ear link, and reception of forwarding confirmation. To ensure audio synchronization between the left and right ears, the forwarding process needs to carry precise timestamps and synchronization information. The control processor of the new master ear is responsible for maintaining the synchronization clock and generating synchronization signaling. At the same time, the new master ear needs to monitor the reception status of the new slave ear. If it detects that the reception buffer of the new slave ear is about to overflow or become underloaded, it adjusts the forwarding rate or inserts padding frames in time to maintain smooth audio playback. The continuous execution of audio decoding and data forwarding significantly increases the load on the audio processing module and control processor of the new primary ear compared to the new secondary ear, resulting in power consumption differences.
[0049] S73, the new secondary earbud disables the main mode function and reduces power consumption; Based on the role transition of the new secondary earbud (formerly the primary earbud), the control processor executes a process to disable primary mode functions and reduce power consumption. The new secondary earbud's Bluetooth communication module disables primary mode-related functional units, including the primary mode RF transmit power amplifier, multi-connection management unit, active scanning, and connection initiation unit. These units require continuous power and operation in primary mode but can be disabled in secondary mode to save power. After disabling the RF transmit power amplifier, the new secondary earbud retains only receive and low-power transmit functions for inter-ear communication, significantly reducing RF power consumption. Disabling the multi-connection management unit reduces the protocol stack burden and lowers processor utilization. The new secondary earbud's Bluetooth communication module switches to a dedicated secondary mode configuration, maintaining only the inter-ear communication link with the new primary earbud. This communication link uses a low-power mode, entering sleep mode when there is no data transmission and waking up only when data arrives. The new secondary earbud's audio processing module is also simplified accordingly, no longer performing complex audio decoding tasks, but only receiving decoded or simply encoded audio data forwarded by the new primary earbud. The audio processing load is significantly reduced, allowing the processor to reduce its operating frequency or enter a deeper power-saving mode. Through systematic function shutdown and mode switching, the overall power consumption of the new secondary earphone is reduced to a level comparable to that of the original secondary earphone.
[0050] S74 dynamically monitors the changes in the charge of the new primary and secondary earpieces and records the consumption curve; After the load migration and power redistribution are completed, the system returns to step S1 to continue precise acquisition of dual-ear voltage, initiating a new power monitoring cycle. At this point, the roles have been reversed: the former secondary ear becomes the new primary ear, undertaking high-power tasks and increasing its battery consumption rate; the former primary ear becomes the new secondary ear, with reduced power consumption and a decreased battery consumption rate. The control processor continuously collects and records voltage change data from both ears, plotting power consumption curves. Before the switch, the primary ear's power curve has a steeper slope, while the secondary ear's curve has a shallower slope, and the two curves gradually separate. After the switch, the slopes of the two curves reverse: the previously faster-decreasing curve becomes shallower, and the previously slower-decreasing curve becomes steeper, causing the two curves to approach and intersect. Through continuous monitoring and recording, the control processor analyzes the changing trends of the power consumption curves and evaluates the switching effect. Ideally, after several master-slave switches, the power curves of the left and right ears exhibit an alternating, sawtooth-like decline, but the overall trend tends towards a synchronized decline, with the power difference remaining within a small range to prevent one side from depleting its power too quickly.
[0051] S75, adaptively optimizes decision parameters and prepares for the next switching loop; Based on the analysis of power consumption curves and the accumulation of historical switching data, the control processor adaptively optimizes the decision parameters. The control processor extracts data from multiple switching history records, including power differences at each switching point, switching timing, switching time, and the rate of power change after switching. It analyzes the statistical characteristics and patterns of this data. Based on the analysis results, the decision model parameters in step S3 are adjusted, including the switching trigger threshold, the weighting coefficients of each evaluation parameter, and the minimum switching interval threshold. If excessively high historical switching frequencies lead to increased power consumption, the switching trigger threshold is appropriately increased or the minimum switching interval is increased to reduce the switching frequency. If the power imbalance remains significant, indicating insufficient switching timeliness or poor effectiveness, the switching trigger threshold is lowered or the weighting coefficients are adjusted to increase switching sensitivity. The optimized parameters are stored in non-volatile memory to ensure they are not lost after power failure and remain effective. Simultaneously, the control processor further personalizes the parameters based on user usage patterns, such as daily usage time, charging frequency, and common scenarios, achieving user-level adaptive optimization. After optimization, the system remains in power monitoring mode. When a power difference is detected again and reaches the trigger condition, a new round of switching process is initiated, achieving dynamic power balance management through continuous monitoring, switching, and optimization. Through continuous monitoring, switching, and optimization, this invention effectively solves the power imbalance problem between the primary and secondary earbuds in TWS earphones, significantly improving overall battery life.
[0052] In one embodiment of the present invention, a dynamic power optimization allocation system for TWS earphones is provided, for performing the steps in the aforementioned dynamic power optimization allocation method for TWS earphones, such as... Figure 2As shown, it includes: The voltage acquisition module is used to acquire the real-time voltage signals of the left and right ear batteries. It adopts adaptive sampling frequency configuration and multi-level filtering technology to obtain voltage status data with timestamps. The data synchronization module is used to receive voltage status data with timestamps, and uses bidirectional transmission via inter-ear communication link and timestamp alignment mechanism to obtain a synchronized voltage status dataset containing complete information of the left and right ears. The decision-making module is used to acquire the synchronization voltage state dataset, and adopts a multi-dimensional evaluation index construction and weighted scoring intelligent decision-making method to obtain the switching trigger determination result including the trigger signal state and comprehensive score; The scene recognition module is used to receive the switching trigger determination result and use audio stream feature extraction and scene perception strategy optimization methods to obtain a switching execution strategy that includes execution timing and scene parameters. The switching preparation module is used to start the preparation process according to the switching execution strategy. It adopts a dual-link parallel mechanism and a state data pre-synchronization method to obtain the switching ready signals of the new master ear and the old master ear. The switching execution module is used to receive the switching readiness signals of the new master ear and the old master ear. It adopts a gradual data flow transition control and a dual-link weight dynamic adjustment method to obtain a stable connection and switching completion flag under the new master-slave architecture. The load management module is used to obtain the power consumption status and return it to the voltage monitoring loop based on the stable connection and switching completion flags under the new master-slave architecture, using modular task migration and power redistribution methods.
[0053] This invention focuses on long-lasting battery life applications in urban commuting and office scenarios. The following is a real-world application example demonstrating the actual performance of the method described in this invention.
[0054] A user wears TWS earbuds to commute every morning at 8 AM, with a commute of approximately 2 hours, during which they mainly listen to podcasts and music. Upon arriving at the office, they continue wearing the earbuds, participating in a 1-hour online meeting in the morning, watching 30 minutes of video during their lunch break, and continuously listening to background music for 3 hours in the afternoon. Their return commute begins at 6 PM and lasts 2 hours. The total daily usage time is approximately 8.5 hours, encompassing various scenarios including music playback, conference calls, and video viewing.
[0055] Using the dynamic power optimization allocation method of this invention, the system's operating data throughout the day is as follows. At 8:00 AM, both ears had 100% power, and the system initially set the right ear as the primary ear and the left ear as the secondary ear. The voltage acquisition module periodically sampled at a first frequency value, and the sampled data underwent multi-stage filtering to obtain accurate voltage status data. Table 1 shows some of the voltage monitoring data collected during the morning period.
[0056] Table 1. Example of voltage monitoring data during the morning session.
[0057] As shown in Table 1, with the passage of time, the voltage of the right primary ear decreased at a significantly faster rate than that of the left secondary ear, the voltage difference gradually increased, and the decision score continued to rise. At 10:30, the decision score of 148 exceeded the preset switching trigger threshold of 120, and the time interval since the last power-on exceeded the minimum switching interval, so the system determined that the switching conditions were met. At this time, the user was listening to music, and the scene recognition module identified it as music playback mode, detecting that the current track was about to end and there was a silent interval. The switching execution timing was set to the track interval. At 10:31, the track ended, and the system started the switching process. The left ear switched from the secondary ear to the primary ear, and the right ear switched from the primary ear to the secondary ear. The entire switching process took about 80 milliseconds, and the user did not perceive any audio interruption.
[0058] After the switch was completed, the left ear became the new primary ear and began to undertake high-power tasks, while the right ear became the new secondary ear and its power consumption decreased. Table 2 shows some of the voltage monitoring data collected in the afternoon.
[0059] Table 2, Example of voltage monitoring data during the afternoon session
[0060] As shown in Table 2, after the switch, the voltage drop rate of the right ear as the secondary ear slowed down significantly, while the voltage drop rate of the left ear as the new primary ear increased. The voltage difference was positive at 14:00 (90mV) but turned negative at 15:00 (-30mV), indicating that the voltage levels on both sides had become close and started to reverse. By 16:00, the negative voltage difference reached -150mV, and the absolute value of the decision score (82) was close to the trigger threshold. It is expected that another switch will be triggered around 16:30, reversing the primary and secondary roles again.
[0061] Through dynamic switching and power balancing management throughout the day, when the user returned home at 18:00, the battery levels of the left and right ears were 28% and 32% respectively, with a difference of only 4%. Compared to the severe imbalance of 10% battery in the primary ear and 55% battery in the secondary ear under the traditional fixed master-slave architecture, this invention achieves a significant power balancing effect. During the entire day's use, three master-slave switches were performed, and the user did not experience any audio interruption or connection abnormalities during each switch, verifying the effectiveness of the zero-lag switching mechanism.
[0062] This invention effectively solves the technical problem of power imbalance between the main and secondary earbuds in TWS earphones by constructing a complete dynamic power optimization allocation method. It achieves balanced power consumption and improved battery life, while ensuring a seamless switching process and a continuous user experience. It has significant practical value and broad application prospects.
[0063] The embodiments of the present invention have been described above. However, the embodiments are not limited to the specific implementation methods described above. The specific implementation methods described above are merely illustrative and not restrictive. Those skilled in the art can make more equivalent embodiments under the guidance of the present embodiments, and all of them are within the protection scope of the present embodiments.
Claims
1. A dynamic power optimization allocation method for TWS earphones, characterized in that, Includes the following steps: S1, acquire the real-time voltage signals of the left and right ear batteries, and use adaptive sampling frequency configuration and multi-level filtering processing method to obtain voltage state data with timestamps; S2, receive voltage status data with timestamps, and use bidirectional transmission and timestamp alignment mechanism of inter-ear communication link to obtain a synchronized voltage status dataset containing complete information of the left and right ears; S3. Obtain the synchronization voltage state dataset, construct multi-dimensional evaluation indicators and use a weighted scoring intelligent decision-making method to obtain the switching trigger determination result that includes the trigger signal state and comprehensive score; S4, receive the switching trigger determination result, and use audio stream feature extraction and scene awareness strategy optimization methods to obtain a switching execution strategy that includes execution timing and scene parameters; S5, start the preparation process according to the switching execution strategy, and use the dual-link parallel mechanism and state data pre-synchronization method to obtain the switching ready signal of the new master ear and the old master ear; S6 receives the handover readiness signals from the new master ear and the old master ear, and uses a gradual data stream transition control and dual-link weight dynamic adjustment method to obtain a stable connection and handover completion flag under the new master-slave architecture. S7, based on the stable connection and switching completion flags under the new master-slave architecture, uses a modular task migration and power redistribution method to obtain the power consumption status and return to the voltage monitoring loop.
2. The dynamic power optimization allocation method for TWS earphones according to claim 1, characterized in that, S1 includes: Configure a voltage acquisition channel with an adaptive sampling frequency. When the battery voltage is higher than the first voltage threshold, the sampling frequency is set to the first frequency value. When the battery voltage is between the first and second voltage thresholds, the sampling frequency is increased to the second frequency value. When the battery voltage is lower than the second voltage threshold, the sampling frequency is increased to the third frequency value. Perform periodic voltage sampling and record the raw data; apply moving average filtering to eliminate high-frequency noise; Kalman filtering is used to eliminate transient drops caused by load fluctuations. A Kalman filter state-space model is established, with the actual battery voltage and voltage change rate as the state variables and the moving average filter output value as the observed variable. Accurate voltage state data with timestamps is generated.
3. The dynamic power optimization allocation method for TWS earphones according to claim 1, characterized in that, S2 includes: Establish a stable two-way communication link between the ears and enable the automatic retransmission request mechanism; Encapsulate voltage status data and send it to the other earphone. The data packet format includes three parts: header, payload, and check. The check part adopts a cyclic redundancy check algorithm. Receive voltage data from the other earphone and perform integrity verification; perform timestamp alignment and data interpolation processing. If the absolute value of the timestamp difference is less than the preset time alignment window threshold, it is directly compared. If the absolute value of the timestamp difference is greater than the preset time alignment window threshold, the data with the newer timestamp is selected as the reference time and the data with the older timestamp is interpolated and estimated. Generate a synchronous voltage state dataset containing complete information for both left and right ears.
4. The dynamic power optimization allocation method for TWS earphones according to claim 1, characterized in that, S3 includes: Identify the current primary and secondary earbud roles and extract the corresponding voltage values; Calculate the absolute voltage difference and the relative percentage difference. The absolute voltage difference is equal to the secondary ear voltage value minus the primary ear voltage value. The relative percentage difference is equal to the absolute voltage difference divided by the primary ear voltage value and then multiplied by 100. The voltage change rate is calculated and the future trend is predicted. The least squares method is used to fit a linear regression model to obtain the voltage change rate of the primary ear and the voltage change rate of the secondary ear. Based on the current voltage value and the voltage change rate, the linear extrapolation method is used to predict the voltage values of the primary and secondary ears at future times. The system collects historical data on switching and calculates time interval parameters. It integrates multi-dimensional parameters to perform intelligent decision-making. The decision-making model adopts a weighted scoring mechanism, with the relative difference percentage as the first weight, the voltage change rate difference and future trend prediction as the second weight, and the time interval since the last switching as the third weight. The system calculates a comprehensive score and compares it with a preset switching trigger threshold.
5. The dynamic power optimization allocation method for TWS earphones according to claim 1, characterized in that, S4 includes: The audio stream feature parameters are collected and scene fingerprints are extracted. The feature parameters include audio sampling rate, audio encoding format, audio data packet size, data packet arrival interval, audio stream direction, and audio signal energy distribution. Based on feature matching, scenario type classification is performed. Feature templates for multiple typical scenarios are pre-stored, including call mode template, music playback mode template, video viewing mode template and game mode template. The similarity between the scenario fingerprint vector and each template is calculated. Adjust the switching priority and timing according to the recognition scenario. If the recognition result is a call mode, set a delayed execution flag and wait for the call to end before switching. If the recognition result is a music playback mode, monitor the silent segments in the audio stream and switch during the silence interval. Detect user interaction operations and identify active pause events; generate a switching execution strategy that includes execution timing and scenario parameters.
6. The dynamic power optimization allocation method for TWS earphones according to claim 1, characterized in that, S5 includes: Activate the Bluetooth master mode function module of the new master earbud and initialize the hardware resources and software protocol stack related to master mode; Transmit Bluetooth connection parameters and establish a backup connection channel. The connection parameters include the Bluetooth address, device name, pairing key, link key, connection handle, link monitoring timeout parameters, transmit power level, and frequency hopping sequence of the audio source device. The new master ear initiates a backup connection request to the audio source device. There are two parallel Bluetooth connections between the audio source device and the TWS earphone system. Synchronize audio decoder configuration and playback status. Playback status information includes the currently decoded audio frame number, playback clock timestamp, audio buffer fill level, and number of decoded but not played frames. Preload audio buffer data and verify decoding capabilities; establish a dual-link coordination mechanism and generate a switching ready signal.
7. The dynamic power optimization allocation method for TWS earphones according to claim 1, characterized in that, S6 includes: A gradual data stream transition mechanism is initiated, in which the audio source device sends audio data bidirectionally to both the old master ear and the new master ear. The old master ear gradually reduces the proportion of audio data received and processed, while the new master ear gradually increases the proportion of audio data received and processed. The processing weights and output mixing of the dual links are dynamically adjusted, and the transition time axis is divided into multiple stages. In the first stage, the old master ear is processed with the first weight value and the new master ear is processed with the second weight value. In the second stage, the old master ear weight is reduced to the third weight value and the new master ear weight is increased to the fourth weight value. In the third stage, the old master ear weight is reduced to the fifth weight value and the new master ear weight is increased to the sixth weight value. The data forwarding direction is switched and the inter-ear communication link is adjusted, changing the data flow of the inter-ear communication link from the old master ear to the new master ear to the new master ear; Disconnect the old master ear connection and confirm that the new master ear connection is stable; verify the new master-slave architecture and generate a switchover completion flag.
8. The dynamic power optimization allocation method for TWS earphones according to claim 1, characterized in that, S7 includes: The new master ear takes over all Bluetooth connection management tasks, including link quality monitoring, connection parameter negotiation, power control, frequency hopping management, retransmission control, and flow control. The new master ear continuously performs audio decoding and data forwarding tasks. The decoding process includes data packet decapsulation, compression format parsing, frequency domain or time domain transformation, and audio sampling point reconstruction. The data forwarding task includes encapsulation, compression or encoding of forwarded data, transmission through the inter-ear link, and reception of forwarding confirmation. The new secondary ear disables the main mode function and reduces power consumption, disabling the main mode RF transmit power amplifier, multi-connection management unit, active scanning and connection initiation unit; Dynamically monitor the changes in the charge level of the new primary and secondary earpieces and record the consumption curve; adaptively optimize decision parameters and prepare for the next switching cycle.
9. A dynamic power optimization allocation method for TWS earphones according to claim 4, characterized in that, The intelligent decision-making process, which integrates multi-dimensional parameters, determines whether the switching conditions are met if the comprehensive score is greater than the preset switching trigger threshold, the relative difference percentage is positive, and the time interval since the last switching is greater than the preset minimum switching interval threshold. If any condition is not met, the switch is deemed unnecessary and the trigger signal is set to trigger invalid. The generated switching trigger determination result includes the trigger signal status, the comprehensive score value, and the values of each dimension parameter.
10. A dynamic power optimization allocation system for TWS earphones, used to perform the steps in the dynamic power optimization allocation method for TWS earphones as described in any one of claims 1-9, characterized in that, include: The voltage acquisition module is used to acquire the real-time voltage signals of the left and right ear batteries. It adopts adaptive sampling frequency configuration and multi-level filtering technology to obtain voltage status data with timestamps. The data synchronization module is used to receive voltage status data with timestamps, and uses bidirectional transmission via inter-ear communication link and timestamp alignment mechanism to obtain a synchronized voltage status dataset containing complete information of the left and right ears. The decision-making module is used to acquire the synchronization voltage state dataset, and adopts a multi-dimensional evaluation index construction and weighted scoring intelligent decision-making method to obtain the switching trigger determination result including the trigger signal state and comprehensive score; The scene recognition module is used to receive the switching trigger determination result and use audio stream feature extraction and scene perception strategy optimization methods to obtain a switching execution strategy that includes execution timing and scene parameters. The switching preparation module is used to start the preparation process according to the switching execution strategy. It adopts a dual-link parallel mechanism and a state data pre-synchronization method to obtain the switching ready signals of the new master ear and the old master ear. The switching execution module is used to receive the switching readiness signals of the new master ear and the old master ear. It adopts a gradual data flow transition control and a dual-link weight dynamic adjustment method to obtain a stable connection and switching completion flag under the new master-slave architecture. The load management module is used to obtain the power consumption status and return it to the voltage monitoring loop based on the stable connection and switching completion flags under the new master-slave architecture, using modular task migration and power redistribution methods.
