Data transmission method and electronic device

By employing a priority queue mechanism in Bluetooth transmission, the transmission queue is divided according to the real-time requirements of the data, and high-priority data is sent first. This solves the problem of untimely command data in concurrent transmission of multiple services, and improves the stability of Bluetooth transmission and user experience.

CN120475520BActive Publication Date: 2026-06-05HONOR DEVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-10-23
Publication Date
2026-06-05

Smart Images

  • Figure CN120475520B_ABST
    Figure CN120475520B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a data sending method and an electronic device. The method is performed by a first electronic device which is in Bluetooth connection with a second electronic device. The method comprises: obtaining first data from a first sending queue; sending the first data to the second electronic device through Bluetooth; obtaining second data from a second sending queue after the first data in the first sending queue is sent; the sending priority of the first data is higher than that of the second data; and sending the second data to the second electronic device through Bluetooth. The method can prevent business from being blocked and improve user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic technology, specifically to a data transmission method and an electronic device. Background Technology

[0002] Bluetooth is an important short-range wireless transmission technology that is widely used in electronic devices. Two electronic devices can transmit command data, as well as file data, via Bluetooth.

[0003] However, during use, it was found that when transmitting concurrent data for multiple services via Bluetooth, the transmission of command data was often delayed, causing service interruptions and affecting the user experience. Summary of the Invention

[0004] This application provides a data transmission method and an electronic device that can transmit high-priority data in a timely manner, prevent service interruptions, and improve user experience.

[0005] In a first aspect, a data transmission method is provided, which is executed by a first electronic device and connected to a second electronic device via Bluetooth. The method includes: retrieving first data from a first transmission queue; transmitting the first data to the second electronic device via Bluetooth; retrieving second data from a second transmission queue after the first data in the first transmission queue has been transmitted; wherein the transmission priority of the first data is higher than the transmission priority of the second data; and transmitting the second data to the second electronic device via Bluetooth.

[0006] The first sending queue is, for example, a high-priority queue in a specific embodiment. The second sending queue is, for example, a low-priority queue in a specific embodiment. Of course, the first or second sending queue can also be a medium-priority queue in a specific embodiment.

[0007] The first data refers to the data currently stored in the first transmission queue, which can be high-priority data in a specific implementation, such as a photo-taking command. The second data refers to the data currently stored in the second transmission queue, which can be low-priority data in a specific implementation, such as motion data.

[0008] The first data has a higher transmission priority than the second data, meaning the first data needs to be transmitted before the second data. A scenario where the first data has a higher transmission priority than the second data is, for example, when the real-time requirements of the first data are higher than those of the second data.

[0009] The data transmission method provided in the first aspect of this application prioritizes data in a first transmission queue over data in a second transmission queue. During transmission, data from the first transmission queue is sent first, and data from the second transmission queue is sent only after the data in the first queue has been sent. This prioritizes the transmission of high-priority data, preventing it from being blocked, such as preventing data with high real-time requirements from being blocked, reducing latency, ensuring timely transmission, preventing service interruptions, improving Bluetooth transmission stability and performance, and enhancing user experience. Furthermore, once the high-priority first data has been sent, the low-priority second data can also be sent promptly, fully utilizing Bluetooth bandwidth, improving bandwidth utilization, and maximizing the transmission efficiency of low-priority data, thus improving user experience.

[0010] In one possible implementation, before retrieving the first data from the first sending queue, the method further includes: a first application generating the first data; the first application adding a first priority flag to the first data according to the type of the first data; and the first application adding the first data to the first sending queue according to the first priority flag.

[0011] In one embodiment, the first data is of one type: file data, streaming media data, and instruction data.

[0012] In another embodiment, the type of the first data may be related to the business type of the first application.

[0013] In this implementation, a priority flag is added to the first data according to its type, which enables data with different sending priority requirements to be added to different sending queues, preventing high-priority data from being blocked, preventing business delays, and improving user experience.

[0014] In one possible implementation, before retrieving the second data from the second sending queue, the method further includes: a second application generating the second data; the second application adding a second priority flag to the second data according to the type of the second data; and the second application adding the second data to the second sending queue according to the second priority flag.

[0015] The classification method for the second data type is similar to that for the first data type, and will not be repeated here.

[0016] In this implementation, a priority flag is added to the second data according to its type, which enables data with different sending priority requirements to be added to different sending queues, preventing high-priority data from being blocked, preventing business delays, and improving user experience.

[0017] In one possible implementation, after the first data in the first transmission queue is transmitted, the second data is retrieved from the second transmission queue, including: after the first data in the first transmission queue is transmitted, the third data is retrieved from the third transmission queue; the transmission priority of the third data is lower than the transmission priority of the first data but higher than the transmission priority of the second data; the third data is transmitted to the second electronic device via Bluetooth; and the second data is retrieved from the second transmission queue after the data in the third transmission queue is transmitted.

[0018] The third sending queue is, for example, the medium-priority queue in a specific implementation.

[0019] This implementation, through three priority-based sending queues, enables more granular data sending according to priority, further preventing higher-priority data from being blocked, preventing business delays, and improving user experience.

[0020] In one possible implementation, the first data is instruction data, the second data is file data, and the third data is streaming media data.

[0021] In this implementation, command data is sent with the highest priority, streaming media data with the second highest priority, and file data is sent last. This sending order meets the user's real-time requirements, prevents command data and streaming media data from being blocked and causing stuttering, and improves the user experience.

[0022] In one possible implementation, the first data is stored in a first transmission queue in the form of multiple first data fragments; retrieving the first data from the first transmission queue includes: determining whether there are first data fragments in the first transmission queue; if there are first data fragments in the first transmission queue, then retrieving one first data fragment from the first transmission queue based on the first-in-first-out principle to obtain the first target data fragment.

[0023] This implementation divides the data into multiple data fragments and sends them in multiple batches according to these fragments. This prevents data packets from becoming too large to send, improving the success rate and accuracy of transmission. Furthermore, this implementation uses a first-in, first-out (FIFO) principle to retrieve data fragments from the sending queue, ensuring the correctness of the data transmission order and improving the reliability and accuracy of data transmission.

[0024] In one possible implementation, sending the first data to the second electronic device via Bluetooth includes: obtaining the current transmission quota; the current transmission quota refers to the transmission quota remaining at the current moment after the initial transmission quota of the current quota period has been consumed, the initial transmission quota of the current quota period represents the total amount of data that the first electronic device expects to send via Bluetooth within the current quota period, and the quota period refers to the period for updating the initial transmission quota; if the current transmission quota is greater than a first value, then sending the first target data fragment to the second electronic device via Bluetooth, and returning to determine whether the first data fragment exists in the first transmission queue; the first value is the product of the size of the first target data fragment and a first percentage, the first percentage being greater than 0 and less than 100%.

[0025] The first target data fragment refers to a data fragment obtained from the first transmission queue based on the first-in-first-out principle; that is, the data fragment at the very beginning of the first transmission queue. The first target data fragment is the data fragment to be transmitted in the current first transmission queue.

[0026] If the current transmission quota is greater than the first value, it means that the current transmission quota is large enough to send the first target data fragment, and sending the first target data fragment will not cause Bluetooth congestion. Alternatively, if the current transmission quota is insufficient to send the first target data fragment, but the difference between the current quota and the first target data fragment is not large (in other words, the first target data fragment is not very large), the first target data fragment can be sent after a short queueing period, without causing serious Bluetooth congestion. Therefore, under the condition that congestion is acceptable, the timely transmission of the high-priority first target data fragment is guaranteed, which is beneficial to improving the user experience.

[0027] In one possible implementation, if the current transmission quota is greater than a first value, the first target data fragment is transmitted to the second electronic device via Bluetooth, including: if the current transmission quota is greater than or equal to the size of the first target data fragment, the first target data fragment is transmitted to the second electronic device via Bluetooth, and the transmission quota for the current quota period is consumed according to the size of the first target data fragment, and the current transmission quota is updated; if the current transmission quota is less than the size of the first target data fragment, it is determined whether the current transmission quota is greater than the first value; if the current transmission quota is greater than the first value, the first target data fragment is transmitted to the second electronic device via Bluetooth, and the transmission quota for the next quota period is overdrawn according to the size of the first data fragment.

[0028] In this implementation, while ensuring the timeliness of the first target data fragment with high priority, the transmission quota is consumed or overdrawn to facilitate accurate management of the transmission quota in the future, thereby achieving reasonable allocation of the transmission quota, further preventing Bluetooth congestion, and improving the user experience.

[0029] In one possible implementation, the method further includes: if the current transmission quota is less than or equal to a first value, then adding the first target data fragment to the head of the first transmission queue and reclaiming the current transmission quota.

[0030] If the current sending quota is less than or equal to the first percentage of the size of the first target data fragment, it means that the current sending quota is significantly different from the size of the first target data fragment (i.e., the high-priority data fragment is large). Even if the quota is used for sending, it may cause data blocking or even overflow, resulting in greater latency and affecting user experience. Therefore, the sending of the first target data fragment is abandoned, the first target data fragment is added back to the first sending queue, and the sending quota is reclaimed.

[0031] In this implementation, when the first target data fragment cannot be sent, the data fragment is added back to the first sending queue and placed at the head of the first sending queue, so that the first target data fragment can be retrieved first from the first sending queue in the next sending, thus ensuring the correctness of the first data transmission order and improving the reliability and accuracy of data transmission.

[0032] In addition, in this implementation, when the transmission quota is small, the transmission of larger data fragments is abandoned to prevent the larger data fragments from blocking or even overflowing the Bluetooth module, thus ensuring the stability and reliability of data transmission.

[0033] Moreover, in this implementation, when there is a large amount of transmission quota remaining, the remaining transmission quota is not reclaimed. Instead, the transmission quota may be reclaimed only when there is a small amount remaining. This prevents the transmission quota from accumulating excessively over the quota cycle, prevents false transmission quotas, improves the accuracy of transmission quota calculation, thereby improving the accuracy of bandwidth allocation and control, and ultimately improving the accuracy of Bluetooth transmission performance.

[0034] In one possible implementation, the first electronic device includes a transmitting unit; determining whether a first data fragment exists in the first transmitting queue includes: after the transmitting unit enters a working state from a sleep state, the transmitting unit determines whether a first data fragment exists in the first transmitting queue; after overdrawing the transmitting quota for the next quota period according to the size of the first data fragment, and after reclaiming the current transmitting quota, the method further includes: the transmitting unit entering a sleep state.

[0035] In this implementation, the transmitting unit enters a sleep state after the transmitting quota for the current quota period is exhausted or has little remaining. When needed, it enters the working state again. This can prevent the transmitting unit from being in the working state continuously, which would cause the power consumption of the first electronic device to be too high, and can extend the standby time of the first electronic device.

[0036] In one possible implementation, the second data is stored in a second sending queue in the form of multiple second data fragments; after the first data in the first sending queue is sent, the second data is retrieved from the second sending queue, including: if the first data fragment does not exist in the first sending queue, then determining whether the second data fragment exists in the second sending queue; if the second data fragment exists in the second sending queue, then retrieving one second data fragment from the second sending queue based on the first-in-first-out principle to obtain the second target data fragment.

[0037] In one possible implementation, sending the second data to the second electronic device via Bluetooth includes: obtaining the current transmission quota; the current transmission quota refers to the transmission quota remaining at the current moment after the initial transmission quota of the current quota period has been consumed, the initial transmission quota of the current quota period represents the total amount of data that the first electronic device is expected to send via Bluetooth within the current quota period, and the quota period refers to the period for updating the initial transmission quota; if the current transmission quota is greater than or equal to the size of the second target data fragment, then the second target data fragment is sent to the second electronic device via Bluetooth, and the transmission quota of the current quota period is consumed according to the size of the second target data fragment, and the current transmission quota is updated, and the process returns to determine whether the first data fragment exists in the first transmission queue.

[0038] In one possible implementation, the method further includes: if the current transmission quota is less than the size of the second target data fragment, then adding the second target data fragment to the head of the second transmission queue and reclaiming the current transmission quota.

[0039] In this implementation, during the lower-priority second data transmission process, if the current transmission quota is less than the size of the second target data fragment, the second target data fragment is not transmitted through quota allocation; instead, the transmission of the second target data fragment is directly canceled, and the quota is reclaimed. This is because low-priority data does not have high real-time requirements. On the one hand, it prevents low-priority data fragments from causing data blockage and affecting the transmission of high and medium-priority data in the next transmission cycle; on the other hand, it also saves transmission quota, which can be used for the next quota cycle to prioritize the transmission of subsequent high and medium-priority data, further ensuring that this data is transmitted in a timely manner, preventing electronic devices from lagging, and improving the user experience.

[0040] In one possible implementation, the first electronic device includes a transmitting unit; after the current transmitting quota is reclaimed, the method further includes: the transmitting unit entering a sleep state.

[0041] In one possible implementation, the method further includes: if there is no second data fragment in the second transmission queue, the transmission unit enters a sleep state.

[0042] In this implementation, the sending unit enters a sleep state after the sending quota for the current quota period is exhausted or has little remaining, or after all data in the sending queue has been sent. This prevents the sending unit from continuously operating, which would lead to excessive power consumption of the first electronic device, and extends the standby time of the first electronic device.

[0043] In one possible implementation, the first electronic device includes a transmitting unit; before determining whether a first data fragment exists in the first transmitting queue, the method further includes: in response to the transmitting unit entering a working state, if the time difference between the current moment and the moment of the last update of the initial transmitting quota is greater than or equal to the duration of the quota period, acquiring a first transmitting rate; the first transmitting rate characterizes the rate at which the first electronic device transmits data via Bluetooth, and the first transmitting rate is determined based on historical data; determining the initial transmitting quota of the current quota period based on the first transmitting rate; if the initial transmitting quota is greater than 0, then determining whether a first data fragment exists in the first transmitting queue; if the initial transmitting quota is less than or equal to 0, then the transmitting unit enters a sleep state.

[0044] In this implementation, after determining the initial transmission quota, it can be checked whether the initial transmission quota is greater than 0. If the initial transmission quota is greater than 0, it means that there are available Bluetooth resources and data can be transmitted, so the data transmission operation is further executed. If the initial transmission quota is less than or equal to 0, no data is transmitted, and the system enters a sleep state. This prevents data congestion and ensures system stability.

[0045] Furthermore, this implementation method can accurately predict the transmission rate using historical data, thereby enabling more accurate and instructive transmission quota estimates. It's understood that overestimating the transmission quota will lead to link congestion, while underestimating it will result in bandwidth waste. Therefore, this implementation method, by accurately estimating the transmission quota, allows for more precise bandwidth allocation and management, preventing link congestion and bandwidth waste, thereby improving service transmission performance and stability.

[0046] In one possible implementation, the longest duration for which the sending unit is in working state is a first preset duration, and the duration of the quota period is equal to n times the first preset duration, where n is an integer greater than 1 and less than 10.

[0047] The longest duration during which the transmitting unit is in working condition is also the duration of the transmitting cycle in the specific implementation. The first preset duration is also the preset duration 2 in the specific implementation.

[0048] In this implementation, a quota period is set as several times the length of the sending cycle. The calculated sending quota is larger than a single sending cycle, preventing the sending quota from being too low, thus preventing low data transmission rates, preventing buffering, improving data transmission performance, and enhancing user experience. Furthermore, the calculated sending quota is not excessively large, ensuring the accuracy of quota estimation, thereby improving bandwidth allocation accuracy and data transmission performance and stability. On the other hand, the sending quota is determined based on the first sending rate, using a quota period that is several times the length of the sending cycle. Even if the estimated sending rate is inaccurate, such as extremely low, the calculated sending quota will not be too low. This ensures that even large amounts of data can be sent, preventing situations where extremely low sending quota estimates lead to data transmission failure, further improving data transmission performance and stability, and enhancing user experience.

[0049] In addition, by setting the quota period duration to an integer multiple of the transmission period duration, a quota update judgment is triggered every time the transmission unit is woken up. This facilitates timely updates to the transmission quota, improves the accuracy of transmission quota management, and eliminates the need for additional processes to trigger quota update judgments or additional wake-ups of the transmission unit. This further saves power consumption and extends the standby time of electronic devices.

[0050] In one possible implementation, determining the initial transmission quota for the current quota period based on the first transmission rate includes: calculating the product of the first transmission rate and the duration of the quota period to obtain the estimated transmission quota; calculating the sum of the estimated transmission quota and the transmission quota recovered in the previous quota period, or calculating the difference between the estimated transmission quota and the transmission quota overdrawn in the previous quota period to obtain the initial transmission quota for the current quota period.

[0051] In this implementation, based on the estimated transmission quota and combined with the quota recovered or overdrawn in the previous quota cycle, bandwidth can be accurately managed and allocated. On the one hand, it can prevent Bluetooth link congestion, thereby reducing latency and increasing transmission rate; on the other hand, it can prevent bandwidth waste.

[0052] In one possible implementation, before obtaining the first transmission rate, the method further includes: during the process of sending the first historical data packet to a third electronic device via Bluetooth, if the size of the first historical data packet is greater than a first threshold, then calculating the first transmission rate based on the transmission time of the first historical data packet, the reception time of the acknowledgment message, the size of the first historical data packet, and the size of the acknowledgment message; the acknowledgment message is a message sent by the third electronic device to confirm receipt of the first historical data packet; if the size of the first historical data packet is less than a second threshold, then calculating the first delay based on the transmission time and reception time, and determining the first transmission rate based on the first delay; the second threshold is less than the first threshold.

[0053] The size of data packets sent by business applications is highly random, and there may be instances where only small data packets are sent for extended periods. Small data packets cannot reflect the true transmission rate of Bluetooth; that is, transmission data measured based on small data packets is inaccurate. Therefore, in this implementation, the size of the data packets is assessed. If a large data packet is present, the transmission rate is measured using that packet; otherwise, smaller data packets are used to measure the data latency. Determining the transmission rate through latency improves the accuracy of transmission rate measurement, thereby improving the accuracy of Bluetooth bandwidth allocation.

[0054] In one possible implementation, the method further includes: if the size of the first historical data packet is greater than a first threshold, then setting a first mark on the first historical data packet; if the size of the first historical data packet is less than a second threshold, then setting a second mark on the first historical data packet; during the process of sending data packets to a third electronic device via Bluetooth, if it is determined that the data packet has a first mark, then recording the sending time, receiving time, size of the first historical data packet, and size of the acknowledgment message; if it is determined that the data packet has a second mark, then recording the sending time and receiving time.

[0055] In this implementation, the data required to calculate the first transmission rate can be recorded quickly, effectively, and selectively through the first and second tags, simplifying the method process and improving the method's operating efficiency.

[0056] In one possible implementation, calculating the first transmission rate based on the transmission time of the first historical data packet, the reception time of the acknowledgment message, the size of the first historical data packet, and the size of the acknowledgment message includes: calculating the sum of the transmission time and the reception time to obtain a second value; calculating the sum of the size of the first historical data packet and the size of the acknowledgment message to obtain a third value; and calculating the quotient of the third value and the second value to obtain a first delay.

[0057] In one possible implementation, the first delay is calculated based on the sending time and the receiving time, including: calculating the sum of the sending time and the receiving time to obtain a second value; and calculating the quotient of the second value and 2 to obtain a first sending rate.

[0058] In one possible implementation, determining the first transmission rate based on the first delay includes: obtaining a first mapping relationship; the first mapping relationship includes a one-to-one correspondence between multiple preset delay ranges and multiple transmission rates, wherein the first preset delay range among the multiple preset delay ranges includes the first delay; and determining the transmission rate corresponding to the first preset delay range based on the first mapping relationship to obtain the first transmission rate.

[0059] In one possible implementation, before obtaining the first mapping relationship, the method further includes: obtaining multiple delays and their corresponding transmission times; obtaining multiple transmission rates and their corresponding transmission times; associating delays and transmission rates with corresponding transmission time differences less than a preset time threshold to obtain an associated data group; determining multiple preset delay ranges based on the delays in the associated data group; clustering the transmission rates corresponding to delays within a second preset delay range to obtain a first rate set; the second preset delay range is any one of the multiple preset delay ranges; and processing the transmission rates in the first rate set to obtain the transmission rate corresponding to the second preset delay range.

[0060] In this implementation, by using multiple delays, multiple transmission rates, and corresponding transmission times, and through analysis and clustering, the delay-rate mapping relationship can be determined simply and accurately, thereby improving the accuracy of transmission rate prediction.

[0061] In one possible implementation, determining the first transmission rate based on the first delay includes: determining the first transmission rate based on the first delay when the time difference between the current time and the time of the last update of the first transmission rate is greater than or equal to the preset update period of the transmission rate.

[0062] In this implementation, the transmission rate is updated based on the first delay only when the time elapsed since the last update of the first transmission rate is greater than or equal to the rate update period. This is because the transmission rate determined by the delay is slightly less accurate than the transmission rate calculated directly based on the transmission time, reception time, data packet size, and acknowledgment message size of larger data packets. Therefore, the directly calculated transmission rate is prioritized, which improves the accuracy of transmission rate estimation, the accuracy of subsequent transmission quota estimation, and ultimately, the accuracy of bandwidth allocation.

[0063] In one possible implementation, the first electronic device further includes a Bluetooth module; obtaining first data from a first transmission queue includes: if it is determined that the Bluetooth module is not in a blocked state, then obtaining the first data from the first transmission queue.

[0064] In one possible implementation, the first electronic device includes a transmitting unit, and the method further includes: if it is determined that the Bluetooth module is in a blocked state, the transmitting unit enters a sleep state.

[0065] In this implementation, the transmitting unit executes the data transmission process when the Bluetooth module is not blocked. When the Bluetooth module is blocked, the transmitting unit directly enters a sleep state and does not send data to the Bluetooth module. This prevents data overflow in the Bluetooth module's buffer queue, ensuring system stability.

[0066] Secondly, this application provides an apparatus included in an electronic device, which has the function of implementing the behaviors of the electronic device in the first aspect and possible implementations thereof. The function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above-described functions. For example, a receiving module or unit, a processing module or unit, etc.

[0067] Thirdly, this application provides an electronic device, which includes a processor, a memory, and an interface; the processor, memory, and interface cooperate with each other to enable the electronic device to execute any one of the methods in the first aspect of the technical solution.

[0068] Optionally, the electronic device can be a wearable device, or a mobile phone, tablet, or other device with a Bluetooth module.

[0069] Fourthly, this application provides a chip system including a processor. The processor is used to read and execute a computer program stored in a memory to perform the methods in the first aspect and any possible implementation thereof.

[0070] Optionally, the chip system may also include memory, which is connected to the processor via circuitry or wires.

[0071] Alternatively, the chip system may also include a communication interface.

[0072] Fifthly, this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform any one of the methods in the first aspect of the technical solution.

[0073] Sixthly, this application provides a computer program product, which includes computer program code that, when executed on an electronic device, causes the electronic device to perform any one of the methods in the first aspect of the technical solution. Attached Figure Description

[0074] Figure 1 This is an application scenario diagram of a data transmission method provided in an embodiment of this application;

[0075] Figure 2 This is an application scenario diagram of another data transmission method provided in the embodiments of this application;

[0076] Figure 3 This is an application scenario diagram of another data transmission method provided in the embodiments of this application;

[0077] Figure 4 This is an application scenario diagram of another data transmission method provided in the embodiments of this application;

[0078] Figure 5 This is an application scenario diagram of another data transmission method provided in the embodiments of this application;

[0079] Figure 6 This is a schematic diagram of a transmission model for multiple services sharing a Bluetooth link in related technologies;

[0080] Figure 7 This is a schematic diagram illustrating the principle of a data transmission method provided in an embodiment of this application;

[0081] Figure 8 This is a schematic diagram of the structure of an example electronic device 100 provided in an embodiment of this application;

[0082] Figure 9 This is a schematic diagram of the structure of an example electronic device 200 provided in an embodiment of this application;

[0083] Figure 10 This is a software structure block diagram of an example electronic device 100 provided in an embodiment of this application;

[0084] Figure 11 This is a software structure block diagram of an example electronic device 200 provided in an embodiment of this application;

[0085] Figure 12 This is a schematic diagram illustrating another application scenario of the data transmission method provided in the embodiments of this application;

[0086] Figure 13 This is a flowchart illustrating an example of a data transmission method provided in an embodiment of this application;

[0087] Figure 14 This is a flowchart illustrating another data transmission method provided in an embodiment of this application;

[0088] Figure 15 This is a flowchart illustrating yet another example of a data transmission method provided in this application embodiment;

[0089] Figure 16 This is a flowchart illustrating yet another example of a data transmission method provided in this application embodiment;

[0090] Figure 17 This is a flowchart illustrating yet another example of a data transmission method provided in this application embodiment;

[0091] Figure 18 This is a flowchart illustrating yet another example of a data transmission method provided in this application embodiment;

[0092] Figure 19 This is a flowchart illustrating yet another example of a data transmission method provided in this application embodiment;

[0093] Figure 20 This is a flowchart illustrating yet another example of a data transmission method provided in this application embodiment;

[0094] Figure 21 This is a flowchart illustrating yet another example of a data transmission method provided in this application embodiment;

[0095] Figure 22 This is a schematic diagram of an example of an associated data group provided in an embodiment of this application;

[0096] Figure 23 This is a schematic diagram illustrating an example of a delay-rate mapping relationship provided in an embodiment of this application. Detailed Implementation

[0097] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.

[0098] Hereinafter, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include one or more of that feature.

[0099] References to "one embodiment" or "some embodiments" as described in this application specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this application specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0100] To better understand the embodiments of this application, the terms or concepts that may be involved in the embodiments are explained below.

[0101] 1. Bluetooth bandwidth

[0102] Bluetooth bandwidth can be considered as the upper limit of the amount of data a Bluetooth device can transmit per unit of time. For example, the theoretical bandwidth of Bluetooth 2.0+EDR is 3Mbps, which means that under ideal conditions, a maximum of 3 megabits of data can be transmitted per second.

[0103] It is worth noting that Bluetooth bandwidth is affected by the air interface environment. The air interface environment refers to the surrounding environmental conditions in which wireless communication devices transmit signals through the air interface. The air interface environment includes, but is not limited to, electromagnetic interference, obstacles, and distance.

[0104] 2. Sending rate

[0105] Transmission rate refers to the speed at which data is sent from one device to another; that is, the actual rate at which a device sends data. The unit of transmission rate can be bits per second (bps), kilobits per second (Kbps), megabits per second (Mbps), etc.

[0106] It's understandable that Bluetooth bandwidth determines the upper limit of the transmission rate; in other words, the maximum transmission rate is the Bluetooth bandwidth.

[0107] 3. Delay

[0108] In the field of communications, latency refers to the time it takes for a data message or packet to travel from the sender to the receiver. Latency can include transmission latency, propagation latency, processing latency, and queuing latency. Transmission latency is the time required for a data block to enter the transmission medium from the node when transmitting data. Propagation latency is the time it takes for an electromagnetic signal or optical signal to travel a certain distance in the transmission medium, i.e., from the time the data is sent at the sender to the time the data is received at the receiver. Latency is equal to the sum of transmission latency, propagation latency, processing latency, and queuing latency.

[0109] 4. Sending queue

[0110] A send queue is a data structure typically used to store data items waiting to be sent. Its main function is to act as a buffer between the sender and receiver, ensuring that data is sent in a certain order and at a certain pace. Data in the send queue follows the first-in-first-out (FIFO) principle, meaning that the data that enters the queue first is the first to be retrieved and processed.

[0111] Bluetooth communication is a common short-range communication method between electronic devices. The stability and performance requirements for Bluetooth communication transmission are becoming increasingly stringent, especially for wearable devices such as smartwatches and fitness trackers. As the ecosystem of interconnected products becomes richer, wearable devices are also joining the trust loop, supporting trusted interconnection with other Android devices, intelligent service transfer, and sharing. Moreover, wearable devices generally only support Bluetooth for short-range near-field communication. Therefore, Bluetooth is used more frequently and in more scenarios on these wearable devices, making the stability and performance of Bluetooth transmission even more crucial.

[0112] The embodiments of this application aim to provide a data transmission method in the Bluetooth communication process, thereby improving the stability and performance of Bluetooth transmission from the perspective of data transmission.

[0113] First, the application scenarios of the data transmission method provided in the embodiments of this application will be described.

[0114] This method can be applied to scenarios where two electronic devices transmit data via Bluetooth. Both electronic devices can be Bluetooth-enabled devices such as mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). This application does not impose any restrictions on the specific type of electronic device.

[0115] For example, Figure 1 This is a schematic diagram illustrating an application scenario of a data transmission method provided in an embodiment of this application. For example... Figure 1 As shown, the following example illustrates the process using two electronic devices: a smartwatch 101 and a mobile phone 102. The smartwatch 101 and mobile phone 102 are connected via Bluetooth, allowing for the transmission of various types of business data to achieve diverse business functions. These business data types can include file data, streaming media data, and command data. File data refers to data primarily stored as files on the device. Streaming media data refers to media data that is continuously played in real-time over a network using streaming technology, such as audio and video streams. Command data consists of commands or signals used to control the device or software to perform specific operations.

[0116] It's understandable that file data is generally large, and the transmission time is relatively long. However, most file data does not require high real-time transmission speed. Taking the transfer of file data from smartwatch 101 to phone 102 as an example, smartwatch 101 can transmit collected exercise data, heart rate data, sleep data, photos or videos, and other file data to phone 102 via Bluetooth. Figure 2 As shown. Of course, the phone 102 can also transfer file data to the smartwatch 101 via Bluetooth. Optionally, file data can be transferred in the background.

[0117] Streaming media data requires a certain degree of continuity and real-time transmission. A scenario for transmitting streaming media data between smartwatch 101 and mobile phone 102 is, for example, when mobile phone 102 is taking a photo, the smartwatch 101 simultaneously displays the photo preview interface of mobile phone 102. In this case, mobile phone 102 needs to transmit video stream data to smartwatch 101 via Bluetooth. Figure 3 As shown. For example, while the smartwatch 101 is playing music, it can transmit the audio stream to the phone 102 via Bluetooth, such as... Figure 4 As shown.

[0118] Command data is generally small and requires high real-time transmission speed. For example, consider a scenario where a smartwatch 101 transmits command data to a mobile phone 102. (See...) Figure 5 While the phone 102 is playing audio or video, the user can control playback via the smartwatch 101. Specifically, the user can input playback control commands on the smartwatch 101, which will then send the commands to the phone 102 via Bluetooth. The phone 102 will then respond to the playback control commands. Playback commands can include, for example, playing the previous track, playing the next track, pausing playback, or adjusting the volume. Figure 5 Let's take the instruction to play the next track as an example. For another example, while the phone 102 is taking a photo, the user can control the photo taking process via the smartwatch 101. Specifically, the user inputs a photo-taking command on the smartwatch 101, which then sends the command to the phone 102 via Bluetooth. The phone 102 responds to the command and takes the photo.

[0119] It's understandable that when two electronic devices transmit data via Bluetooth, there are scenarios involving concurrent data transmission of multiple services. This means that various data services may be sent simultaneously. For example, a watch might be transmitting exercise data to a phone via Bluetooth while simultaneously transmitting playback control commands. Another example is a watch transmitting photos to a phone via Bluetooth while also simultaneously transmitting audio stream data. Due to the limited bandwidth of Bluetooth, in scenarios involving concurrent data transmission of multiple services, the Bluetooth link needs to be shared by all services.

[0120] In related technologies, when multiple services share a Bluetooth link, the transmission resources are competed for fairly by the multiple services. For example, Figure 6 The diagram illustrates a transmission model for a multi-service shared Bluetooth link in related technologies. For example... Figure 6 As shown, continuing with the example of smartwatch 101 and mobile phone 102, smartwatch 101 needs to simultaneously send business data from applications (APPs) A, B, and C to mobile phone 102. Smartwatch 101 can establish a sending queue A for application A, a sending queue B for application B, and a sending queue C for application C. Application A adds its business data to sending queue A, application B adds its business data to sending queue B, and application C adds its business data to sending queue C. Then, the sending thread in smartwatch 101 polls sending queues A, B, and C, and sends the data from each queue to mobile phone 102 via Bluetooth according to the first-in, first-out (FIFO) principle.

[0121] Polling mechanisms ensure that each service has a relatively equal opportunity to send data. However, as analyzed above, data packets have different purposes and different real-time requirements. Sending data according to a polling mechanism can lead to the transmission of a large amount of data with low real-time requirements within a certain period, causing data with high timeliness requirements to be blocked. This can affect some services with high real-time requirements, resulting in lag or unresponsiveness on the user side, thus impacting the user experience.

[0122] by Figure 5 The example shown illustrates a user controlling music playback on a mobile phone 102 via a smartwatch 101. The user inputs a "play next track" command on the smartwatch 101, and the music control application on the smartwatch adds the command data to its corresponding sending queue. Simultaneously, the fitness tracking application on the smartwatch 101 caches exercise data in its corresponding sending queue. The sending thread, based on a polling mechanism, first retrieves the exercise data from the fitness tracking application's sending queue and sends the exercise trajectory data to the mobile phone 102 via Bluetooth. Because the exercise trajectory data is large, the transmission takes a long time, and the "next track" control command data is blocked. After a period of time, once the exercise trajectory data is sent, the sending thread retrieves the "next track" control command data from the control application's sending queue and sends it to the mobile phone 102 via Bluetooth. This results in a significant delay in the transmission of the "next track" control command data to the mobile phone 102, causing a delay in music playback control, resulting in a perceived stuttering experience and impacting the user experience.

[0123] In view of this, embodiments of this application provide a data transmission method that establishes a priority queue mechanism, adding data to a transmission queue with a corresponding priority based on the data's real-time requirements. The higher the real-time requirement, the higher the priority of the transmission queue. When transmitting data, data is retrieved from each transmission queue in descending order of priority, i.e., data with higher real-time requirements is transmitted first. This prevents data with high real-time requirements from being blocked, reduces the latency of this data, ensures timely transmission, prevents service interruptions, improves the stability and performance of Bluetooth transmission, and enhances the user experience. Furthermore, after data with high real-time requirements has been transmitted, data with lower real-time requirements can also be transmitted promptly, fully utilizing Bluetooth bandwidth, improving bandwidth utilization, and maximizing the synchronization efficiency of data such as file data, thereby enhancing the user experience.

[0124] For example, Figure 7 This is a schematic diagram illustrating the principle of a data transmission method provided in an embodiment of this application. Figure 7 As shown, optionally, the electronic device can establish three priority queues: a high-priority queue, a medium-priority queue, and a low-priority queue. When sending service data, each application determines the priority of the service data based on its type (related to real-time requirements) and adds the data to the corresponding sending queue according to priority. The sending thread first sends data from the high-priority queue via Bluetooth, then sends data from the medium-priority queue via Bluetooth, and finally sends data from the low-priority queue via Bluetooth. This prevents data with high real-time requirements in the high-priority and medium-priority queues from being blocked, preventing service interruptions, improving the stability and performance of Bluetooth transmission, and enhancing the user experience.

[0125] It should be noted that the above explanation mainly uses the Bluetooth data transmission between a smartwatch and a mobile phone as an example. In reality, the scenarios of concurrent data transmission of multiple services and the aforementioned technical problems exist between any two Bluetooth-enabled electronic devices. Therefore, the method provided in this application can be applied to any Bluetooth-enabled electronic device.

[0126] The structure of the electronic device provided in the embodiments of this application will be described below.

[0127] For example, Figure 8This is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of this application. The electronic device 100 is, for example, a wearable device such as a smartwatch, fitness tracker, smart wristband, smart glasses, smart headband, or headphones. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, a wireless communication module 150, an audio module 160, a speaker 160A, a microphone 160B, buttons 170, a display screen 171, and a sensor module 180, etc. The sensor module 180 may include an infrared light sensor 180A, a gyroscope sensor 180B, an accelerometer sensor 180C, a touch sensor 180D, a photoplethysmography (PPG) heart rate sensor 180E, an ambient light sensor 180F, etc.

[0128] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0129] Processor 110 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, etc. Different processing units may be independent devices or integrated into one or more processors. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.

[0130] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory.

[0131] Internal memory 121 can be used to store computer executable program code, which includes instructions. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as voice navigation, image playback function, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phone book, etc.). In addition, internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 110 executes various functional applications and data processing of electronic device 100 by running instructions stored in internal memory 121 and / or instructions stored in memory disposed in the processor.

[0132] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0133] Electronic device 100 can provide wireless communication solutions through modules such as antenna 1, wireless communication module 150, modem processor, and baseband processor, including but not limited to wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), and other wireless communication solutions.

[0134] In other words, the wireless communication module 150 is capable of short-range wireless communication, or in other words, the wireless communication module 150 includes a short-range wireless communication module. In this embodiment, the electronic device 100 can use the wireless communication module 150 to conduct short-range wireless communication with a terminal device based on a short-range wireless communication protocol. For example, the wireless communication module 150 can establish a Bluetooth connection with a mobile phone or similar device based on the Bluetooth protocol, and transmit data based on the Bluetooth connection. The wireless communication module 150 may include a Bluetooth module (also called a Bluetooth device). The Bluetooth device can be a classic Bluetooth device, a BLE Bluetooth device, or a dual-mode Bluetooth device; this embodiment does not impose any limitations on these.

[0135] Antenna 1 is used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antennas can be multiplexed as diversity antennas for a wireless local area network. In some other embodiments, antennas can be used in conjunction with tuning switches.

[0136] The wireless communication module 150 may be one or more devices integrating at least one communication processing module. The wireless communication module 150 receives electromagnetic waves via an antenna, performs frequency modulation and filtering of the electromagnetic wave signal, and sends the processed signal to the processor 110. The wireless communication module 150 may also receive signals to be transmitted from the processor 110, perform frequency modulation and amplification on them, and then convert them into electromagnetic waves for radiation via the antenna.

[0137] The 180A infrared light sensor is a sensor that uses infrared light for data processing. It is used to sense certain features of the surrounding environment, measure the heat emitted by the human body, and detect movement.

[0138] The gyroscope sensor 180B can be used to determine the motion attitude of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 about three axes (i.e., the x, y, and z axes) can be determined by the gyroscope sensor 180B. The gyroscope sensor 180B can also be used to detect the user's motion state.

[0139] The accelerometer 180C can detect the magnitude of acceleration of electronic device 100 in various directions (typically three axes). When electronic device 100 is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the posture of electronic device and applied to step counting, motion status feedback, etc.

[0140] Touch sensor 180D is also called a "touch panel". Touch sensor 180D can be disposed on display screen 171, and touch sensor 180D and display screen 171 together form a touch screen, also called a "touchscreen". Touch sensor 180D is used to detect touch operations applied to or near it. Touch sensor 180D can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 171. In other embodiments, touch sensor 180D can also be disposed on the surface of electronic device 100, in a different position than display screen 171, for example, disposed on the side of the dial of a smartwatch.

[0141] The PPG 180E heart rate sensor detects the intensity of reflected light after it has been absorbed by human blood and tissues, recording changes in blood vessel volume during the cardiac cycle to obtain a pulse waveform, from which the heart rate is calculated. The PPG 180E heart rate sensor is used for user health monitoring.

[0142] The ambient light sensor 180F is used to sense the ambient light intensity. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the sensed ambient light intensity. The ambient light sensor 180F can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180F can also be used in conjunction with proximity sensors (not shown in the figure) to detect whether the electronic device 100 is being worn.

[0143] For example, Figure 9This is a schematic diagram of the structure of an electronic device 200 provided in an embodiment of this application. The electronic device 200 is, for example, a mobile phone, a tablet computer, a laptop computer, etc. The electronic device 200 may include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, a headphone jack 270D, a sensor module 280, buttons 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, etc. The sensor module 280 may include a pressure sensor 280A, a gyroscope sensor 280B, a barometric pressure sensor 280C, a magnetic sensor 280D, an accelerometer sensor 280E, a distance sensor 280F, a proximity sensor 280G, a fingerprint sensor 280H, a temperature sensor 280J, a touch sensor 280K, an ambient light sensor 280L, a bone conduction sensor 280M, etc.

[0144] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 200. In other embodiments of this application, the electronic device 200 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0145] Processor 210 may include one or more processing units, such as application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.

[0146] The controller can be the nerve center and command center of the electronic device 200. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.

[0147] The processor 210 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. This memory can store instructions or data that the processor 210 has just used or that are used repeatedly. If the processor 210 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.

[0148] The wireless communication function of electronic device 200 can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor, and baseband processor.

[0149] The wireless communication module 260 can provide solutions for wireless communication applications on the electronic device 200, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 260 can be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 210. The wireless communication module 260 can also receive signals to be transmitted from processor 210, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0150] In other words, the wireless communication module 260 is capable of short-range wireless communication, or in other words, the wireless communication module 260 includes a short-range wireless communication module. In this embodiment, the terminal device 200 can establish a short-range wireless communication connection with the electronic device 100 through the wireless communication module 260, and communicate based on this short-range wireless communication connection. Optionally, the wireless communication module 260 may include a Bluetooth module (also called a Bluetooth device). The Bluetooth module can be a classic Bluetooth device, a BLE Bluetooth device, or a dual-mode Bluetooth device; this embodiment does not impose any limitations on this.

[0151] Electronic devices 100 and 200 run operating systems on top of the aforementioned components. Electronic device 100 may run a lightweight operating system such as Watch OS, HarmonyOS, or RTOS. Electronic device 200 may run an iOS operating system, the Android open-source operating system, or a Windows operating system. The software systems of electronic devices 100 and 200 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. A layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces.

[0152] For example, Figure 10 This is a schematic diagram of the software architecture of an example electronic device 100 provided in an embodiment of this application. For example... Figure 10 As shown, taking electronic device 100 as a wearable device, and running an RTOS operating system on electronic device 100 as an example, the RTOS operating system can be divided into the application layer, system service layer, kernel layer, and driver layer from top to bottom.

[0153] The application layer can include a series of applications, such as camera, gallery, music, camera control, music control, fitness and health, etc., used to implement business functions (also referred to as business applications). Application layer programs can implement specific functions by calling interfaces of the system service layer and kernel layer. It should be noted that the application names provided in this application embodiment are merely examples to illustrate the business functions that the applications can implement, and do not constitute a limitation on the applications. In reality, these applications can be standalone applications or units integrated into other applications or modules; this is not limited.

[0154] Each business application can trigger data transmission to other devices via Bluetooth. For ease of explanation, the other device receiving the transmitted data is referred to as the peer device. Specifically, the business application can acquire or generate session messages. A session message refers to a message generated and transmitted during a Bluetooth communication session. The session message contains the business data to be transmitted. In this embodiment, when generating a session message, the business application can prioritize the business data according to its type. The business data can be transmitted in the form of data packets, hereinafter referred to as data packets.

[0155] like Figure 10As shown in this embodiment, the application layer may further include a data transmission module, a Bluetooth module, and a Wi-Fi module. The data transmission module is used to transmit data from the business application to the corresponding wireless communication module, for example, to the Bluetooth module or the Wi-Fi module.

[0156] For wearable devices, the data transmission module may be, for example, the Magiclink application. Optionally, the data transmission module may include session management, a transmission engine, etc.

[0157] Session management is used to manage and transmit session messages. For example, session management can pass session messages to the sending engine through a sending queue. In this embodiment, session management can also preprocess data packets in the session messages. Preprocessing includes, but is not limited to, setting measurement flags on data packets and fragmenting data packets to obtain data fragments. Measurement flags are used to indicate whether to measure the sending rate or latency based on detected data packets. Session management adds data fragments to the corresponding priority queues according to priority flags.

[0158] The transmission engine retrieves data fragments from various priority queues and sends these fragments to the Bluetooth module. Optionally, the transmission engine can implement its functionality through a transmission thread. Figure 10 As shown in the embodiments of this application, the sending engine may include a wake-up unit, a sending unit, a rate management unit, and a quota management unit.

[0159] The wake-up unit wakes up the transmitting unit, bringing it from sleep mode to working mode. The rate management unit estimates the current transmission rate based on historical data packet transmission rates and latency; this estimate is called the estimated transmission rate or the first transmission rate. The transmitting unit estimates the amount of data Bluetooth can transmit in the current quota period (called the estimated transmission quota) based on the estimated transmission rate provided by the rate management unit. The quota management unit determines the initial transmission quota in each quota period based on the estimated transmission quota, combined with the recovered or overdrawn transmission quota from the previous quota period. Based on the initial transmission quota, it updates and manages the transmission quota according to the size of the data transmitted by the transmitting unit. The transmitting unit also retrieves data fragments sequentially from each priority queue in descending order of priority and determines whether to transmit the data fragments to the Bluetooth module based on the transmission quota.

[0160] The Bluetooth module is used to send data fragments sent by the sending engine to the peer device.

[0161] The system service layer, built on top of the kernel layer, provides higher-level system services to applications. It can include a file system, network protocol stack, graphics library, and database. The file system provides read and write operations on files on storage devices. The network protocol stack enables network communication with other devices. The graphics library provides graphics rendering and user interface display capabilities. The database stores and manages data.

[0162] The kernel layer is the core of an RTOS operating system, responsible for managing system resources and task scheduling. It provides basic services such as task management, interrupt management, memory management, timer management, communication, and synchronization.

[0163] The driver layer sits above the hardware layer of the electronic device 100 and is primarily responsible for driving and controlling the hardware devices. The driver layer software abstracts the operations of the hardware devices into a set of functions or interfaces for upper-layer software to call. The driver layer may include display drivers, Bluetooth drivers, Wi-Fi drivers, audio drivers, sensor drivers, etc.

[0164] It should be noted that the above software architecture and modules are only examples and do not constitute a limitation on the structure of electronic device 100.

[0165] For example, Figure 11 This is a schematic diagram of the software architecture of an example electronic device 200 provided in an embodiment of this application. For example... Figure 11 As shown, electronic device 200 is a mobile phone, tablet computer, etc., and the Android operating system running on electronic device 200 is used as an example for illustration. In some embodiments, the Android system is divided into four layers, from top to bottom: application layer, application framework layer, Android runtime and system library, and kernel layer.

[0166] The application layer can include a series of application packages. For example... Figure 11 As shown, the application package can include applications such as camera, gallery, call, music, and fitness and health.

[0167] like Figure 11 As shown in this embodiment, the application layer may further include a data transmission module, a Bluetooth module, and a Wi-Fi module. For electronic devices such as mobile phones and tablets, the data transmission module may be, for example, a Nearby application.

[0168] The data transmission module may include session management and a sending engine. Session management, the sending engine, and... Figure 10The corresponding modules in the illustrated electronic device 100 have the same function, which will not be repeated here. It should be noted that the identical function of the two modules in electronic devices 100 and 200 mainly refers to their identical implementation logic and the same main effects achieved. However, the architecture, implementation method, and specific code of the two modules may differ. Specifically, the implementation of a module needs to be compatible with the operating system it runs on, and the software can be adjusted according to the hardware structure of the electronic device.

[0169] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0170] like Figure 11 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.

[0171] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.

[0172] Content providers store and retrieve data, making that data accessible to applications. This data can include videos, images, audio, phone calls made and received, browsing history and bookmarks, phone books, and more.

[0173] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.

[0174] The phone manager is used to provide communication functions for electronic devices 200. For example, it manages call status (including connection and disconnection).

[0175] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.

[0176] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.

[0177] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.

[0178] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0179] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0180] The system library can include multiple functional modules. For example, a surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), and a Bluetooth protocol stack.

[0181] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.

[0182] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.

[0183] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0184] A 2D graphics engine is a graphics engine for 2D drawing.

[0185] The kernel layer is the layer between hardware and software. The kernel layer includes at least display drivers, Wi-Fi drivers, Bluetooth drivers, audio drivers, and sensor drivers.

[0186] For ease of understanding, the following embodiments of this application will be described using the following methods: Figures 8 to 11Taking the electronic device with the structure shown as an example, and using... Figure 12 Taking the application scenario shown as an example, the data transmission method provided in this application embodiment will be specifically described. For example... Figure 12 As shown, at a certain moment, the fitness app on smartwatch 101 (also known as the first electronic device) generates a fitness data package in the background. The fitness app needs to synchronize this data package to phone 102 (also known as the second electronic device) via Bluetooth so that phone 102 can update the fitness data (also known as first data, such as steps) of its fitness app or other apps (such as lock screen apps). At this time, the user is taking a photo with phone 102 and controlling the phone 102 to take the photo via the camera control app on smartwatch 101. For example... Figure 12 As shown, when a user taps the camera control 1201 on the smartwatch 101 interface, the smartwatch 101 receives the user's input photo-taking command. The camera control app on the smartwatch 101 generates a photo-taking command data packet and needs to send the photo-taking command data packet to the mobile phone 102 via Bluetooth so that the mobile phone 102 responds to the photo-taking command (also known as the second data) and performs the photo-taking operation.

[0187] based on Figure 12 The application scenarios shown in this application are implemented through... Figure 13 The process shown enables data transmission. In this embodiment, the execution entity of the method is a module in the smartwatch, and the steps below are not described one by one.

[0188] See Figure 13 Data transmission methods may include:

[0189] S101, The Sports and Health APP determines the corresponding priority as low priority based on the type of data in the sports data package.

[0190] It is understood that data priority, also known as data transmission priority, represents the order in which data is sent. In principle, high-priority data is sent first, and low-priority data is sent later. In this embodiment, data priority is related to the real-time requirements. The higher the real-time requirement, the higher the data priority; the lower the real-time requirement, the lower the data priority.

[0191] In one embodiment, data priorities, from highest to lowest, can include three categories: high priority, medium priority, and low priority. It should be noted that this is just one example of priority classification; in practical applications, more or fewer priority categories can be used depending on the requirements. For example, in another embodiment, priorities may only include high priority and low priority.

[0192] Moreover, the above-described method of distinguishing priorities is merely an example. In other embodiments, priorities may also be distinguished in the form of, for example, first priority, second priority, third priority, or priority A, priority B, priority C, etc., and this is not limited.

[0193] Optionally, each business application can pre-configure a mapping table between data types and priorities. When data needs to be sent via Bluetooth, the business application can query the mapping table to obtain the priority corresponding to the data type to be sent. The data type can be determined according to a preset classification method. In one embodiment, data can be divided into file data, command data, and streaming media data as described in the above embodiments. File data has lower real-time requirements and corresponds to low priority; command data has higher real-time requirements and corresponds to high priority; streaming media data has real-time requirements between file data and command data and corresponds to medium priority. In another implementation, data can also be classified based on the corresponding business type, where different business types may have different real-time requirements. For example, data generated by a sports and health app includes types such as exercise synchronization data, trajectory synchronization data, heart rate synchronization data, remote control data, and manually refreshed data. Exercise synchronization data, trajectory synchronization data, and heart rate synchronization data have lower real-time requirements and correspond to low priority, while remote control data and manually refreshed data have higher real-time requirements and correspond to high priority.

[0194] In this embodiment, the data in the motion data packet belongs to file data or motion synchronization data, and therefore has a low priority.

[0195] S102. The Sports and Health App adds a low-priority tag (also known as a second-priority tag) to the data in the sports data package.

[0196] S103, The Sports and Health APP generates Session Message 1, which contains a sports data packet.

[0197] S104, The Sports and Health APP sends session message 1 to the session management in the data transmission module.

[0198] S105. Session management performs fragmentation processing on the motion data packets in session message 1 to obtain multiple data fragments 1 (also known as second data fragments).

[0199] In this embodiment, by fragmenting the data packets, the data in the data packets is divided into multiple data fragments, and the data fragments are sent in multiple times. This can prevent the data packets from being too large to be sent, and improve the success rate and accuracy of the transmission.

[0200] S106. Session management adds each data shard 1 to the low-priority queue in sequence according to the low-priority marker of the data in data shard 1.

[0201] In this embodiment of the application, the priority types of the sending queue correspond to the priority types of the data. The sending queue may include a high-priority sending queue (hereinafter referred to as a high-priority queue), a medium-priority sending queue (hereinafter referred to as a priority queue), and a low-priority sending queue (hereinafter referred to as a low-priority queue). For ease of explanation, the high-priority queue, low-priority queue, and medium-priority queue can be collectively referred to as priority queues below.

[0202] Furthermore, it's understandable that the data fragments obtained from packet fragmentation have a specific order. Adding the data fragments to the priority queue sequentially means adding them in the order they appear. This prevents data fragment disorder from occurring and ensures the accuracy of data transmission.

[0203] S107. The camera control APP determines the corresponding priority as high priority based on the data type in the photo capture command data packet.

[0204] This step is similar to step S101, except that in this step, the photo-taking command data is command data, which has a high real-time requirement, and therefore has a high priority.

[0205] S108. The camera control APP adds a high-priority tag (also known as a first-priority tag) to the data in the photo capture command data packet.

[0206] S109. The camera control APP generates session message 2, which contains a photo-taking instruction data packet.

[0207] S110, the camera control APP sends session message 2 to the session management in the data transmission module.

[0208] S111. Session management processes the photo capture instruction data packet in session message 2 into multiple data fragments 2 (also known as the first data fragment).

[0209] S112. Session management adds each data shard 2 to the high-priority queue in sequence according to the high-priority marker of the data in data shard 2.

[0210] For example, Figure 13 A schematic diagram of a priority queue is shown. For example... Figure 13 As shown, after executing steps S106 and S112, data shard 1 is located in the low-priority queue, and data shard 2 is located in the high-priority queue.

[0211] It should be noted that the motion data packets of the sports and health app and the photo-taking command data packets of the camera control app are generated concurrently. Therefore, the execution order of the above steps S101 to S106 and steps S107 to S112 is not limited. The execution time between the steps may have slight differences, or they may be executed simultaneously.

[0212] S113. The wake-up unit in the transmitting engine sends a wake-up command to the transmitting unit. The wake-up command is used to instruct the transmitting unit to enter the working state from the sleep state.

[0213] Optionally, the transmitting unit can operate periodically and remain in sleep mode the rest of the time to prevent excessive power consumption of the smartwatch due to continuous operation of the transmitting unit, thereby extending the standby time. Specifically, the transmitting unit wakes up once every preset sleep duration 1 to perform a data transmission task. After completing the data transmission task or when the wake-up time exceeds a preset duration 2 (also known as the first preset duration), it enters sleep mode. The specific values ​​of preset duration 1 and preset duration 2 can be set according to requirements. Preset duration 1 and preset duration 2 can be equivalent or unequal. In a specific embodiment, for electronic devices such as wearable devices, preset duration 1 and preset duration 2 can be 20 milliseconds (ms), and for electronic devices such as mobile phones and tablets, preset duration 1 and preset duration 2 can be 6 ms.

[0214] Specifically, when the transmitting unit enters sleep mode, a timer 1 with a preset duration of 1 can be started. When timer 1 reaches its preset duration, the wake-up unit is triggered to send a wake-up command to the transmitting unit. The transmitting unit responds to the wake-up command, enters working mode, and executes relevant tasks. After the tasks are completed, the transmitting unit enters sleep mode again. Optionally, when the wake-up unit wakes up the transmitting unit, a timer 2 with a preset duration of 2 can be started. When timer 2 reaches its preset duration, if the transmitting unit is still in working mode, it enters sleep mode. This further prevents the transmitting unit from working for extended periods, thus extending the standby time of the smartwatch.

[0215] For ease of description, in this embodiment, the time period from the start of timer 2 to the time it reaches its set duration, i.e., the time period from when the transmitting unit enters the working state to when timer 2 reaches its set duration, is called a transmitting cycle. That is, the duration of the transmitting cycle is equal to the preset duration of 2. The transmitting cycle in which the current moment occurs is called the current transmitting cycle. The transmitting cycle preceding the current transmitting cycle is called the previous transmitting cycle.

[0216] Of course, the wake-up unit's function can also be accomplished by other functional modules in the smartwatch, for example, through timer management in the kernel layer, and there are no restrictions on this.

[0217] S114. In response to the wake-up command, the sending unit sequentially retrieves each data fragment 2 from the high-priority queue.

[0218] S115, the transmitting unit sequentially sends each data fragment 2 to the Bluetooth module.

[0219] S116 and the Bluetooth module sequentially send each data fragment 2 to the mobile phone.

[0220] Specifically, the smartwatch's Bluetooth module sequentially sends each data fragment 2 to the phone's Bluetooth module. The phone's Bluetooth module then sends each data fragment 2 to the phone's transmission engine. After receiving all data fragments 2 from the photo-taking command data packet, the phone's transmission engine, through the phone's session management, sends the photo-taking command data packet to the corresponding application, i.e., the camera app. Upon receiving the photo-taking command data packet, the phone's camera app parses the packet to obtain the photo-taking command and executes it to take a picture.

[0221] For the sake of brevity, Figure 12 The relevant processes on the mobile phone side are not shown.

[0222] S117. After data fragment 2 in the high-priority queue has been sent, the sending unit retrieves data fragment (which is empty) from the medium-priority queue.

[0223] S118. The sending unit sequentially retrieves each data fragment 1 from the low-priority queue.

[0224] S119, The transmitting unit sequentially sends each data fragment 1 to the Bluetooth module.

[0225] The S120 and Bluetooth module sequentially send each data fragment 1 to the mobile phone.

[0226] Specifically, the smartwatch's Bluetooth module sequentially sends each data fragment 1 to the phone's Bluetooth module. The phone's Bluetooth module then sends each data fragment 1 to the phone's transmission engine. After receiving all data fragments 1 from the motion data packet, the phone's transmission engine uses the phone's session management to send the motion data packet to the corresponding application, namely the fitness and health app. Upon receiving the motion data packet, the fitness and health app parses it, obtains the motion data, and saves it.

[0227] For the sake of brevity, Figure 12 The relevant processes on the mobile phone side are not shown.

[0228] As shown in steps S114 to S120, the transmitting unit retrieves data fragments from each priority queue in descending order of priority and sends the data fragments to the Bluetooth module sequentially. It should be noted that during each data fragment retrieval from the high-priority queue, if it is determined that the high-priority queue currently has no data, it then retrieves data fragments from the medium-priority queue. If it is determined that the medium-priority queue currently has no data, it then retrieves data fragments from the low-priority queue. This ensures that data currently existing in the higher-priority queue is sent first, i.e., data with higher real-time requirements is sent first.

[0229] The data transmission method provided in this application establishes a priority queue mechanism. Data is prioritized based on its type, and then added to the corresponding priority queue according to its priority. Higher real-time requirements result in higher priority queue placement. When transmitting data, data is retrieved from each priority queue in descending order of priority, meaning data with higher real-time requirements is sent first. This prevents high-real-time data from being blocked, reduces latency, ensures timely transmission, prevents service interruptions, improves Bluetooth transmission stability and performance, and enhances user experience. Furthermore, after high-priority data is transmitted, low-priority data can be transmitted promptly, fully utilizing Bluetooth bandwidth, improving bandwidth utilization, and maximizing synchronization efficiency for data such as file data, further enhancing user experience.

[0230] As one possible implementation, after sending each data fragment from the low-priority queue, the transmitting unit can check whether there are data fragments in the high-priority and medium-priority queues. If there are data fragments in the high-priority and / or medium-priority queues, the data fragments in the high-priority queue and then the medium-priority queue are sent according to the above process before sending the next data fragment from the low-priority queue. Data in the low-priority queue is generally large, and sending all data in the low-priority queue takes a long time. Therefore, this method can prevent the continuous transmission of data in the low-priority queue from consuming too much Bluetooth link resources for an extended period, prevent high-priority and low-priority data from being blocked, prevent stuttering, and improve the user experience.

[0231] The process of sending data fragments will be further explained below, that is, the process of implementing the above steps S114 to S120 will be further explained.

[0232] In this embodiment, considering the limited bandwidth of Bluetooth, sending too much or too large a amount of data at once can easily cause Bluetooth link congestion. Therefore, a transmission quota is used to control the amount of data sent to prevent Bluetooth link congestion. Simultaneously, combined with the transmission quota, bandwidth is rationally allocated to data of different priorities, preventing both Bluetooth link congestion and bandwidth waste, thereby improving service transmission performance and stability. The transmission quota can be understood as the accumulated bandwidth of the Bluetooth link within a certain time period, that is, the amount of data that the Bluetooth link can send within a certain time.

[0233] It is understood that Bluetooth bandwidth is not fixed and is greatly affected by the air interface environment. Therefore, the transmission quota is not a fixed value and needs to be evaluated in conjunction with the impact of the air interface environment. The transmission rate reflects the actual Bluetooth bandwidth situation; therefore, by detecting the transmission rate in real time, the actual Bluetooth bandwidth can be determined. Based on this, in this embodiment, the Bluetooth transmission rate (referred to as the estimated transmission rate or first transmission rate) is estimated for the current and future period by detecting the transmission information of the transmission unit on historical data. Based on the estimated transmission rate, the amount of data that Bluetooth can transmit during the current and future period can be estimated (referred to as the estimated transmission quota). Then, based on the estimated transmission quota, bandwidth is allocated for the data during the current and future period.

[0234] In this embodiment, by analyzing historical transmission data, the Bluetooth transmission rate can be accurately predicted for the current and future periods, thereby enabling a more accurate and instructive transmission quota estimate. It is understood that overestimating the transmission quota can lead to link congestion, while underestimating it can result in bandwidth waste. Therefore, in this embodiment, accurately estimating the transmission quota allows for more precise bandwidth allocation and management, preventing link congestion and bandwidth waste, thereby improving service transmission performance and stability.

[0235] Optionally, a time length can be preset for the current and future period, and the transmission quota can be re-estimated at intervals of this time length. In this embodiment, a period of time of the preset time length is called a quota period, and this preset time length is called the duration of the quota period. The transmission quota estimated in each quota period can be understood as the transmission quota allocated by the electronic device to the transmission unit, which represents the amount of data that the Bluetooth link is expected to transmit within this quota period. For ease of description, the quota period in which the current moment is located is called the current quota period, the quota period before the current quota period and adjacent to the current quota period is called the previous quota period, and the quota period after the current quota period and adjacent to the current quota period is called the next quota period.

[0236] In one embodiment of this application, during the data transmission process, the quota management unit can reduce the transmission quota for the current quota period based on the size of the transmitted data. This process is also called quota consumption. Optionally, when the remaining transmission quota is low, the quota management unit can reclaim the remaining quota for data transmission in the next quota period. This process is called quota reclamation. Alternatively, the quota management unit can pre-draw a portion of the transmission quota for the next quota period to prioritize data transmission. This process is called quota overdraft.

[0237] Based on this, for the current quota period, a total transmission quota available for use in the current quota period can be calculated based on the estimated transmission quota and the transmission quota recovered or overdrawn in the previous quota period. This total transmission quota is also the available Bluetooth resource in the current quota period before any data is transmitted; therefore, in this embodiment, it is referred to as the initial transmission quota for the current quota period. The quota management module updates the initial transmission quota once in each quota period.

[0238] In this embodiment of the application, based on the estimated transmission quota, combined with the operations of consuming quota, reclaiming quota, and transparently distributing quota, bandwidth can be accurately managed and allocated. On the one hand, this can prevent Bluetooth link congestion, thereby reducing latency and increasing transmission rate; on the other hand, it can prevent bandwidth waste.

[0239] A more detailed explanation follows, with reference to the accompanying diagram. It should be noted that... Figure 13 In the illustrated embodiment, steps S114 to S120 are explained using two specific data shards as examples. In this embodiment, in order to demonstrate the universality of the method, data shard 1 and data shard 2 will no longer be used as examples for explanation. Instead, the processing methods corresponding to data shards of various priorities will be explained one by one.

[0240] For ease of understanding, the method in this embodiment is divided into four processes: quota update process, blocking query process, hibernation process, and data transmission process. The quota update process is used to implement timed updates of the transmission quota. The blocking query process is used to determine whether the Bluetooth module is blocked before transmitting data, to prevent data overflow in the Bluetooth module. The data transmission process is used to transmit data from each priority queue. The data transmission process can include: a high-priority transmission process, a medium-priority data transmission process, and a low-priority transmission process. Each of these processes will be described below.

[0241] 1. Quota update process

[0242] For example, Figure 14 A flowchart illustrating another data transmission method provided in this application embodiment is shown below. Figure 14As shown, the process of updating the transmission quota by the transmitting unit in this method may include:

[0243] S201. The sending unit in the sending engine responds to the wake-up command sent by the wake-up unit and determines whether the time elapsed since the last update of the sending quota exceeds the quota period. If yes, then proceed to step S202; if no, then proceed to step S208 and enter the blocking query process.

[0244] In other words, it determines whether the current time has reached the preset quota update time. If the quota update time has been reached, step S202 is executed to update the sending quota; otherwise, the sending quota is not updated, and step S208 is executed to enter the blocking query process.

[0245] Optionally, the duration of the quota period can be equal to or different from the duration of the sending period.

[0246] In one specific embodiment, the duration of the quota period can be equal to several times (integer multiples greater than 1 and less than 10) the duration of the transmission period (i.e., the preset duration 2), for example, 5 times or 6 times. Taking a transmission period of 20ms as an example, the duration of the quota period can be 100ms or 120ms. It can be understood that the longer the duration of the quota period is set, the larger the calculated transmission quota will be, and the data transmission rate may be higher based on the bandwidth allocation of the transmission quota. However, the Bluetooth transmission rate is constantly changing, so if the quota period is too large, the estimation of the quota will be less accurate. Therefore, in this embodiment, several times the duration of the transmission period is used as the quota period. The calculated transmission quota is larger than that of 1 times the duration of the transmission period, which can prevent the transmission quota from being too low, thereby preventing the data transmission rate from being too low, preventing lag, improving data transmission performance, and improving user experience; moreover, the calculated transmission quota will not be too large, which can ensure the accuracy of quota estimation, thereby improving the accuracy of bandwidth allocation, improving data transmission performance and stability. On the other hand, the sending quota is determined based on the estimated sending rate, and the quota period is several times the sending period. Even if the estimated sending rate is inaccurate, such as extremely low, the calculated sending quota will not be too low. This ensures that large amounts of data can be sent and prevents the situation where data cannot be sent due to an extremely low estimated sending quota. This improves data transmission performance and stability and enhances user experience.

[0247] In addition, by setting the quota period duration to an integer multiple of the transmission period duration, a quota update judgment is triggered every time the transmission unit is woken up. This facilitates timely updates to the transmission quota, improves the accuracy of transmission quota management, and eliminates the need for additional processes to trigger quota update judgments or additional wake-ups of the transmission unit. This further saves power consumption and extends the standby time of electronic devices.

[0248] S202, The transmitting unit obtains the estimated transmitting rate from the rate management unit.

[0249] The rate management unit can calculate the transmission rate and / or latency based on information from historical data packets, and determine the estimated transmission rate based on the transmission rate and / or latency. Historical data refers to data packets transmitted by the Bluetooth module via Bluetooth during a historical time period. It is understood that the transmitted data packets change over time, and the calculated estimated transmission rate may also change; therefore, the rate management unit can continuously update the estimated transmission rate. The process of the rate management unit calculating and updating the estimated transmission rate will be further explained in subsequent embodiments.

[0250] S203. The transmitting unit calculates the estimated transmitting quota for the current quota period based on the estimated transmitting rate and quota period.

[0251] The estimated transmission quota represents the amount of data that the Bluetooth module can transmit continuously for one quota cycle at the estimated transmission rate.

[0252] Optionally, the sending unit can calculate the product of the estimated sending rate and the quota period to obtain the estimated sending quota for the current quota period.

[0253] S204. The sending unit sends the estimated sending quota for the current quota period to the quota management unit.

[0254] S205. The quota management unit determines the initial sending quota for the current quota period based on the estimated sending quota for the current quota period and the sending quota recovered or overdrawn in the previous quota period.

[0255] Specifically, if quota was reclaimed in the previous quota period, the estimated sending quota for the current quota period can be calculated by adding the sending quota reclaimed in the previous quota period to obtain the initial sending quota for the current quota period; if quota was overdrawn in the previous quota period, the estimated sending quota for the current quota period can be calculated by adding the sending quota overdrawn in the previous quota period to obtain the initial sending quota for the current quota period.

[0256] S206. The quota management unit sends the initial sending quota for the current quota period to the sending unit.

[0257] As mentioned above, the initial sending quota represents the available sending quota before any data is sent in the current quota period.

[0258] S207. The sending unit determines whether the initial sending quota is greater than 0; if yes, then execute step S208 and enter the blocking query process; if no, then execute S210 and enter the sleep process.

[0259] It is understandable that if the estimated transmission rate determined based on historical transmission data is 0, and there was no quota recovery or quota overdraft in the previous quota period, the calculated initial transmission quota for the current quota period may be 0 or negative. Furthermore, if the estimated transmission rate determined based on historical transmission data is very low, and there was quota overdraft in the previous quota period, the calculated initial transmission quota for the current quota period may also be 0 or negative. This situation is particularly common for thin systems such as wearable devices, which have limited bandwidth. In such cases, the lack of available Bluetooth resources can lead to data congestion, affecting Bluetooth transmission performance and user experience. Therefore, in this step, after determining the initial transmission quota, it is checked whether the initial transmission quota is greater than 0. If the initial transmission quota is greater than 0, it indicates that there are currently available Bluetooth resources, and data can be transmitted. Step S208 and subsequent steps are then executed to check for congestion and transmit data. If the initial transmission quota is less than or equal to 0, step S210 is executed, and the transmitting unit does not transmit data and enters a sleep state. This prevents data blockage and ensures system stability.

[0260] 2. Blocking the query process

[0261] See also Figure 14 In one embodiment, blocking the query process may include:

[0262] S208, The transmitting unit queries the Bluetooth module for blocking information.

[0263] Specifically, the transmitting unit can send a blocking query request to the Bluetooth module. The Bluetooth module responds to the blocking query request by determining whether there is data currently queued for transmission in its buffer queue. If yes, it indicates that the Bluetooth module is currently blocked; otherwise, it indicates that the Bluetooth module is not blocked. The Bluetooth module then sends the query result to the transmitting unit.

[0264] S209. The sending unit determines whether the query result indicates that the Bluetooth module is blocked; if yes, it executes step S210 to enter the sleep process; if no, it executes step S301 to enter the data sending process.

[0265] A blocked Bluetooth module indicates that there is data in the Bluetooth module's buffer queue. If more data is sent, a data overflow may occur, leading to service interruption, system performance degradation, etc.

[0266] Therefore, in this embodiment, the transmitting unit executes the data transmission process when the Bluetooth module is not blocked. When the Bluetooth module is blocked, step S210 is executed, and the transmitting unit directly enters a sleep state, not transmitting data to the Bluetooth module. This prevents data overflow in the Bluetooth module's buffer queue, ensuring system stability.

[0267] 3. Hibernation Process

[0268] See also Figure 14 In one embodiment, the hibernation process may include:

[0269] S210. The transmitting unit enters sleep mode and starts timer 1.

[0270] When the transmitting unit enters sleep mode, the current task flow of the transmitting engine ends. When timer 1 reaches its set duration, the wake-up unit executes step S113 again, sending a wake-up command to the transmitting unit to enter the next transmitting cycle. This process repeats continuously.

[0271] 4. Data transmission process

[0272] For example, Figure 15 This is a flowchart illustrating another example of a data transmission method provided in an embodiment of this application, as shown below. Figure 15 As shown, the data transmission process may include:

[0273] 1) High-priority data transmission process

[0274] S301. The sending unit determines whether there is a data fragment (called a high-priority data fragment) in the high-priority queue; if yes, then execute step S302; if no, then execute step S401 and enter the medium-priority data sending process.

[0275] It is understandable that when a sending unit retrieves data from a priority queue, that priority queue may or may not contain data. The absence of data could be due to the queue not having been updated or the updated data having been temporarily sent. In this embodiment, before retrieving a data fragment from a priority queue, it can be determined whether a data fragment exists in that queue. For high-priority or medium-priority queues, if no data exists, the next priority data transmission process begins. If a data fragment exists, it is retrieved from the priority queue according to a first-in, first-out (FIFO) principle, and the transmission operation is performed. The process continues until all data fragments have been sent, meaning no data fragments remain in the priority queue. For low-priority queues, if no data exists, a sleep process is initiated.

[0276] Specifically, in step S301, the sending unit determines whether there are data fragments in the high-priority queue. If there are data fragments in the high-priority queue, then the following steps S302 and subsequent steps are executed to send the data fragments in the high-priority queue; if there are no data fragments in the high-priority queue, then step S401 is executed to enter the medium-priority data sending process (see...). Figure 16 ).

[0277] S302. The sending unit obtains a high-priority data fragment from the high-priority queue based on the first-in-first-out principle.

[0278] S303, The sending unit obtains the current sending quota from the quota management unit.

[0279] Specifically, the quota management unit consumes quotas and continuously updates the transmission quota as the transmitting unit sends various data fragments. For ease of description, the transmission quota at the current moment is referred to as the current transmission quota. In essence, the current transmission quota can be understood as the remaining transmission quota after the initial transmission quota of the current quota period has been consumed. The current transmission quota represents the amount of data that the Bluetooth module is expected to transmit from the current moment until the end of the current quota period.

[0280] It should be understood that after the initial sending quota is calculated, before sending the first data fragment of the current quota period, the current sending quota is equal to the initial sending quota; after sending the last data fragment of the current quota period, the current sending quota is equal to the reclaimed sending quota or the overdrawn sending quota.

[0281] S304. The sending unit determines whether the current sending quota is greater than or equal to the size of the high-priority data fragment; if yes, it executes steps S305 to S307 to send the high-priority data fragment and consume the quota; if no, it executes steps S308 to S314 to further determine whether to send the high-priority data fragment.

[0282] If the current sending quota is greater than or equal to the size of the high-priority data fragment, it means that the current sending quota is sufficient to send the high-priority data fragment. Therefore, steps S305 to S307 can be executed to directly send the high-priority data fragment and consume the quota. If the current sending quota is less than the size of the high-priority data fragment, it means that the current sending quota is insufficient to send the high-priority data fragment. Then, steps S308 to S314 are executed to further combine the relationship between the size of the data fragment and the size of the current sending quota to decide whether to send the data fragment through the quota or to enter a dormant state and wait for the sending quota to be updated in the next sending cycle before sending the data fragment.

[0283] S305, The transmitting unit sends high-priority data fragments to the Bluetooth module.

[0284] After receiving a high-priority data fragment, the Bluetooth module sends that high-priority data fragment to the peer device; this will not be elaborated further. For simplicity, Figure 15 Not shown in the image.

[0285] S306, The sending unit notifies the quota management unit to consume the sending quota.

[0286] Specifically, the sending unit can send a quota consumption message to the quota management unit. This message indicates the quota to be consumed. The quota consumption message can carry the size of the quota to be consumed, which is the size of the data fragment currently being sent. In the current step, the quota consumption message carries the size of the high-priority data fragment.

[0287] S307. In response to the notification from the sending unit, the quota management unit consumes the sending quota and updates the current sending quota, and then returns to the execution step S301.

[0288] Specifically, this involves consuming the transmission quota, which means reducing the transmission quota value. The quota management unit can calculate the difference between the current transmission quota and the size of the data fragment to be transmitted, obtaining the transmission quota after consumption. The current transmission quota is then updated to the consumed transmission quota. In other words:

[0289] Updated sending quota = Previous sending quota - Size of data fragments to be sent.

[0290] It should be noted that after step S307, the process returns to step S301. This process is repeated to ensure that data fragments in the high-priority queue are sent sequentially until there are no more data fragments in the high-priority queue (i.e., the result of step S301 is negative), or until the sending quota is insufficient to send high-priority data fragments (i.e., the result of step S304 is negative).

[0291] S308. The sending unit determines whether the current sending quota is greater than n1% of the size of the high-priority data fragment; if yes, it executes steps S309 to S311 and S210 to send the high-priority data fragment and overdraft the sending quota, and then enters the sleep process; if no, it executes steps S312 to S314 and S210 to cancel the sending of the high-priority data fragment and reclaim the sending quota, and then enters the sleep process.

[0292] n1 is greater than or equal to 0 and less than 100. For example, n1 can be 30, 50, or 70, etc. n1% is also called the first percentage, and n1% of the size of the high-priority data shard is also called the first value.

[0293] In other words, when the current transmission quota is insufficient to send the high-priority data fragment, the size difference between the current transmission quota and the high-priority data fragment can be further determined. If the current transmission quota is greater than n1% of the size of the high-priority data fragment, it indicates that the size difference between the current transmission quota and the high-priority data fragment is small (i.e., the high-priority data fragment is not very large). Then, steps S309 to S311 can be executed to send the high-priority data fragment through quota control. Afterwards, step S210 is executed to put the transmission unit into a sleep state. Sending the data fragment through quota control can be understood as first sending the data fragment to the Bluetooth module, which may need to queue for a certain period before sending it. In this embodiment, high-priority data has high real-time requirements. When the high-priority data fragment is not very large, sending it to the Bluetooth module through quota control may allow it to be sent after a short queue, without causing serious congestion. Therefore, under acceptable congestion conditions, timely data transmission is guaranteed, which is beneficial to improving the user experience.

[0294] If the current transmission quota is less than or equal to n1% of the size of the high-priority data fragment, it indicates a significant difference between the current transmission quota and the size of the high-priority data fragment (i.e., the high-priority data fragment is large). Even if the high-priority data fragment is transmitted through the quota, it may cause data blocking or even overflow, resulting in greater latency and affecting user experience. Therefore, the transmission of the high-priority data fragment is abandoned, and steps S312 to S314 are executed to add the high-priority data fragment back to the high-priority queue and reclaim the transmission quota. Then, step S210 is executed to put the transmission unit into a sleep state. The data fragment will be transmitted again after the transmission quota is updated in the next transmission cycle. In other words, when the transmission quota is small, the transmission of larger data fragments is abandoned to prevent the larger data fragments from blocking or overflowing the Bluetooth module, thus ensuring the stability and reliability of data transmission.

[0295] S309, The transmitting unit sends high-priority data fragments to the Bluetooth module.

[0296] After receiving a high-priority data fragment, the Bluetooth module sends that high-priority data fragment to the peer device; this will not be elaborated further. For simplicity, Figure 15 Not shown in the image.

[0297] S310, The sending unit notifies the quota management unit of overdraft sending quota.

[0298] Optionally, the sending unit can send a quota overdraft message to the quota management unit. This message indicates the amount of quota to be overdrafted. The quota overdraft message can carry the size of the quota to be overdrafted, which is also the size of the data fragment currently being sent. Specifically, in this current step, the overdraft consumption message carries the size of the high-priority data fragment.

[0299] S311. In response to the notification from the sending unit, the quota management unit overdrafts the sending quota according to the size of the high-priority data fragment.

[0300] Specifically, the quota management unit can calculate the difference between the size of the data fragment to be sent and the current sending quota, and use this difference as the quota overdrawn in the current quota period. The quota management unit records this overdrawn quota. In the next quota period, the initial quota period can be calculated based on this overdrawn quota.

[0301] S312, The sending unit adds the high-priority data fragment to the first position of the high-priority queue.

[0302] It is understandable that the sending unit retrieves data fragments from each priority queue according to the first-in-first-out principle. Therefore, when a data fragment is canceled from transmission, it is added back to the priority queue and placed at the head of the priority queue so that it can be retrieved first from the priority queue in the next transmission. This ensures the correct transmission order of data packets and improves the reliability and accuracy of data transmission.

[0303] S313, The sending unit notifies the quota management unit to reclaim the sending quota.

[0304] Optionally, the sending unit may send a quota reclamation message to the quota management unit, which is used to indicate the reclamation of quotas.

[0305] S314. The quota management unit responds to the notification from the sending unit and reclaims the sending quota.

[0306] It can be understood that reclaiming transmission quota means reclaiming the remaining quota for the current quota period at the current moment, that is, reclaiming the current transmission quota. Specifically, the quota management unit can use the current transmission quota as the value of the quota to be reclaimed in the current quota period and record the value of the reclaimed quota.

[0307] 2) Data transmission process for medium-priority queues

[0308] For example, Figure 16 This is a flowchart illustrating another example of a data transmission method provided in an embodiment of this application, as shown below. Figure 16 As shown, the medium-priority queue sending process may include:

[0309] S401. The sending unit determines whether there is a data fragment (called a medium-priority data fragment) in the medium-priority queue; if yes, then execute step S402; if no, then execute step S501 and enter the high-priority data sending process.

[0310] In other words, the sending unit determines whether there are data fragments in the medium-priority queue. If there are data fragments in the medium-priority queue, it executes step S402 and subsequent steps to send the data fragments in the medium-priority queue; if there are no data fragments in the medium-priority queue, it executes step S501 to enter the low-priority data sending process (see...). Figure 17 ).

[0311] S402. The sending unit obtains a medium-priority data fragment from the medium-priority queue based on the first-in-first-out principle.

[0312] S403. The sending unit obtains the current sending quota from the quota management unit.

[0313] S404. The sending unit determines whether the current sending quota is greater than or equal to the size of the medium-priority data fragment; if yes, it executes steps S405 to S407 to send the medium-priority data fragment and consume the quota; if no, it executes steps S408 to S414 to further determine whether to send the medium-priority data fragment.

[0314] S405, The transmitting unit sends the high-priority data fragments to the Bluetooth module.

[0315] S406, The sending unit notifies the quota management unit to consume the sending quota.

[0316] S407. In response to the notification from the sending unit, the quota management unit consumes the sending quota and updates the current sending quota, and then returns to the execution step S401.

[0317] After step S407, return to step S401. Repeat this process to send each data fragment in the medium priority queue until there are no more data fragments in the medium priority queue (i.e., the result of step S401 is negative), or the sending quota is consumed to the point that there are not enough data fragments to send medium priority data fragments (i.e., the result of step S404 is negative).

[0318] S408. The sending unit determines whether the current sending quota is greater than n2% of the size of the medium-priority data fragment; if yes, it executes steps S409 to S411 and S210 to send the medium-priority data fragment and overdraft the sending quota, and then enters the sleep process; if no, it executes steps S412 to S414 and S210 to cancel the sending of the medium-priority data fragment and reclaim the sending quota, and then enters the sleep process.

[0319] n2 is greater than or equal to 0 and less than 100. For example, n2 can be 30, 50, or 70, etc. Optionally, n2 can be equal to or unequal to n1. In one embodiment, n2 can be greater than n1. That is, the threshold for sending high-priority data fragments through the quota is higher than that for high-priority data. This prioritizes the sending of high-priority data fragments, while when sending medium-priority data fragments, it considers both real-time transmission and preventing excessive overdraft of the next quota cycle's transmission quota, thus preventing impact on the sending of high-priority data fragments in the next quota cycle, preventing lag, and improving user experience.

[0320] S409, The transmitting unit sends the high-priority data fragments to the Bluetooth module.

[0321] S410, The sending unit notifies the quota management unit of overdraft sending quota.

[0322] S411. In response to the notification from the sending unit, the quota management unit overdrafts the sending quota according to the size of the medium-priority data fragment.

[0323] S412, The sending unit adds the medium-priority data fragment to the first position of the medium-priority queue.

[0324] S413, The sending unit notifies the quota management unit to reclaim the sending quota.

[0325] S414. The quota management unit responds to the notification from the sending unit by reclaiming the sending quota.

[0326] The logic of the medium-priority data transmission process is similar to that of the high-priority data transmission process; for details, please refer to [link / reference]. Figure 15 The descriptions in the illustrated embodiments will not be repeated.

[0327] 3) Low-priority data transmission process

[0328] For example, Figure 17 This is a flowchart illustrating another example of a data transmission method provided in an embodiment of this application, as shown below. Figure 17 As shown, the low-priority queue sending process may include:

[0329] S501. The sending unit determines whether there is a data fragment (referred to as a low-priority data fragment) in the low-priority queue; if yes, then execute step S502; if no, then execute step S210 and enter the sleep process.

[0330] In other words, the sending unit determines whether there is a data fragment in the low-priority queue. If there is a data fragment in the low-priority queue, it executes step S402 and the following steps to send the data fragment in the low-priority queue. If there is no data fragment in the low-priority queue, it executes step S210 to end the current sending task and put the sending unit into a sleep state.

[0331] S502. The sending unit obtains a low-priority data fragment from the low-priority queue based on the first-in-first-out principle.

[0332] S503, The sending unit obtains the current sending quota from the quota management unit.

[0333] S504. The sending unit determines whether the current sending quota is greater than or equal to the size of the low-priority data fragment. If yes, it executes steps S505 to S507 to send the low-priority data fragment and consume the quota. If no, it executes steps S508 to S510 and S210 to cancel the sending of the low-priority data fragment and reclaim the sending quota, and then enters the sleep process.

[0334] S505, the transmitting unit sends low-priority data fragments to the Bluetooth module.

[0335] S506, The sending unit notifies the quota management unit to consume the sending quota.

[0336] S507. In response to the notification from the sending unit, the quota management unit consumes the sending quota and updates the current sending quota, and then returns to the execution step S301.

[0337] As mentioned above, high-priority data packets are generally larger, resulting in a larger number of low-priority data fragments after fragmentation. If all data fragments stored in the low-priority queue are sent consecutively, it may take a long time. During this sending process, the application may generate new high-priority and / or medium-priority data, which will be blocked while waiting for the low-priority data to be sent, causing electronic devices to lag.

[0338] Based on this consideration, in this embodiment, after each low-priority data fragment is sent, the high-priority data sending process and the medium-priority data sending process are executed once to check whether there are any newly added data fragments in the high-priority queue and the medium-priority queue. If so, the data fragments in the high-priority queue and the low-priority queue are sent according to the above process. After sending the data fragments in these two priority queues, the low-priority data sending process is entered again according to the logic (i.e., step S501 is executed again) to send the next low-priority data fragment. If not, the process will also enter the low-priority data sending process again according to the above logic (i.e., step S501 is executed again) to send the next low-priority data fragment. This can further ensure that high-priority data and low-priority data are sent in a timely manner, prevent electronic devices from lagging, and improve user experience.

[0339] S508, The sending unit adds low-priority data fragments to the first position of the low-priority queue.

[0340] S509, The sending unit notifies the quota management unit to reclaim the sending quota.

[0341] S510, the quota management unit responds to the notification from the sending unit, reclaims the sending quota, and then executes step S210.

[0342] Additionally, it's worth noting that in the low-priority data transmission process, if the current transmission quota is less than the size of a low-priority data fragment, the transmission of that fragment can be canceled directly instead of using quota-based transmission. The quota is then reclaimed, and the system enters a dormant state. This is because low-priority data doesn't have high real-time requirements. On one hand, it prevents low-priority data fragments from causing data congestion and affecting the transmission of high and medium-priority data in the next transmission cycle. On the other hand, it conserves transmission quota, allowing it to be used in the next quota cycle to prioritize the transmission of subsequent high and medium-priority data, further ensuring timely transmission, preventing electronic device lag, and improving user experience.

[0343] Furthermore, as can be seen from the above process, the remaining transmission quota is only reclaimed when the current transmission quota is insufficient to send data fragments (the judgment results of steps S308 and S408 are negative), that is, when the remaining transmission quota is small. When the current transmission quota is sufficient to send data fragments (the judgment results of steps S308 and S408 are positive), that is, when the remaining transmission quota is large, after the data fragments are sent, the original priority data transmission process is returned (returning to execute steps S301 and S401). After judgment, if there are no data fragments in any priority queue, it directly enters a sleep state, and the remaining transmission quota is not reclaimed. This is because if the transmission quota is reclaimed when there is a large remaining quota, the transmission quota of each quota period will gradually accumulate, resulting in an excessively high transmission quota that exceeds the actual transmission quota corresponding to the Bluetooth bandwidth. This is a false transmission quota, which will lead to inaccurate bandwidth allocation results and inaccurate transmission rate control, thus causing unstable Bluetooth transmission performance. In other words, in this embodiment of the application, the transmission quota may be reclaimed only when the remaining transmission quota is low. This can prevent the transmission quota from accumulating too high as the quota period continues, prevent false transmission quotas, improve the accuracy of transmission quota calculation, thereby improving the accuracy of bandwidth allocation and control, and thus improving the accuracy of Bluetooth transmission performance.

[0344] The process for determining the estimated transmission rate is explained below.

[0345] As described in the above embodiments, the Bluetooth transmission rate is greatly affected by the air interface environment, and a fixed transmission rate value cannot be used to estimate the current transmission rate. Therefore, in this embodiment, the current transmission rate is estimated by measuring the transmission rate of historical data. Furthermore, considering the limited Bluetooth bandwidth, measuring the transmission rate using additional test data would consume additional air interface resources. Therefore, using historical data transmitted by the service application to measure the transmission rate does not consume additional Bluetooth air interface resources and bandwidth, thus saving resources.

[0346] Furthermore, the inventors discovered that the size of data packets sent by business applications is highly random, and there may be instances where only small data packets are sent for extended periods. Small data packets cannot reflect the true transmission rate of Bluetooth; that is, transmission data measured based on small data packets is inaccurate. Therefore, in this embodiment, the size of the data packets is determined. If the data packet is large, the rate is measured using that data packet; if no large data packet exists, the latency is measured using smaller data packets. Determining the transmission rate through latency improves the accuracy of transmission rate measurement, thereby improving the accuracy of Bluetooth bandwidth allocation.

[0347] The following explanation is provided in conjunction with the accompanying drawings.

[0348] For example, Figures 18 to 20 This is a flowchart illustrating yet another example of a data transmission method provided in an embodiment of this application. For example... Figures 18 to 20 As shown, taking the example of any service application A in electronic device A (also called the first electronic device) sending any data packet A (also called the first historical data packet) to electronic device B (also called the third electronic device), the process of determining the estimated transmission rate may include the following steps. It should be noted that some steps in the following steps are the same as those in the above embodiments. In the following description, these identical steps will not be explained in detail, but can be referred to the above embodiments.

[0349] S601. Business application A in electronic device A determines the corresponding priority based on the type of data in data packet A.

[0350] S602. Business application A in electronic device A adds a priority marker to the data in data packet A.

[0351] S603. Business application A in electronic device A generates session message A, which contains data packet A.

[0352] S604. Business application A in electronic device A sends session message A to session management in data transmission module.

[0353] S605, Session management in electronic device A sets the size of data packet A to D. send Send to the rate management unit.

[0354] S606. In electronic device A, the session management sets a measurement marker for data packet A based on the size of data packet A.

[0355] Measurement markers are used to indicate whether the transmission rate or delay of data packets is measured. Optionally, measurement markers may include a rate measurement marker (also called a first marker), a delay measurement marker (also called a second marker), and an empty marker. The rate measurement marker indicates that the transmission rate of data packets is measured. The delay measurement marker indicates that the delay of data packets is measured. The empty marker indicates that neither the transmission rate nor the delay of the measured data packets is measured. Of course, in some other embodiments, measurement markers may not be set for data packets for which neither the transmission rate nor the delay is measured; this is not a limitation.

[0356] Specifically, session management can pre-store a first threshold and a second threshold, where the first threshold is greater than the second threshold. If the size of a data packet is greater than the first threshold, a rate measurement flag is added to the data packet; if the size of the data packet is less than the second threshold, a delay measurement flag is added to the data packet. In a specific embodiment, the first threshold can be 16kB, and the second threshold can be 980B.

[0357] S607. The session management in electronic device A performs fragmentation processing on data packet A to obtain multiple data fragments A, wherein the first data fragment A1 among the multiple data fragments A has a measurement tag.

[0358] As one possible implementation, the order of steps S606 can also be reversed compared to steps S607; that is, fragmentation processing is performed first, and then a measurement tag is added to the first data fragment. There is no specific limitation on this. In other words, session management can first add a measurement tag to data packet A based on its size, then fragment data packet A, and continue marking the measurement tag onto the first data fragment A1 obtained after fragmentation. Alternatively, session management can first determine the size of data packet A, then fragment the data packet, and set a measurement tag on the first data fragment A1 after fragmentation based on the size of data packet A.

[0359] It can be understood that the first data fragment A1 refers to the data fragment that is sent first after data packet A has been fragmented. It should also be understood that the sending time of the first data fragment A1 is the same as the sending time of data packet A.

[0360] S608. The session management in electronic device A adds each data segment A to its corresponding priority queue A in sequence according to the priority marker of the data in data segment A.

[0361] Priority queue A can be a high-priority queue, a medium-priority queue, or a low-priority queue.

[0362] S609, The wake-up unit in the transmitting engine of electronic device A sends a wake-up command to the transmitting unit.

[0363] S610, the transmitting unit in electronic device A responds to the wake-up command and sequentially retrieves data fragments from each priority queue in descending order of priority, wherein data fragment A is retrieved from priority queue A.

[0364] S611. When the transmitting unit in electronic device A transmits the first data fragment A1 in data packet A, it determines the measurement mark of data fragment A1; if the measurement mark is an empty mark, then steps S612 and S613 are executed (see...). Figure 18 If the measurement mark is a speed measuring mark, then execute steps S612 to S618 (see...). Figure 19 If the measurement marker is a time delay marker, then execute steps S612 to S614, S619 to S624 (see...). Figure 20 ).

[0365] S612, the transmitting unit in electronic device A sequentially transmits data fragment A1 and other data fragments A to the Bluetooth module, and manages the transmission quota.

[0366] S613, The Bluetooth module in electronic device A sends data fragment A1 and other data fragments A to electronic device B in sequence.

[0367] Specifically, the Bluetooth module of electronic device A sequentially sends data fragment A1 and other data fragments A to the Bluetooth module of electronic device B. The Bluetooth module of electronic device B then sends these data fragments A to the transmission engine in the data transmission module of electronic device B.

[0368] S614, The transmitting unit in electronic device A records the transmission time T of data fragment A1. send .

[0369] In other words, during the process of sending data packet A into its various data fragments A, the sending time of the first data fragment in data packet A is recorded. This sending time is also the sending time of data packet A, denoted as T. send .

[0370] Specifically, each data fragment has a sending timestamp when it is sent, and the sending time T of data A can be obtained from the sending timestamp of the first data fragment. send .

[0371] S615. The transmitting unit in electronic device A receives the acknowledgment message corresponding to data packet A sent by electronic device B, and records the reception time T of the acknowledgment message. recv and the size D of the confirmation message recv .

[0372] It can be understood that electronic device A sends data fragments of a data packet sequentially to electronic device B via Bluetooth. Once electronic device B has received all data fragments of a data packet, it sends an acknowledgment message (ACK message) back to electronic device A via Bluetooth to notify A that it has received the data packet. Therefore, after sending all data fragments of data packet A, electronic device A will receive an acknowledgment message from electronic device B regarding data packet A. After receiving the acknowledgment message, electronic device A can record the time it takes to receive the acknowledgment, called the reception time T. recv Meanwhile, electronic device A can determine the size of the received confirmation message, denoted as D. recv .

[0373] Specifically, after the transmitting engine in electronic device B confirms that all data fragments A in data packet A have been received, on the one hand, the transmitting engine in electronic device B sends data packet A to the session management. The session management in electronic device B forwards data packet A to the corresponding business application to notify the corresponding business application in electronic device B to perform operations such as storing data in data packet A, executing instructions in data packet A, or displaying data according to the data interface in data packet A. On the other hand, the transmitting engine in electronic device B sends an acknowledgment message to the Bluetooth module in electronic device B. The Bluetooth module in electronic device B forwards the acknowledgment message to the Bluetooth module in electronic device A. The Bluetooth module in electronic device A forwards the acknowledgment message to the transmitting unit in the transmitting engine of electronic device A. In this way, the transmitting unit of electronic device A can know the reception time T of the acknowledgment message. recv and the size D of the confirmation message recv .

[0374] S616, The transmitting unit in electronic device A will receive time T recv and the size D of the confirmation message recv Send to the rate management unit.

[0375] S617, The transmitting unit in electronic device A sends data according to the size D of data packet A. send Size of the confirmation message D recv Reception time T recv and sending time T send Calculate the transmission rate A.

[0376] Optionally, the transmission rate A can be calculated according to the following formula (1):

[0377]

[0378] Here, RATE represents the transmission rate. It can be understood that D... send +D recv The result, also known as the third value, represents the sum of the data sizes of the sent data packet A and the returned acknowledgment message (i.e., the amount of data sent). recv +T send The result is also called the second value, which represents the time it takes for data to travel from the sending unit to electronic device B and back, i.e., the round-trip time. The result can be considered as the data rate at which the Bluetooth module sends data to electronic device B.

[0379] S618, The transmitting unit in electronic device A updates the value of the estimated transmission rate to the transmission rate A.

[0380] In other words, the sending rate A is determined as the latest estimated sending rate.

[0381] It's understandable that the transmission rate of historical time periods closer to the current moment is closer to the actual current transmission rate; moreover, the transmission rate obtained by direct calculation is more accurate than the transmission rate estimated based on latency. Therefore, after each transmission rate is calculated, that rate is used as the latest estimated transmission rate, which improves the accuracy of the estimated transmission rate.

[0382] S619. The transmitting unit in electronic device A receives the acknowledgment message corresponding to data packet A sent by electronic device B, and records the reception time T of the acknowledgment message. recv .

[0383] S620, the transmitting unit in electronic device A will receive time T recv Send to the rate management unit.

[0384] S621, The rate management unit in electronic device A determines the transmission time T based on the rate management unit. send and receiving time T recv Calculate the delay A (also known as the first delay).

[0385] Specifically, the delay A can be calculated using the following formula (2):

[0386]

[0387] Here, RTT represents latency. It can be understood that T... recv +T send T represents the time it takes for data to travel from the sending unit to electronic device B and back, i.e., the round-trip time. recv +T send Dividing the result by 2 can be considered as the duration of the Bluetooth module sending data (one-way) to electronic device B. Therefore, this result can be used as the latency.

[0388] S622. The rate management unit in electronic device A determines whether the time elapsed since the last estimated transmission rate update is greater than or equal to the rate update cycle; if yes, then step S623 is executed; if no, then the current transmission rate calculation process ends.

[0389] S623. The rate management unit in electronic device A determines the transmission rate B corresponding to delay A based on the delay-rate mapping relationship between delay A and delay A.

[0390] The inventors discovered that latency is also affected by the air interface environment, and that there is a certain relationship between latency and transmission rate. When air interface interference is low, latency is low and transmission rate is high; when air interface interference is high, latency is high and transmission rate is low. Based on this, this embodiment provides a method that records a large amount of latency and transmission rate data and analyzes the relationship between the two to obtain a mapping relationship between latency and transmission rate (referred to as the latency-rate mapping relationship). Thus, when the transmitted data packets are small and the transmission rate cannot be accurately calculated, the transmission rate corresponding to that latency can be estimated by calculating the latency and then using the latency-rate mapping relationship. This solves the problem of inaccurate measurement of transmission rate in small data packet transmission scenarios and improves the accuracy of transmission rate estimation.

[0391] The latency-rate mapping relationship includes multiple preset latency ranges and their corresponding transmission rates. The rate management unit can determine the preset latency range to which latency A belongs, and then determine the transmission rate corresponding to that preset latency range. In this embodiment, the transmission rate corresponding to latency A is denoted as transmission rate B.

[0392] The latency-rate mapping relationship will be further explained in subsequent embodiments.

[0393] Furthermore, in this embodiment, the transmission rate is updated based on the delay only when the time elapsed since the last estimated transmission rate update is greater than or equal to the rate update period. This is because the transmission rate determined by the delay is slightly less accurate than the transmission rate calculated directly based on the transmission time, reception time, data packet size, and acknowledgment message size of larger data packets. Therefore, the directly calculated transmission rate is preferred, which improves the accuracy of transmission rate estimation, the accuracy of subsequent transmission quota estimation, and ultimately, the accuracy of bandwidth allocation.

[0394] S624, The rate management unit in electronic device A updates the estimated transmission rate value to the transmission rate B.

[0395] Under normal circumstances, the size of the data packet to be sent is much smaller than the sending quota of a quota period. That is, the sending quota of a quota period is sufficient to send data packets for multiple sending periods. Therefore, data fragments within the same data packet can generally be sent to the peer device in the same sending period. However, in some extreme cases, after some data fragments in a particular data packet are sent to the peer device in the first sending period, the sending unit enters a sleep state because the sending quota of the current quota period is insufficient to send the next data fragment. The other data fragments need to be allocated a sending quota in the next sending period before they can continue to be sent (see steps S308, S312 to S314, S210, or steps S408, S412 to S414, S210, or steps S504, S508 to S510, S210 in the above embodiments). In this case, according to the above... Figure 20 When calculating the transmission rate or delay using the method shown, the reception time T recv With the sending time T send There is a sleep time (i.e., the preset duration of 1 mentioned above), so the calculated transmission rate or delay is not accurate enough.

[0396] To address this, this application provides an implementation method whereby, after the sending unit executes step S611 and determines the measurement marker of the first data fragment A1, if the measurement marker is a speed measurement marker or a delay measurement marker, the sending unit can also obtain the size of data packet A from the rate management unit and determine whether the current sending quota is greater than or equal to the size of data packet A based on the current quota obtained from the quota management unit (see steps S303, S403, or S503 in the above embodiments). If the current sending quota is greater than or equal to the size of data packet A, it means that the current sending quota can send all data fragments in data packet A, and the subsequent steps continue. If the current sending quota is less than the size of data packet A, it means that the current sending quota is insufficient to send all data fragments in data packet A, and the sending unit may sleep during the transmission of data packet A. In this case, the measurement marker in the first data fragment A1 can be modified to an empty marker, and the sending rate or delay strategy for this data packet can be ignored. Alternatively, the sending unit can send a notification message to the rate management unit, and the rate management unit can then send a notification message even if it receives the size D of data packet A. send Size of the confirmation message D recv Reception time T recv and sending time T send The transmission rate and delay are not calculated. Alternatively, after receiving the notification message from the transmitting unit, the rate management unit can calculate the transmission rate using formula (3) and the delay using formula (4). This improves the accuracy of the estimated transmission rate calculation. Formulas (3) and (4) are as follows:

[0397]

[0398] Where T1 is the preset duration of 1, which is also the sleep duration of the transmitting unit.

[0399] The process of establishing and updating the delay-rate mapping relationship will be further explained below.

[0400] Optionally, the rate management unit can update the latency-rate mapping relationship according to a preset mapping update cycle. The duration of the mapping update cycle can be set according to actual needs.

[0401] For example, Figure 21 This is another example of a data transmission process provided in an embodiment of this application. For example... Figure 21 As shown, the latency-rate mapping can be created or updated using the following procedure:

[0402] S701, the rate management unit records the transmission time T corresponding to each calculated delay. send .

[0403] Specifically, after each execution of step S621, the rate management unit can execute step S701 to record the transmission time corresponding to the calculated delay.

[0404] S702, The rate management unit records the transmission time T corresponding to each calculated transmission rate. send .

[0405] Specifically, after each execution of step S617, the rate management unit can execute step S702 to record the transmission time corresponding to the calculated transmission rate.

[0406] S703, in each mapping update cycle, the rate management unit associates the delay and the transmission rate when the transmission time difference is less than a preset time threshold with the corresponding transmission time to obtain the associated data group.

[0407] The preset time threshold can be, for example, 0.5ms.

[0408] For example, see Figure 22The transmission times corresponding to the delays RTT1, RTT2, RTT3, RTT4, RTT5, and RTT6 are time1, time2, time3, time4, time5, and time6, respectively. The transmission times corresponding to the transmission rates RATE1, RATE2, RATE3, and RATE4 are time7, time8, time9, and time10, respectively. The time difference between time1 and time7 is less than a preset time threshold, therefore, RTT1 is associated with RATE1; the time differences between time2 and time3 and time8 are less than the preset time threshold, therefore, RTT2 and RTT3 are associated with RATE2; the time difference between time6 and time10 is less than the preset time threshold, therefore, RTT6 is associated with RATE4. The time differences between time7 and time8 and the transmission times corresponding to each transmission rate are all greater than or equal to the preset time threshold, therefore, RTT4 and RTT5 are not associated with any RATE. Similarly, RATE4 is not associated with any RTT.

[0409] It is understood that the data range targeted in step S702 can be all recorded transmission rates and delays. When there are newly calculated delays and / or transmission rates in each mapping update cycle, the newly calculated delays and transmission rates are also correlated according to this process. In this way, more data correlations can be obtained, and these data correlations will be used to analyze the mapping relationship between delay and transmission rate. It is understood that the larger the amount of data in the correlation data group, the more accurate the analyzed mapping relationship will be. Therefore, in this embodiment, adding all recorded correlations to the correlation data group as the basis for mapping relationship analysis can improve the accuracy of the obtained mapping relationship, thereby improving the accuracy of transmission rate prediction.

[0410] S704 The rate management unit determines multiple preset delay ranges based on the delay in the associated data group.

[0411] Among them, some or all of the delays in the associated data group are within the delay range.

[0412] In other words, multiple preset delay ranges can represent the range of delay values ​​in the associated data group. The granularity of the preset delay ranges can be set according to requirements.

[0413] For example, Figure 22 In the associated data group shown, the values ​​of RTT1, RTT2, RTT3, RTT5 and RTT6 are mainly between 40ms and 70ms. Based on this, three preset delay ranges can be divided: 40ms to 50ms, 50ms to 60ms, and 60ms to 70ms.

[0414] S705 The rate management unit clusters the transmission rates corresponding to the delays within each preset delay range to obtain a set of transmission rates corresponding to each preset delay range.

[0415] S706 The rate management unit processes each transmission rate set separately, determines the transmission rate corresponding to each preset delay range, and obtains the delay-rate mapping relationship.

[0416] In other words, the data in the transmission rate set corresponding to each delay range is processed to obtain a transmission rate, and this transmission rate is determined as the transmission rate corresponding to the preset delay range.

[0417] Optionally, the data in the transmission rate set can be processed by averaging the data in the transmission rate set.

[0418] For example, Figure 23 This is a schematic diagram illustrating an example of a delay-rate mapping relationship provided in an embodiment of this application. For example... Figure 23 As shown, assume that the corresponding transmission rate sets are obtained by clustering according to three preset delay ranges: 40ms to 50ms, 50ms to 60ms, and 60ms to 70ms, respectively: transmission rate set 1, transmission rate set 2, and transmission rate set 3. Transmission rate set 1 includes RATE1, RATE2, and RATE3; transmission rate set 2 includes RATE3, RATE4, RATE5, RATE6, and RATE7; and transmission rate set 3 includes RATE2, RATE5, and RATE8. The transmission rates in transmission rate set 1 can be processed to obtain transmission rate a; the transmission rates in transmission rate set 2 can be processed to obtain transmission rate b; and the transmission rates in transmission rate set 3 can be processed to obtain transmission rate c. Thus, the delay-rate mapping relationship can be obtained: the preset delay range of 40ms to 50ms corresponds to transmission rate a; the preset delay range of 50ms to 60ms corresponds to transmission rate b; and the preset delay range of 60ms to 70ms corresponds to transmission rate c.

[0419] In this embodiment, by using multiple delays, multiple transmission rates, and corresponding transmission times, and through analysis and clustering, the delay-rate mapping relationship can be determined simply and accurately, thereby improving the accuracy of transmission rate prediction.

[0420] The foregoing has detailed examples of the data transmission methods provided in the embodiments of this application. It is understood that, in order to achieve the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.

[0421] This application embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into a separate functional module, such as a detection unit, a processing unit, a display unit, etc., or two or more functions can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.

[0422] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.

[0423] The electronic device provided in this embodiment is used to execute the above data transmission method, and therefore can achieve the same effect as the above implementation method.

[0424] When using integrated units, the electronic device may also include a processing module, a storage module, and a communication module. The processing module is used to control and manage the operation of the electronic device. The storage module supports the execution of stored program code and data. The communication module supports communication between the electronic device and other devices.

[0425] The processing module can be a processor or a controller. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a digital signal processor (DSP), and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, or other devices that interact with other electronic devices.

[0426] In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device involved in this embodiment can be a device having... Figure 8 or Figure 9 The device with the structure shown.

[0427] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to perform the data transmission method of any of the above embodiments.

[0428] This application also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the data transmission method described above.

[0429] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the data transmission methods in the above-described method embodiments.

[0430] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.

[0431] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0432] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0433] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0434] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0435] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0436] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A data transmission method, the method being performed by a first electronic device, characterized in that, The first electronic device and the second electronic device are connected via Bluetooth, and the method includes: First data is obtained from the first sending queue; the first data is stored in the first sending queue in the form of multiple first data fragments; The first data is sent to the second electronic device via Bluetooth; After the first data in the first sending queue is sent, the second data is retrieved from the second sending queue; the sending priority of the first data is higher than the sending priority of the second data. The second data is sent to the second electronic device via Bluetooth; The step of sending the first data to the second electronic device via Bluetooth includes: Obtain the current sending quota; the current sending quota refers to the sending quota remaining at the current moment after the initial sending quota of the current quota period has been consumed. The initial sending quota of the current quota period represents the total amount of data that the first electronic device is expected to send via Bluetooth within the current quota period. The quota period refers to the period during which the initial sending quota is updated. If the current sending quota is less than or equal to the first value, the first target data fragment is added to the head of the first sending queue, and the current sending quota is revoked; the first target data fragment is a first data fragment obtained from the first sending queue based on the first-in-first-out principle; the first value is the product of the size of the first target data fragment and the first percentage, where the first percentage is greater than 0 and less than 100%.

2. The method according to claim 1, characterized in that, Before retrieving the first data from the first sending queue, the method further includes: The first application generates the first data; The first application adds a first priority tag to the first data according to the type of the first data; The first application adds the first data to the first sending queue according to the first priority flag.

3. The method according to claim 1, characterized in that, Before retrieving the second data from the second sending queue, the method further includes: The second application generates the second data; The second application adds a second priority flag to the second data based on the type of the second data; The second application adds the second data to the second sending queue according to the second priority flag.

4. The method according to claim 1, characterized in that, After the first data in the first sending queue is sent, the second data is retrieved from the second sending queue, including: After the first data in the first sending queue is sent, the third data is obtained from the third sending queue; the sending priority of the third data is lower than the sending priority of the first data, but higher than the sending priority of the second data. The third data is sent to the second electronic device via Bluetooth; After the data in the third sending queue has been sent, the second data is retrieved from the second sending queue.

5. The method according to claim 4, characterized in that, The first data is instruction data, the second data is file data, and the third data is streaming media data.

6. The method according to claim 1, characterized in that, The step of obtaining the first data from the first sending queue includes: Determine whether the first data fragment exists in the first sending queue; If the first data fragment exists in the first sending queue, then based on the first-in-first-out principle, a first data fragment is obtained from the first sending queue to obtain the first target data fragment.

7. The method according to claim 6, characterized in that, The step of sending the first data to the second electronic device via Bluetooth further includes: If the current sending quota is greater than the first value, the first target data fragment is sent to the second electronic device via Bluetooth, and the process returns to determine whether the first data fragment exists in the first sending queue.

8. The method according to claim 7, characterized in that, The step of sending the first target data fragment to the second electronic device via Bluetooth if the current sending quota is greater than the first value includes: If the current sending quota is greater than or equal to the size of the first target data fragment, the first target data fragment is sent to the second electronic device via Bluetooth, and the sending quota of the current quota period is consumed according to the size of the first target data fragment, and the current sending quota is updated. If the current sending quota is less than the size of the first target data fragment, then determine whether the current sending quota is greater than the first value; If the current transmission quota is greater than the first value, the first target data fragment is sent to the second electronic device via Bluetooth, and the transmission quota for the next quota period is overdrawn according to the size of the first data fragment.

9. The method according to claim 8, characterized in that, The first electronic device includes a transmitting unit; Determining whether the first data fragment exists in the first sending queue includes: After the sending unit enters the working state from the sleep state, the sending unit determines whether the first data fragment exists in the first sending queue; After overdrafting the transmission quota for the next quota period based on the size of the first data fragment, and after reclaiming the current transmission quota, the method further includes: The transmitting unit enters a sleep state.

10. The method according to claim 6, characterized in that, The second data is stored in the second sending queue in the form of multiple second data fragments; After the first data in the first sending queue is sent, the second data is retrieved from the second sending queue, including: If the first data fragment does not exist in the first sending queue, then determine whether the second data fragment exists in the second sending queue; If the second data fragment exists in the second sending queue, then based on the first-in-first-out principle, a second data fragment is obtained from the second sending queue to obtain the second target data fragment.

11. The method according to claim 10, characterized in that, The step of sending the second data to the second electronic device via Bluetooth includes: Obtain the current sending quota; the current sending quota refers to the sending quota remaining at the current moment after the initial sending quota of the current quota period has been consumed. The initial sending quota of the current quota period represents the total amount of data that the first electronic device is expected to send via Bluetooth within the current quota period. The quota period refers to the period during which the initial sending quota is updated. If the current transmission quota is greater than or equal to the size of the second target data fragment, the second target data fragment is transmitted to the second electronic device via Bluetooth, and the transmission quota of the current quota period is consumed according to the size of the second target data fragment, the current transmission quota is updated, and the process returns to determine whether the first data fragment exists in the first transmission queue.

12. The method according to claim 11, characterized in that, The method further includes: If the current sending quota is less than the size of the second target data fragment, then the second target data fragment is added to the first position of the second sending queue, and the current sending quota is revoked.

13. The method according to claim 12, characterized in that, The first electronic device includes a transmitting unit; The method further includes: If the second data fragment is not present in the second transmission queue, the transmission unit enters a sleep state; After reclaiming the current sending quota, the method further includes: The transmitting unit enters a sleep state.

14. The method according to any one of claims 7 to 13, characterized in that, The first electronic device includes a transmitting unit; before determining whether the first data fragment exists in the first transmitting queue, the method further includes: In response to the transmitting unit entering the working state, if the time difference between the current moment and the moment of the last update of the initial transmitting quota is greater than or equal to the duration of the quota period, a first transmitting rate is obtained; the first transmitting rate represents the rate at which the first electronic device transmits data via Bluetooth, and the first transmitting rate is determined based on historical data; Based on the first transmission rate, determine the initial transmission quota for the current quota period; If the initial sending quota is greater than 0, then the step of determining whether the first data fragment exists in the first sending queue is executed; If the initial transmission quota is less than or equal to 0, the transmission unit enters a sleep state.

15. The method according to claim 14, characterized in that, The longest duration for which the sending unit is in working state is a first preset duration, and the duration of the quota period is equal to n times the first preset duration, where n is an integer greater than 1 and less than 10.

16. The method according to claim 14, characterized in that, The step of determining the initial transmission quota for the current quota period based on the first transmission rate includes: Calculate the product of the first transmission rate and the duration of the quota period to obtain the estimated transmission quota; Calculate the sum of the estimated sending quota and the sending quota recovered in the previous quota period, or calculate the difference between the estimated sending quota and the sending quota overdrawn in the previous quota period to obtain the initial sending quota for the current quota period.

17. The method according to claim 14, characterized in that, Before obtaining the first transmission rate, the method further includes: During the process of sending the first historical data packet to a third electronic device via Bluetooth, if the size of the first historical data packet is greater than a first threshold, the first transmission rate is calculated based on the transmission time of the first historical data packet, the reception time of the confirmation message, the size of the first historical data packet, and the size of the confirmation message; the confirmation message is sent by the third electronic device to confirm receipt of the first historical data packet. If the size of the first historical data packet is less than the second threshold, then the first delay is calculated based on the sending time and the receiving time, and the first sending rate is determined based on the first delay; the second threshold is less than the first threshold.

18. The method according to claim 17, characterized in that, The method further includes: If the size of the first historical data packet is greater than the first threshold, then a first tag is set on the first historical data packet; If the size of the first historical data packet is less than the second threshold, then a second flag is set for the first historical data packet; During the process of sending data packets to the third electronic device via Bluetooth, if it is determined that the data packet contains the first marker, the sending time, the receiving time, the size of the first historical data packet, and the size of the confirmation message are recorded. If it is determined that the data packet contains the second marker, then the sending time and the receiving time are recorded.

19. The method according to claim 17, characterized in that, The step of calculating the first transmission rate based on the transmission time of the first historical data packet, the reception time of the acknowledgment message, the size of the first historical data packet, and the size of the acknowledgment message includes: Calculate the sum of the sending time and the receiving time to obtain the second value; The third value is obtained by summing the size of the first historical data packet and the size of the confirmation message. The first time delay is obtained by calculating the quotient of the third value and the second value.

20. The method according to claim 17, characterized in that, The step of calculating the first delay based on the sending time and the receiving time includes: Calculate the sum of the sending time and the receiving time to obtain the second value; The first transmission rate is obtained by calculating the quotient of the second value and 2.

21. The method according to claim 17, characterized in that, Determining the first transmission rate based on the first delay includes: Obtain a first mapping relationship; the first mapping relationship includes a one-to-one correspondence between multiple preset delay ranges and multiple transmission rates, and the first preset delay range among the multiple preset delay ranges includes the first delay; Based on the first mapping relationship, the transmission rate corresponding to the first preset delay range is determined, and the first transmission rate is obtained.

22. The method according to claim 21, characterized in that, Before obtaining the first mapping relationship, the method further includes: Obtain multiple delays and their corresponding sending times; Obtain multiple transmission rates and their corresponding transmission times; Correlate the corresponding delays with a transmission time difference less than a preset time threshold with the transmission rate to obtain a correlated data group; The plurality of preset delay ranges are determined based on the delay in the associated data group; Cluster the transmission rates corresponding to the delays within the second preset delay range to obtain a first rate set; the second preset delay range is any one of the plurality of preset delay ranges; The transmission rate corresponding to the second preset delay range is obtained by processing the transmission rate of the first rate set.

23. The method according to claim 17, characterized in that, Determining the first transmission rate based on the first delay includes: If the time difference between the current moment and the moment when the first transmission rate was last updated is greater than or equal to the preset transmission rate update period, the first transmission rate is determined based on the first delay.

24. The method according to any one of claims 1 to 23, characterized in that, The first electronic device also includes a Bluetooth module; The step of obtaining the first data from the first sending queue includes: If it is determined that the Bluetooth module is not in a blocked state, then the first data is obtained from the first transmission queue.

25. The method according to claim 24, characterized in that, The first electronic device includes a transmitting unit, and the method further includes: If it is determined that the Bluetooth module is in a blocked state, the transmitting unit enters a sleep state.

26. An electronic device, characterized in that, The electronic device includes: one or more processors, and memory; The memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 25.

27. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system including one or more processors, the one or more processors being used to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 25.

28. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1 to 25.