Data sending method and electronic equipment

By adopting the priority queue mechanism in Bluetooth transmission, the problem of untimely transmission of medium and high priority data in multiple services is solved, and the timely transmission and stable transmission of data is realized, and the user experience is improved.

CN120475520AActive Publication Date: 2025-08-12HONOR DEVICE CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411492976.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-08-12
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

When multi-service concurrent data transmission is carried out through Bluetooth, it is easy to cause inadvertent transmission of instruction data, resulting in service lag and affecting user experience.

Method used

The priority queue mechanism is adopted to add data to the sending queue of corresponding priority according to the real-time requirements of the data, and send data in priority order to ensure that high-priority data is sent first and prevent blockage.

Benefits of technology

It improves the stability and performance of Bluetooth transmission, reduces the delay of high-priority data, ensures timely data transmission, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120475520A_ABST
    Figure CN120475520A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data sending method and electronic equipment, the method is executed by first electronic equipment, the first electronic equipment is in Bluetooth connection with second electronic equipment, and the method comprises the following steps: obtaining first data from a first sending queue; sending the first data to a second electronic device through Bluetooth; after the first data in the first sending queue is sent, obtaining second data from a second sending queue; the sending priority of the first data is higher than that of the second data; and sending the second data to the second electronic equipment through Bluetooth. The method can prevent service lagging and improve user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of electronic technology, and in particular to a data sending method and electronic equipment. Background Art

[0002] Bluetooth is an important short-range wireless transmission technology that is widely used in electronic devices. It can be used to transmit command data, file data, etc. between two electronic devices.

[0003] However, during use, it was found that when transmitting multiple business concurrent data via Bluetooth, the command data was easily not transmitted in a timely manner, resulting in business jams and affecting user experience. Summary of the Invention

[0004] The present application provides a data sending method and electronic device, which can transmit high-priority data in a timely manner, prevent business jams, and improve user experience.

[0005] In a first aspect, a data sending method is provided, which is executed by a first electronic device, and the first electronic device is connected to a second electronic device via Bluetooth. The method includes: obtaining first data from a first sending queue; sending the first data to the second electronic device via Bluetooth; after the first data in the first sending queue is sent, obtaining second data from the second sending queue; the sending priority of the first data is higher than the sending priority of the second data; and sending 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 sending queue or the second sending queue may also be a medium priority queue in a specific embodiment.

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

[0008] The sending priority of the first data is higher than the sending priority of the second data, indicating that the first data needs to be sent before the second data. The scenario where the sending priority of the first data is higher than the sending priority of the second data is, for example: the real-time requirement of the first data is higher than the real-time requirement of the second data.

[0009] The data sending method provided in the first aspect of the present application is that the sending priority of the data in the first sending queue is higher than the sending priority of the data in the second sending queue. When sending, the data in the first sending queue is sent first, and after the data in the first sending queue is sent, the data in the second sending queue is sent. In this way, high-priority data can be sent first to prevent high-priority data from being blocked. For example, data with high real-time requirements can be prevented from being blocked, and the time delay of these data is reduced, thereby ensuring the timeliness of sending, thereby preventing business jams, improving the stability and transmission performance of Bluetooth transmission, and improving user experience. In addition, when the high-priority first data is sent, the low-priority second data can also be sent in time, making full use of the Bluetooth bandwidth, improving bandwidth utilization, and increasing the transmission efficiency of low-priority data as much as possible to improve user experience.

[0010] In one possible implementation, before obtaining the first data from the first sending queue, the method also 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; and the first application adds the first data to the first sending queue according to the first priority tag.

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

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

[0013] In this implementation, a priority tag is added to the first data according to the type of the first data, so that data with different sending priority requirements can be added to different sending queues, preventing high-priority data from being blocked, preventing business jams, and improving user experience.

[0014] In one possible implementation, before obtaining the second data from the second sending queue, the method also includes: the second application generates the second data; the second application adds a second priority tag to the second data according to the type of the second data; and the second application adds the second data to the second sending queue according to the second priority tag.

[0015] The way of dividing the types of the second data is similar to the way of dividing the types of the first data, and will not be repeated here.

[0016] In this implementation, a priority tag is added to the second data according to the type of the second data, so that data with different sending priority requirements can be added to different sending queues, preventing high-priority data from being blocked, preventing business jams, and improving user experience.

[0017] In one possible implementation, after the first data in the first sending queue is sent, the second data is obtained 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, and 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 is sent, the second data is obtained from the second sending queue.

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

[0019] This implementation method, through three priority sending queues, can send data according to priority in a more fine-grained manner, further prevent higher priority data from being blocked, prevent business jams, and improve user experience.

[0020] In a 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 first, streaming data is sent second, and file data is sent last. This order of sending meets the user's real-time requirements, prevents command data and streaming data from being blocked and causing lag, and improves the user experience.

[0022] In one possible implementation, the first data is stored in a first sending queue in the form of multiple first data slices; obtaining the first data from the first sending queue includes: determining whether the first data slice exists in the first sending queue; if the first data slice exists in the first sending queue, then based on the first-in-first-out principle, obtaining a first data slice from the first sending queue to obtain a first target data slice.

[0023] This implementation divides data into multiple data slices and sends them in multiple batches, preventing overly large data packets from being unable to be sent and improving the success rate and accuracy of transmission. Furthermore, this implementation uses a first-in, first-out principle to retrieve data slices from the transmission queue, ensuring the correct data transmission order and improving the reliability and accuracy of data transmission.

[0024] In one possible implementation, the first data is sent to the second electronic device via Bluetooth, including: obtaining a 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 is 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, and the quota period refers to the period for updating the initial sending quota; if the current sending quota is greater than a first value, the first target data fragment is sent to the second electronic device via Bluetooth, and the execution is returned to determine whether the first data fragment exists in the first sending queue; the first value is the product of the size of the first target data fragment and a first percentage, and the first percentage is greater than 0 and less than 100%.

[0025] The first target data slice is a data slice obtained from the first sending queue based on the first-in-first-out principle, that is, the first data slice in the first sending queue. The first target data slice is the data slice to be sent in the current first sending queue.

[0026] The current sending quota is greater than the first value, which means that the current sending quota is large enough to send the first target data fragment, that is, sending the first target data fragment will not cause Bluetooth congestion; or, the current sending quota is not enough to send the first target data fragment, but the gap with the first target data fragment is not large (in other words, it means that the first target data fragment is not very large). In this case, the first target data fragment can be sent after a short queue and will not cause serious Bluetooth congestion. Therefore, under the condition that the congestion is acceptable, the timely sending of the high-priority first target data fragment is guaranteed, which is conducive to improving user experience.

[0027] In one possible implementation, 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, including: 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 according to the size of the first target data fragment, the sending quota of the current quota period is consumed, and the current sending quota is updated; if the current sending quota is less than the size of the first target data fragment, it is determined whether the current sending quota is greater than the first value; 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 according to the size of the first data fragment, the sending quota of the next quota period is overdrawn.

[0028] In this implementation, while ensuring the timeliness of the high-priority first target data fragment, the sending quota is consumed or overdrawn, which facilitates the subsequent accurate management of the sending quota, thereby achieving reasonable allocation of the sending quota, further preventing Bluetooth congestion, and improving user experience.

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

[0030] The current sending quota is less than or equal to the first percentage of the size of the first target data shard, indicating that the current sending quota is significantly different from the size of the first target data shard (i.e., the high-priority data shard is larger). Even if the quota is transmitted, data may be blocked or even overflowed, resulting in greater delays and affecting user experience. Therefore, the sending of the first target data shard is abandoned, the first target data shard is re-added to the first sending queue, and the sending quota is recovered.

[0031] In this implementation, when the first target data fragment cannot be sent, the data fragment is added to the first sending queue again and placed at the first place in the first sending queue, so that the first target data fragment can be obtained first from the first sending queue during the next sending, thereby 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 sending quota is small, the sending of larger data fragments is abandoned to prevent the larger data fragments from blocking or even overflowing the Bluetooth module, thereby ensuring the stability and reliability of data transmission.

[0033] Moreover, in this implementation, when there is a large amount of remaining sending quota, the remaining sending quota will not be recycled, and the sending quota may be recycled only when there is a small amount of remaining sending quota. This can prevent the sending quota from accumulating too high as the quota cycle continues, prevent the occurrence of false sending quotas, improve the accuracy of sending quota calculation, thereby improving the accuracy of bandwidth allocation and control, and further improving the accuracy of Bluetooth transmission performance.

[0034] In one possible implementation, the first electronic device includes a sending unit; determining whether a first data fragment exists in a first sending queue includes: after the sending unit enters a working state from a sleep state, the sending unit determines whether the first data fragment exists in the first sending queue; based on the size of the first data fragment, after overdrawing the sending quota of the next quota cycle, and after recovering the current sending quota, the method also includes: the sending unit enters a sleep state.

[0035] In this implementation, the sending unit enters a dormant state after the sending quota of the current quota period is exhausted or less remains, and enters a working state again when needed. This can prevent the sending unit from being in a working state continuously, which causes excessive power consumption of the first electronic device, and can extend the standby time of the first electronic device.

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

[0037] In one possible implementation, the second data is sent to the second electronic device via Bluetooth, including: obtaining a 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 is consumed, and 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, and the quota period refers to the period for updating the initial sending quota; if the current sending quota is greater than or equal to the size of the second target data fragment, the second target data fragment is sent to the second electronic device via Bluetooth, and according to the size of the second target data fragment, the sending quota of the current quota period is consumed, and the current sending quota is updated, and the execution is returned to determine whether the first data fragment exists in the first sending queue.

[0038] In a possible implementation, the method further includes: if the current sending quota is smaller than the size of the second target data slice, adding the second target data slice to the first position of the second sending queue and reclaiming the current sending quota.

[0039] In this implementation, in the second data transmission process with a lower priority, if the current transmission quota is smaller than the size of the second target data fragment, the second target data fragment is not sent by using the transparent quota. Instead, the transmission of the second target data fragment is directly canceled and the quota is recovered. This is because low-priority data does not have high real-time requirements. On the one hand, it prevents low-priority data fragments from forming data congestion and affecting the transmission of high- and medium-priority data in the next transmission cycle; on the other hand, it can also save the transmission quota and use the transmission quota for the next quota cycle to give priority to sending subsequent high- and medium-priority data, further ensuring that these data are sent in a timely manner, preventing electronic devices from freezing, and improving user experience.

[0040] In a possible implementation, the first electronic device includes a sending unit; after the current sending quota is recovered, the method further includes: the sending unit entering a dormant state.

[0041] In a possible implementation, the method further includes: if the second data fragment does not exist in the second sending queue, the sending unit enters a dormant state.

[0042] In this implementation, the sending unit enters a dormant state after the sending quota of the current quota period is exhausted or becomes low, or after all data in the sending queue is sent. This prevents the sending unit from being in a continuously active state, which would cause excessive power consumption in the first electronic device, and thus extends the standby time of the first electronic device.

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

[0044] In this implementation, after determining the initial send quota, it is determined whether the initial send quota is greater than 0. If the initial send quota is greater than 0, it indicates that there are currently available Bluetooth resources and data can be sent, and the data sending operation is then performed. If the initial send quota is less than or equal to 0, no data is sent and the system enters a dormant state. This prevents data congestion and ensures system stability.

[0045] Furthermore, this implementation utilizes historical data to more accurately estimate the sending rate, enabling a more accurate and instructive estimate of the sending quota. As can be appreciated, overestimating the sending quota can lead to link congestion, while underestimating the sending quota can lead to bandwidth waste. Therefore, accurately estimating the sending quota in this implementation enables more precise bandwidth allocation and management, preventing both link congestion and bandwidth waste, thereby improving service transmission performance and stability.

[0046] In a possible implementation, the maximum duration that the sending unit is in the 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 that the sending unit is in the working state is also the duration of the sending cycle in the specific implementation. The first preset duration is also the preset duration 2 in the specific implementation.

[0048] In this implementation, several times the length of the sending cycle is used as the quota cycle. The calculated sending quota is larger than 1 times the length of the sending cycle, which can prevent the sending quota from being too low, thereby preventing the data sending rate from being too low, preventing jams, improving data transmission performance, and improving user experience. Moreover, the calculated sending quota will not be too large, which can ensure the accuracy of the quota estimation, thereby improving the accuracy of bandwidth allocation, and improving data transmission performance and stability. On the other hand, the sending quota is determined based on the first sending rate, and several times the sending cycle is used as the quota 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 larger data can be sent, and can prevent the situation where the sending quota estimate is extremely low and the data cannot be sent, thereby improving data transmission performance and stability and improving user experience.

[0049] In addition, the duration of the quota cycle is set to an integer multiple of the sending cycle duration. In this way, each time the sending unit is awakened, a quota update judgment is triggered, which facilitates timely updating of the sending quota and improves the accuracy of sending quota management. There is no need for additional processes to trigger quota update judgments, and there is no need to wake up the sending unit additionally, which further saves power consumption and extends the standby time of electronic devices.

[0050] In one possible implementation, the initial sending quota for the current quota period is determined based on the first sending rate, including: calculating the product of the first sending rate and the length of the quota period to obtain an estimated sending quota; calculating the sum of the estimated sending quota and the sending quota recovered in the previous quota period, or calculating 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.

[0051] In this implementation, based on the estimated sending 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 the sending rate. On the other hand, it can prevent bandwidth waste.

[0052] In one possible implementation, before obtaining the first sending rate, the method also includes: in the process of sending a 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, calculating the first sending rate based on the sending time of the first historical data packet, the receiving 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 and is used to confirm the receipt of the first historical data packet; if the size of the first historical data packet is less than a second threshold, calculating the first delay based on the sending time and the receiving time, and determining the first sending 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 packets are sent for extended periods. Small packets cannot reflect Bluetooth's true transmission rate, meaning that transmission data measured based on small packets is inaccurate. Therefore, this implementation determines the size of the packet. If a packet is large, the rate is measured based on that packet; if no large packets exist, the latency is measured based on smaller packets. Determining the transmission rate based on latency improves the accuracy of transmission rate measurements and, consequently, 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, setting a first mark to the first historical data packet; if the size of the first historical data packet is less than a second threshold, setting a second mark to the first historical data packet; in the process of sending a data packet to a third electronic device via Bluetooth, if it is determined that the data packet has the first mark, recording the sending time, receiving time, size of the first historical data packet and size of the confirmation message; if it is determined that the data packet has the second mark, recording the sending time and receiving time.

[0055] In this implementation, the data required for calculating the first sending rate can be recorded quickly, effectively, and selectively through the first mark and the second mark, thereby simplifying the method process and improving the operating efficiency of the method.

[0056] In one possible implementation, the first sending rate is calculated based on the sending time of the first historical data packet, the receiving time of the confirmation message, the size of the first historical data packet and the size of the confirmation message, including: calculating the sum of the sending time and the receiving time to obtain the second value; calculating the sum of the size of the first historical data packet and the size of the confirmation message to obtain the third value; calculating the quotient of the third value and the second value to obtain the first delay.

[0057] In a possible implementation, calculating the first delay according to the sending time and the receiving time includes: 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 the first sending rate.

[0058] In one possible implementation, determining a first sending rate based on a 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 sending rates, and a first preset delay range in the multiple preset delay ranges includes the first delay; based on the first mapping relationship, determining the sending rate corresponding to the first preset delay range to obtain the first sending rate.

[0059] In one possible implementation, before obtaining the first mapping relationship, the method also includes: obtaining multiple delays and corresponding sending times; obtaining multiple sending rates and corresponding sending times; associating delays and sending rates whose corresponding sending time differences are 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 sending 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 multiple preset delay ranges; and obtaining the sending rate corresponding to the second preset delay range based on processing the sending rate in the first rate set.

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

[0061] In one possible implementation, determining the first sending rate based on the first delay includes: determining the first sending rate based on the first delay when it is determined that the time difference between the current moment and the moment when the first sending rate was last updated is greater than or equal to a preset sending rate update period.

[0062] In this implementation, the sending rate is updated based on the first delay only when it is determined that the time interval between the current moment and the last update of the first sending rate is greater than or equal to the rate update period. This is because the sending rate determined by delay is slightly less accurate than the sending rate calculated directly based on the send time, receive time, packet size, and acknowledgment message size of larger packets. Therefore, the directly calculated sending rate is preferred. This improves the accuracy of sending rate estimation, subsequent sending quota estimation, and, ultimately, bandwidth allocation.

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

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

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

[0066] In a second aspect, the present application provides a device, which is included in an electronic device and has the function of implementing the electronic device behavior described in the first aspect and possible implementations of the first aspect. The function can be implemented through hardware or through hardware executing corresponding software implementations. The hardware or software includes one or more modules or units corresponding to the above functions. For example, a receiving module or unit, a processing module or unit, etc.

[0067] In a third aspect, the present application provides an electronic device, which includes: a processor, a memory, and an interface; the processor, the memory, and the interface cooperate with each other so that the electronic device executes any one of the methods in the technical solution of the first aspect.

[0068] Optionally, the electronic device may be a wearable device, or a device with a Bluetooth module such as a mobile phone or a tablet computer.

[0069] In a fourth aspect, the present application provides a chip system, comprising a processor, wherein the processor is configured to read and execute a computer program stored in a memory to perform the method of the first aspect and any possible implementation thereof.

[0070] Optionally, the chip system also includes a memory, and the memory is connected to the processor via circuits or wires.

[0071] Further optionally, the chip system also includes a communication interface.

[0072] In a fifth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the processor executes any one of the methods in the technical solution of the first aspect.

[0073] In a sixth aspect, the present application provides a computer program product, which includes: a computer program code, which, when the computer program code runs on an electronic device, enables the electronic device to execute any one of the methods in the technical solution of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 This is an application scenario diagram of a data sending method provided in an embodiment of the present application;

[0075] Figure 2 This is an application scenario diagram of another data sending method provided in an embodiment of the present application;

[0076] Figure 3 This is another application scenario diagram of a data sending method provided in an embodiment of the present application;

[0077] Figure 4 This is another application scenario diagram of a data sending method provided in an embodiment of the present application;

[0078] Figure 5 This is another application scenario diagram of a data sending method provided in an embodiment of the present application;

[0079] Figure 6 This is a schematic diagram of a transmission model for a multi-service shared Bluetooth link in the related art;

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

[0081] Figure 8 1 is a schematic structural diagram of an electronic device 100 provided in an embodiment of the present application;

[0082] Figure 9 2 is a schematic structural diagram of an electronic device 200 provided in an embodiment of the present application;

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

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

[0085] Figure 12 This is a schematic diagram of an application scenario of another data sending method provided in an embodiment of the present application;

[0086] Figure 13 This is a flow chart of a data transmission method provided in an embodiment of the present application;

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

[0088] Figure 15 This is a flowchart of another data sending method provided in an embodiment of the present application;

[0089] Figure 16 This is a flowchart of another data sending method provided in an embodiment of the present application;

[0090] Figure 17 This is a flowchart of another data sending method provided in an embodiment of the present application;

[0091] Figure 18 This is a flowchart of another data sending method provided in an embodiment of the present application;

[0092] Figure 19 This is a flowchart of another data sending method provided in an embodiment of the present application;

[0093] Figure 20 This is a flowchart of another data sending method provided in an embodiment of the present application;

[0094] Figure 21 This is a flowchart of another data sending method provided in an embodiment of the present application;

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

[0096] Figure 23 This is a schematic diagram of the principle of a delay-rate mapping relationship provided in an embodiment of the present application. DETAILED DESCRIPTION

[0097] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships can exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0098] In the following, 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 quantity of the technical features indicated. Therefore, a feature specified as "first," "second," or "third" may explicitly or implicitly include one or more of the features.

[0099] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of the present application include a particular feature, structure, or characteristic described in conjunction with that embodiment. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in different places in this 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 "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

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

[0101] 1. Bluetooth bandwidth

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

[0103] It's important to note that Bluetooth bandwidth is affected by the air interface environment. The air interface environment refers to the ambient conditions surrounding signal transmission between wireless communication devices. This includes, but is not limited to, electromagnetic interference, obstacles, and distance.

[0104] 2. Sending rate

[0105] The transmission rate refers to the speed at which data is sent from one device to another, that is, the actual rate at which the device sends data. The transmission rate can be expressed in units such as bits per second (bps), kilobits per second (Kbps), and megabits per second (Mbps).

[0106] It can be understood that the Bluetooth bandwidth determines the upper limit of the sending rate. In other words, the maximum value of the sending rate is the Bluetooth bandwidth.

[0107] 3. Latency

[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 delay, propagation delay, processing delay, and queuing delay. Transmission delay refers to the time it takes for a node to transmit a data block and enter the transmission medium. Propagation delay refers to the time it takes for an electromagnetic or optical signal to travel a certain distance through the transmission medium, from the time the sender sends data to the time the data is received by the receiver. Latency is the sum of transmission delay, propagation delay, processing delay, and queuing delay.

[0109] 4. Send Queue

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

[0111] Bluetooth communication is a common short-range communication method between electronic devices. The stability and performance requirements for Bluetooth transmission are becoming increasingly stringent, especially for wearable devices such as smartwatches and fitness trackers. As the ecosystem of converged connected products grows, wearable devices are also joining the trust cycle, supporting trusted connections with other Android devices, intelligent service flow, and sharing. Furthermore, wearable devices generally only support short-range near-field communication via Bluetooth. Consequently, Bluetooth is used in more scenarios and more frequently on these wearable devices, making the stability and performance of Bluetooth transmission even more critical.

[0112] The embodiments of the present application aim to provide a method for sending data during Bluetooth communication, thereby improving the stability and performance of Bluetooth transmission from the perspective of data transmission.

[0113] First, the application scenario of the data sending method provided in the embodiment of the present application is described.

[0114] This method can be applied to scenarios where two electronic devices transmit data via a Bluetooth device. The two electronic devices can be mobile phones, tablet computers, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), and other electronic devices with Bluetooth functionality. The embodiments of this application do not impose any restrictions on the specific types of electronic devices.

[0115] For example, Figure 1 This is a schematic diagram of an application scenario of a data sending method provided in an embodiment of the present application. Figure 1 As shown, two electronic devices, namely a smart watch 101 and a mobile phone 102, are used as examples for explanation. The smart watch 101 and the mobile phone 102 are connected via Bluetooth, and various business data can be transmitted between the two via Bluetooth to realize various business functions. The types of business data may include file data, streaming data, command data, etc. File data refers to data stored in the device mainly in the form of files. Streaming data refers to media data that is played continuously and in real time on the network using streaming transmission technology, such as audio streams and video streams. Command data is a command or signal used to control a device or software to perform a specific operation.

[0116] It is understandable that file data is generally large and takes a long time to transfer, but most file data do not require high real-time transmission. Taking the example of smart watch 101 transmitting file data to mobile phone 102, smart watch 101 can transmit collected exercise data, heart rate data, sleep data, photos or videos and other file data to mobile phone 102 via Bluetooth, such as Figure 2 Of course, the mobile phone 102 can also transmit file data to the smart watch 101 via Bluetooth. Optionally, the file data can be transmitted in the background.

[0117] Streaming media data has certain continuity and real-time requirements for transmission. The transmission scenario of streaming media data between smart watch 101 and mobile phone 102 is, for example: when mobile phone 102 is taking a photo, the photo preview interface of mobile phone 102 is synchronously displayed on smart watch 101. In this case, mobile phone 102 needs to transmit video streaming data to smart watch 101 via Bluetooth, such as Figure 3 As another example, when the smartwatch 101 is playing music, the audio stream can be transmitted to the mobile phone 102 via Bluetooth, as shown in FIG. Figure 4 shown.

[0118] The instruction data is generally small and requires high real-time transmission. For example, see the scenario where the smart watch 101 transmits instruction data to the mobile phone 102. Figure 5 , when the mobile phone 102 is playing audio or video, the user can control the playback through the smart watch 101. Specifically, the user can input the playback control command on the smart watch 101, and the smart watch 101 sends the playback control command to the mobile phone 102 via Bluetooth, and the mobile phone 102 responds to the playback control command. The playback command is, for example, to play the previous song, play the next song, pause the playback, or adjust the volume, etc. Figure 5 Take the instruction to play the next song as an example. For another example, when the mobile phone 102 is taking a photo, the user can control the photo taking through the smart watch 101. Specifically, the user enters the photo taking instruction on the smart watch 101, and the smart watch 101 sends the photo taking instruction to the mobile phone 102 via Bluetooth. The mobile phone 102 responds to the photo taking instruction and takes the photo.

[0119] It is understandable that when two electronic devices transmit data via Bluetooth, there are scenarios where multiple services are transmitted concurrently. In other words, multiple business data may be sent at the same time. For example, while a watch transmits motion data to a mobile phone via Bluetooth, it also needs to transmit playback control instructions to the mobile phone via Bluetooth. For another example, while a watch transmits photos taken to a mobile phone via Bluetooth, it also needs to transmit audio stream data to the mobile phone via Bluetooth. Due to the limited bandwidth of Bluetooth, in scenarios where multiple services are transmitted concurrently, multiple services need to share the Bluetooth link.

[0120] In related technologies, when multiple services share a Bluetooth link, multiple services compete fairly for transmission resources. Figure 6 FIG1 shows a schematic diagram of a transmission model of a multi-service shared Bluetooth link in the related art. Figure 6 As shown, continuing with the example of smartwatch 101 and mobile phone 102, smartwatch 101 needs to send the business data of application (APP) A, application B, and application C to mobile phone 102 at the same time. Smartwatch 101 can respectively establish a sending queue A corresponding to application A, a sending queue B corresponding to application B, and a sending queue C corresponding to 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. Afterwards, the sending thread in smartwatch 101 polls sending queue A, sending queue B, and sending queue C, and sends the data in each sending queue to mobile phone 102 via Bluetooth according to the first-in-first-out principle.

[0121] The polling mechanism ensures that each service has relatively equal transmission opportunities. However, as analyzed above, data packets have different uses and different real-time requirements. Sending data using the polling mechanism results in a large amount of data with low real-time requirements being sent over a period of time, blocking data with high timeliness requirements. This, in turn, impacts some services with high real-time requirements, resulting in user-side lags such as unresponsive or slow interactions, impacting the user experience.

[0122] by Figure 5 The example shown is of a user controlling music playback on a mobile phone 102 via smartwatch 101. The user enters a control command to play the next song on smartwatch 101. The music control application on the smartwatch adds the control command data to the music control application's corresponding send queue. Simultaneously, the fitness app on smartwatch 101 also caches the motion trajectory data in the fitness app's corresponding send queue. Using a polling mechanism, the sending thread first retrieves the motion data from the fitness app's send queue and then sends the motion trajectory data to mobile phone 102 via Bluetooth. Because the motion trajectory data is large, it takes a long time to transmit, and the next song control command data is blocked. After a period of time, the motion trajectory data is sent, and the sending thread retrieves the next song control command data from the control application's send queue and sends it to mobile phone 102 via Bluetooth. This results in a significant delay in the next song control command data, which takes a long time to be transmitted to mobile phone 102. This delay causes a delay in controlling music playback, resulting in perceived lag and a poor user experience.

[0123] In view of this, an embodiment of the present application provides a data sending method, which establishes a priority queue mechanism and adds data to a sending queue of corresponding priority according to the real-time requirements of the data. Among them, the higher the real-time requirement, the higher the priority of the sending queue to be added. When sending data, data is obtained and sent from each sending queue in order from high to low priority, that is, data with higher real-time requirements are sent first. In this way, data with high real-time requirements are prevented from being blocked, the delay of these data is reduced, and the timeliness of sending is guaranteed, thereby preventing business jams, improving the stability and transmission performance of Bluetooth transmission, and improving user experience. In addition, after the data with higher real-time requirements is sent, the data with lower real-time requirements can also be sent in time, making full use of the Bluetooth bandwidth, improving bandwidth utilization, and improving the synchronization efficiency of data such as file data as much as possible, thereby improving user experience.

[0124] For example, Figure 7 This is a schematic diagram of the principle of a data sending method provided in an embodiment of the present 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 business data, each application determines the priority of the business data according to the type of business data (related to the real-time requirements), and adds the data to the corresponding sending queue according to the priority. The sending thread first sends the data in the high priority queue via Bluetooth, then sends the data in the medium priority queue via Bluetooth, and finally sends the data in the low priority queue via Bluetooth. In this way, data with higher real-time requirements in the high priority queue and the medium priority queue are prevented from being blocked, business jams are prevented, the stability and transmission performance of Bluetooth transmission are improved, and the user experience is improved.

[0125] It should be noted that the above description mainly uses the example of Bluetooth service transmission between a smartwatch and a mobile phone. In fact, the above-mentioned scenario of concurrent multi-service data transmission and the above-mentioned technical problems exist between any two electronic devices with Bluetooth functionality. Therefore, the method provided in the embodiments of the present application can be applied to any electronic device with Bluetooth functionality.

[0126] The structure of the electronic device provided in the embodiments of the present application is described below.

[0127] For example, Figure 81 is a structural diagram of an example of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 is, for example, a wearable device such as a smart watch, a sports bracelet, a smart wristband, smart glasses, a 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, a button 170, a display 171, a sensor module 180, and the like. The sensor module 180 may include an infrared light sensor 180A, a gyroscope sensor 180B, an acceleration sensor 180C, a touch sensor 180D, a photoplethysmography (PPG) heart rate sensor 180E, an ambient light sensor 180F, and the like.

[0128] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0129] The processor 110 may include one or more processing units. For example, the processor 110 may include 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. The different processing units may be independent devices or integrated into one or more processors. The controller may generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.

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

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

[0132] It is understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is merely an illustrative illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.

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

[0134] That is to say, the wireless communication module 150 can realize short-range wireless communication, or in other words, the wireless communication module 150 includes a short-range wireless communication module. In an embodiment of the present application, the electronic device 100 can perform short-range wireless communication with the terminal device based on the short-range wireless communication protocol through the wireless communication module 150. For example, a Bluetooth connection is established based on the Bluetooth protocol with a mobile phone through the wireless communication module 150, and data is transmitted based on the Bluetooth connection. The wireless communication module 150 may include a Bluetooth module (also called a Bluetooth device), and the Bluetooth device may be a classic Bluetooth device, a BLE Bluetooth device, or a dual-mode Bluetooth device. The embodiment of the present application does not impose any limitation on this.

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

[0136] The wireless communication module 150 can be one or more devices that integrate at least one communication processing module. The wireless communication module 150 receives electromagnetic waves via an antenna, frequency-modulates and filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 150 can also receive signals to be transmitted from the processor 110, frequency-modulate them, amplify them, and convert them into electromagnetic waves for radiation via the antenna.

[0137] The infrared light sensor 180A is a sensor that uses infrared rays for data processing. It is used to sense certain characteristics of the surrounding environment. It can also be used to measure the heat emitted by the human body and detect motion.

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

[0139] Accelerometer 180C can detect the magnitude of acceleration of electronic device 100 in all directions (generally three axes). It can also detect the magnitude and direction of gravity when electronic device 100 is stationary. It can also be used to identify the electronic device's posture, for applications such as pedometers and motion status feedback.

[0140] The touch sensor 180D is also called a "touch panel". The touch sensor 180D can be set on the display screen 171. The touch sensor 180D and the display screen 171 form a touch screen, also called a "touch screen". The touch sensor 180D is used to detect touch operations acting on or near it. The touch sensor 180D can pass 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 the display screen 171. In other embodiments, the touch sensor 180D can also be set on the surface of the electronic device 100, at a different location from the display screen 171, for example, on the side of the dial of a smart watch.

[0141] The PPG heart rate sensor 180E detects the intensity of reflected light absorbed by human blood and tissue, charting changes in vascular volume during the cardiac cycle. This produces a pulse waveform, which is then used to calculate heart rate. The PPG heart rate sensor 180E is used to monitor user health.

[0142] Ambient light sensor 180F is used to sense ambient light brightness. Electronic device 100 can adaptively adjust the brightness of display screen 194 based on the perceived ambient light brightness. Ambient light sensor 180F can also be used to automatically adjust white balance when taking photos. Ambient light sensor 180F can also cooperate with a proximity light sensor (not shown) to detect whether electronic device 100 is being worn.

[0143] For example, Figure 92 is a schematic diagram of the structure of an electronic device 200 provided in an embodiment of the present 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, an earphone jack 270D, a sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display 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, an air pressure sensor 280C, a magnetic sensor 280D, an acceleration sensor 280E, a distance sensor 280F, a proximity light 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 should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 200. In other embodiments of the present application, the electronic device 200 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0145] The processor 210 may include one or more processing units. For example, the processor 210 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.

[0146] The controller may be the nerve center and command center of the electronic device 200. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0147] Processor 210 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 210 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 210. If processor 210 needs to use the same instruction or data again, it can directly retrieve it from the memory. This avoids duplicate accesses, reduces processor 210 latency, and thus improves system efficiency.

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

[0149] The wireless communication module 260 can provide wireless communication solutions 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), infrared (IR), etc., which are applied to the electronic device 200. 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 the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 210. The wireless communication module 260 can also receive the signal to be sent from the processor 210, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0150] That is to say, the wireless communication module 260 can realize short-range wireless communication, or in other words, the wireless communication module 260 includes a short-range wireless communication module. In the embodiment of the present application, 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 the short-range wireless communication connection. Optionally, the wireless communication module 260 may include a Bluetooth module (also called a Bluetooth device), and the Bluetooth module may be a classic Bluetooth device, a BLE Bluetooth device, or a dual-mode Bluetooth device. The embodiment of the present application does not impose any limitation on this.

[0151] The electronic device 100 and the electronic device 200 run an operating system on top of the above components. Among them, the electronic device 100 can run a lightweight operating system such as the Watch OS operating system, Hongmeng system, or RTOS. The electronic device 200 can run an iOS operating system, an Android open source operating system, or a Windows operating system. The software system of the electronic device 100 and the electronic device 200 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a microservice architecture, or a cloud architecture. The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces.

[0152] For example, Figure 10 Schematic diagram of the software architecture of an electronic device 100 provided in an embodiment of the present application. Figure 10 As shown, the electronic device 100 is a wearable device, and an RTOS operating system is run in the electronic device 100. The RTOS operating system may include an application layer, a system service layer, a kernel layer, and a driver layer from top to bottom.

[0153] The application layer may include a series of applications, such as camera, gallery, music, camera control, music control, sports health, etc., which are business applications (also referred to as business applications) for realizing business functions. The application layer program can realize specific functions by calling the interfaces of the system service layer and the kernel layer. It should be noted that the names of the applications provided in the embodiments of the present application are only used as examples to illustrate the business functions that the applications can realize, and do not limit the applications. In fact, these applications can be separately set applications or units integrated in other applications or other modules, and there is no limitation on this.

[0154] Each business application can trigger the transmission of data to other devices via Bluetooth. For ease of explanation, the other device that receives the transmitted data is referred to as the peer device. Specifically, the business application can obtain or generate a session message. 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 the embodiment of the present application, when generating a session message, the business application can prioritize the business data based on the type of business data to be transmitted. The business data can be transmitted in the form of data packets, hereinafter referred to as data packets.

[0155] like Figure 10As shown, in the embodiment of the present application, the application layer may further include a data transmission module, a Bluetooth module, a Wi-Fi module, etc. Among them, the data transmission module is used to transmit the data of 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 is, for example, a MagicLink application. Optionally, the data transmission module may include a session management and a sending engine.

[0157] Session management is used to manage and deliver session messages. For example, session management can deliver session messages to the sending engine via a send queue. In embodiments of the present application, session management can also pre-process data packets in session messages. This pre-processing includes, but is not limited to, setting measurement flags on data packets and fragmenting the data packets to produce data fragments. The measurement flag indicates whether to measure the sending rate or latency based on the detected data packets. Based on the priority flag, session management adds the data fragments to the corresponding priority queue.

[0158] The sending engine is used to obtain data fragments from each priority queue and send the data fragments to the Bluetooth module. Optionally, the sending engine can implement its functions through the sending thread. Figure 10 As shown, in an embodiment of the present 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 is used to wake up the sending unit and make the sending unit enter the working state from the dormant state. The rate management unit is used to estimate the current sending rate based on the sending rate and delay of the historical data packets. The estimated result is called the estimated sending rate or the first sending rate. The sending unit is used to estimate the amount of data that Bluetooth can send in the current quota period (called the estimated sending quota) based on the estimated sending rate provided by the rate management unit. The quota management unit is used to determine the initial sending quota in each quota period based on the estimated sending quota and the recovered sending quota or overdrawn sending quota of the previous quota period, and based on the initial sending quota, update and manage the sending quota according to the size of the data sent by the sending unit. The sending unit is also used to obtain data fragments from each priority queue in order from high to low queue priority, and determine whether to send the data fragments to the Bluetooth module based on the sending quota.

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

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

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

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

[0164] It should be noted that the above software architecture and modules are merely examples and do not limit the structure of the electronic device 100 .

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

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

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

[0168] The data transmission module may include session management and sending engine. Figure 10The functions of the corresponding modules in the electronic device 100 shown are the same and will not be described in detail here. It should be noted that the functions of the two modules in the electronic device 100 and the electronic device 200 are the same, mainly referring to the same implementation logic and the same main effects achieved, but the architecture, implementation method, and specific code of the two modules may be different. Specifically, the implementation of the module needs to match the operating system on which the module is installed, and the software can be adjusted in combination with the hardware structure of the electronic device.

[0169] The application framework layer provides an application programming interface (API) and programming framework for the 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, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0171] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.

[0172] Content providers are used to store and retrieve data and make it accessible to applications. Data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0173] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.

[0174] The phone manager is used to provide communication functions of the electronic device 200, such as management of call status (including answering, hanging up, etc.).

[0175] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0176] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.

[0177] The Android runtime includes the core library and the virtual machine. The Android runtime is responsible for scheduling and management of the Android system.

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

[0179] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.

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

[0181] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.

[0182] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[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 drawing engine for 2D drawings.

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

[0186] For ease of understanding, the following examples of this application will be described with Figures 8 to 11The electronic device shown in the structure is taken as an example, and Figure 12 Taking the application scenario shown in the figure as an example, the data sending method provided by the embodiment of the present application is specifically described. Figure 12 As shown, at a certain moment, the sports health APP in the smart watch 101 (also called the first electronic device) generates a sports data packet in the background, and the sports health APP needs to synchronize the sports data packet to the mobile phone 102 (also called the second electronic device) via Bluetooth, so that the mobile phone 102 can update the sports data (also called the first data, such as the number of steps) of its sports health APP or other APPs (such as the lock screen APP). At this time, the user is using the mobile phone 102 to take pictures, and controls the mobile phone 102 to take pictures through the camera control APP in the smart watch 101. Figure 12 As shown, the user clicks the photo control 1201 in the interface of the smart watch 101, and the smart watch 101 receives the photo command input by the user. The camera control app in the smart watch 101 generates a photo command data packet and needs to send the photo command data packet to the mobile phone 102 via Bluetooth, so that the mobile phone 102 responds to the photo command (also called second data) and performs the photo operation.

[0187] based on Figure 12 The application scenario shown in this application Figure 13 The process shown in FIG. 1 realizes data transmission. The execution subject of the method in this embodiment is a module in a smartwatch, and the following steps are not described one by one.

[0188] See also Figure 13 , the data sending method may include:

[0189] S101. The sports health APP determines that the corresponding priority is low priority according to the type of data in the sports data packet.

[0190] It is understood that the priority of data is also called the sending priority of data, which represents the order in which data is sent. In principle, high-priority data is sent first, and low-priority data is sent later. In the embodiments of the present application, the priority of data is related to the real-time requirement of the data. The higher the real-time requirement, the higher the priority of the data, and the lower the real-time requirement, the lower the priority of the data.

[0191] In one embodiment, the data priority may include three types, from high to low, namely, high priority, medium priority, and low priority. It should be noted that this is only an example of priority classification. In actual applications, more or fewer types of priorities may be classified according to needs. For example, in another embodiment, the priority may only include high priority and low priority.

[0192] Moreover, the above-mentioned method of distinguishing priorities is only an example. In other embodiments, the distinction can also be made in the form of, for example, first priority, second priority, third priority, or A priority, B priority, C priority, etc., which is not limited to this.

[0193] Optionally, a mapping table of data types and priorities can be pre-configured in each business application. 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 of the data to be sent. The data type can be determined according to a preset classification method. In one embodiment, the data can be divided into file data, instruction data, and streaming data as described in the above embodiment, wherein file data has low real-time requirements and corresponds to low priority; instruction data has high real-time requirements and corresponds to high priority; streaming data has a real-time requirement between file data and instruction data and corresponds to medium priority. In another embodiment, data classification can also be performed based on the business type corresponding to the data, wherein different business types may have different real-time requirements for data. For example, the data generated by a sports health app includes types such as motion synchronization data, trajectory synchronization data, heart rate synchronization data, remote control data, and manual refresh data. Among them, motion synchronization data, trajectory synchronization data, and heart rate synchronization data have low real-time requirements and correspond to low priority, while remote control data and manual refresh data have high real-time requirements and correspond to high priority.

[0194] In this embodiment, the data in the motion data packet is file data or motion synchronization data, and thus the corresponding priority is low.

[0195] S102 . The sports health APP adds a low priority tag (also called a second priority tag) to the data in the sports data packet.

[0196] S103 , the sports health APP generates a session message 1 , which includes a sports data packet.

[0197] S104. The sports health APP sends the session message 1 to the session management in the data transmission module.

[0198] S105 . The session manager fragments the motion data packet in the session message 1 to obtain multiple data fragments 1 (also referred to as second data fragments).

[0199] In this embodiment, the data packet is fragmented to divide the data in the data packet into multiple data fragments, which are sent multiple times according to the data fragments. This can prevent the data packet from being too large to be sent and improve the success rate and accuracy of the sending.

[0200] S106 , the session management adds each data shard 1 to the low priority queue in sequence according to the low priority mark of the data in the data shard 1 .

[0201] In the embodiment of the present application, the priority type of the sending queue corresponds to the priority type of the data, and the sending queue can include a high priority sending queue (referred to as high priority queue), a medium priority sending queue (referred to as priority queue), and a low priority sending queue (referred to as low priority queue). For ease of explanation, the high priority queue, the low priority queue, and the medium priority queue may be collectively referred to as priority queues below.

[0202] Furthermore, it is understood that the data fragments obtained by fragmenting a data packet have a certain order. Here, "adding the data fragments sequentially to the priority queue" means adding them sequentially according to the order of the data fragments. This prevents data fragments from being out of order and causing data confusion in the data packet, thereby ensuring accurate data transmission.

[0203] S107. The camera control APP determines that the corresponding priority is a high priority according to the type of data in the photo-taking instruction data packet.

[0204] This step is similar to step S101, except that in this step, the photographing instruction data is instruction 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 called a first priority tag) to the data in the photo-taking instruction data packet.

[0206] S109 , the camera control APP generates a session message 2 , wherein the session message 2 includes a photo taking instruction data packet.

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

[0208] S111. The session management performs fragmentation processing on the photo-taking instruction data packet in the session message 2 to obtain multiple data fragments 2 (also called first data fragments).

[0209] S112 , the session management adds each data shard 2 to the high priority queue in sequence according to the high priority mark of the data in the data shard 2 .

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

[0211] It should be noted that the motion data packet of the sports health APP and the photo-taking instruction data packet of the camera control APP are generated concurrently, so the execution order of the above steps S101 to S106 and steps S107 to S112 is not limited. The execution time between the steps can have a slight difference, or they can be executed simultaneously.

[0212] S113: The awakening unit in the sending engine sends a wake-up instruction to the sending unit, wherein the wake-up instruction is used to instruct the sending unit to enter a working state from a dormant state.

[0213] Optionally, the sending unit can work periodically and sleep for the rest of the time to prevent the sending unit from working continuously and causing the smart watch to consume too much power, thereby extending the standby time. Specifically, the sending unit wakes up once every preset sleep time 1, performs a data transfer task, and enters sleep when the data transfer task is completed or the wake-up time exceeds the preset time 2 (also called the first preset time). The specific values of the preset time 1 and the preset time 2 can be set according to demand. The preset time 1 and the preset time 2 may be equal or unequal. In a specific embodiment, for electronic devices such as wearable devices, the preset time 1 and the preset time 2 may be 20 milliseconds (ms), and for electronic devices such as mobile phones and tablets, the preset time 1 and the preset time 2 may be 6ms.

[0214] Specifically, when the sending unit enters the sleep state, timer 1 with a timing duration of preset duration 1 can be started. When timer 1 reaches the timing duration, the wake-up unit is triggered to send a wake-up instruction to the sending unit. The sending unit responds to the wake-up instruction, enters the working state, and performs related tasks. After the task is completed, the sending unit enters the sleep state again. Optionally, when the wake-up unit wakes up the sending unit, timer 2 with a timing duration of preset duration 2 can be started. When timer 2 reaches the timing duration, if the sending unit is still in the working state, the sending unit enters the sleep state. This can further prevent the sending unit from working for a long time, resulting in excessive power consumption of the smart watch, and extend the standby time.

[0215] For ease of description, in the embodiments of the present application, the period from the start of Timer 2 to the expiration of the timer duration, that is, the period from the time the sending unit enters the working state to the timer 2 expiration of the timer duration, is referred to as a sending cycle. In other words, the duration of a sending cycle is equal to the preset duration 2. The sending cycle in which the current moment occurs is referred to as the current sending cycle. The sending cycle before the current sending cycle is referred to as the previous sending cycle.

[0216] Of course, the function of the wake-up unit can also be completed by other functional modules in the smart watch, for example, through the timer management of the kernel layer, which is not limited.

[0217] S114. The sending unit obtains each data fragment 2 from the high priority queue in sequence in response to the wake-up instruction.

[0218] S115 , the sending unit sends each data fragment 2 to the Bluetooth module in sequence.

[0219] S116. The Bluetooth module sends each data fragment 2 to the mobile phone in sequence.

[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 sending engine. After receiving all data fragments 2 in the photo-taking command packet, the phone's sending engine, through the phone's session management, sends the photo-taking command packet to the corresponding service application, namely the camera app. Upon receiving the photo-taking command packet, the phone's camera app parses the packet, obtains the photo-taking command, and executes the command to capture the photo.

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

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

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

[0224] S119 , the sending unit sends each data fragment 1 to the Bluetooth module in sequence.

[0225] S120: The Bluetooth module sends each data fragment 1 to the mobile phone in sequence.

[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 sending engine. After receiving all data fragments 1 in the exercise data packet, the phone's sending engine uses the phone's session management to send the exercise data packet to the corresponding service application, namely the sports health app. Upon receiving the exercise data packet, the phone's sports health app parses the data packet, obtains the exercise data, and saves the exercise data.

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

[0228] As can be seen from steps S114 to S120, the sending unit obtains data fragments from each priority queue in descending order of priority and sends the data fragments to the Bluetooth module in sequence. It should be noted that each time the sending unit obtains a data fragment from the high-priority queue, if it is determined that the high-priority queue currently has no data, it then obtains a data fragment from the medium-priority queue. When it is determined that the medium-priority queue currently has no data, it then obtains a data fragment from the low-priority queue. This ensures that the data currently in the higher-priority queue is sent first, that is, data with higher real-time requirements is sent first.

[0229] The data sending method provided in the embodiment of the present application establishes a priority queue mechanism, prioritizes the data according to the type of data, and adds the data to the corresponding priority queue according to the priority. Among them, the higher the real-time performance, the higher the priority of the queue to be added. When sending data, data is obtained and sent from each priority queue in order from high to low priority, that is, data with higher real-time requirements are sent first. In this way, data with high real-time requirements are prevented from being blocked, the time delay of these data is reduced, and the timeliness of sending is guaranteed, thereby preventing business jams, improving the stability and transmission performance of Bluetooth transmission, and improving user experience. In addition, after the high-priority data is sent, the low-priority data can also be sent in time, making full use of the Bluetooth bandwidth, improving bandwidth utilization, and improving the synchronization efficiency of data such as file data as much as possible, thereby improving user experience.

[0230] As a possible implementation method, after each data fragment in the low-priority queue is sent, the sending unit can detect whether there is a data fragment in the high-priority queue and the medium-priority queue. If there is a data fragment in the high-priority queue and / or the medium-priority queue, the data fragments in the high-priority queue and then the medium-priority queue are sent according to the above process, and then the next data fragment in the low-priority queue is sent. The data in the low-priority queue is generally large, and it takes a long time to send the data in the low-priority queue. Therefore, this method can prevent the continuous sending of data in the low-priority queue from taking up too much time and too many Bluetooth link resources, prevent high-priority and low-priority data from being blocked, prevent the occurrence of freezes, and improve the user experience.

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

[0232] In the embodiments of the present application, considering the limited Bluetooth bandwidth, sending too much or too large data at a time can easily cause Bluetooth link congestion. Therefore, the sending quota of the Bluetooth link is used to control the amount of data sent to prevent Bluetooth link congestion. At the same time, combined with the sending quota, bandwidth is reasonably allocated to data of different priorities, preventing Bluetooth link congestion while also preventing bandwidth waste, thereby improving service transmission performance and stability. The sending quota can be understood as the accumulation of Bluetooth link bandwidth within a certain period of time, that is, the amount of data that can be sent by the Bluetooth link within a certain period of time.

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

[0234] In the embodiments of the present application, historical data transmission can be used to more accurately estimate the Bluetooth transmission rate for the current and future periods, thereby enabling a more accurate and instructive estimation of the transmission quota. It is understood that overestimating the transmission quota will lead to link congestion, while underestimating the transmission quota will lead to bandwidth waste. Therefore, in this embodiment, accurately estimating the transmission quota can enable more accurate bandwidth allocation and management, prevent link congestion, and prevent bandwidth waste, thereby improving service transmission performance and stability.

[0235] Optionally, a time length can be preset for the current and future period of time, and the sending quota is re-estimated once every interval of this time length. In an embodiment of the present application, a period of time of a preset time length is referred to as a quota period, and this preset time length is referred to as the duration of the quota period. The sending quota estimated in each quota period can be understood as the sending quota allocated by the electronic device to the sending unit, and the sending quota represents the amount of data that the Bluetooth link is expected to send within this quota period. For ease of description, the quota period at the current moment is referred to as the current quota period, and the quota period before the current quota period and adjacent to the current quota period is referred to as the previous quota period. The quota period after the current quota period and adjacent to the current quota period is referred to as the next quota period.

[0236] In one embodiment of the present application, while the sending unit is sending data, the quota management unit may reduce the sending quota for the current quota period based on the size of the data being sent. This process is also referred to as consuming quota or consuming quota. Optionally, when the remaining sending quota is small, the quota management unit may reclaim the remaining small quota and use it for data sending in the next quota period. This process is referred to as reclaiming quota or quota reclaiming. Alternatively, the quota management unit may pre-overdraw a portion of the sending quota for the next quota period to prioritize data sending. This process is referred to as overdrawing quota or quota overdraft.

[0237] Based on this, for the current quota period, a total sending quota available for the current quota period can be calculated based on the estimated sending quota, the sending quota recovered in the previous quota period, or the sending quota overdrawn in the previous quota period. This total sending quota is also the available Bluetooth resources in the current quota period before any data is sent, and is therefore referred to as the initial sending quota for the current quota period in this embodiment of the application. The quota management module updates the initial sending quota once per quota period.

[0238] In the embodiment of the present application, based on the estimated sending quota, combined with the operations of consumption quota, recovery quota, and through-use quota, bandwidth can be accurately managed and allocated. On the one hand, it can prevent Bluetooth link congestion, thereby reducing latency and increasing the sending rate. On the other hand, it can prevent bandwidth waste.

[0239] The following is a more detailed description with reference to the accompanying drawings. Figure 13 In the illustrated embodiment, steps S114 to S120 are described using two specific data shards as examples. In this embodiment, in order to reflect the universality of the method, data shard 1 and data shard 2 are no longer used as examples for description, but the processing methods corresponding to data shards of various priorities are described one by one.

[0240] For ease of understanding, the method of this embodiment is divided into four processes: a quota update process, a congestion query process, a sleep process, and a data transmission process. The quota update process is used to implement regular updates of the transmission quota. The congestion query process is used to determine whether the Bluetooth module is blocked before sending data to prevent data overflow in the Bluetooth module. The data transmission process is used to send 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 is described below.

[0241] 1. Quota Update Process

[0242] For example, Figure 14 A flow chart of another data transmission method provided in an embodiment of the present application is shown as follows: Figure 14As shown, in this method, the process of the sending unit updating the sending quota may include:

[0243] S201. The sending unit in the sending engine responds to the wake-up instruction sent by the wake-up unit to determine whether the time from the current moment to the last update of the sending quota exceeds the quota period; if so, execute step S202; if not, execute step S208 and enter the blocking query process.

[0244] That is to say, it is determined 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, step S208 is executed, and the blocking query process is entered.

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

[0246] In a specific embodiment, the duration of the quota period can be equal to several times (an integer multiple 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 20 ms as an example, the duration of the quota period can be 100 ms or 120 ms. It is understood that the longer the quota period is set, the larger the calculated transmission quota will be. Allocating bandwidth based on the transmission quota may result in a higher data transmission rate. However, the Bluetooth transmission rate is constantly changing. Therefore, if the quota period is too long, the quota estimation will be less accurate. Therefore, in this embodiment, a multiple of the transmission period is used as the quota period. The calculated transmission quota is larger than that of 1 times the transmission period. This can prevent the transmission quota from being too low, thereby preventing the data transmission rate from being too low, preventing lags, improving data transmission performance, and enhancing user experience. Furthermore, the calculated transmission quota will not be too large, thus ensuring the accuracy of quota estimation, thereby improving the accuracy of bandwidth allocation, and enhancing data transmission performance and stability. On the other hand, the sending quota is determined based on the estimated sending rate, using a multiple of the sending period as the quota 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 larger data can be sent, prevents the situation where data cannot be sent due to an extremely low sending quota estimate, improves data transmission performance and stability, and enhances user experience.

[0247] In addition, the duration of the quota cycle is set to an integer multiple of the sending cycle duration. In this way, each time the sending unit is awakened, a quota update judgment is triggered, which facilitates timely updating of the sending quota and improves the accuracy of sending quota management. There is no need for additional processes to trigger quota update judgments, and there is no need to wake up the sending unit additionally, which further saves power consumption and extends the standby time of electronic devices.

[0248] S202: The sending unit obtains an estimated sending rate from the rate management unit.

[0249] The rate management unit can calculate the transmission rate and / or latency based on the information of historical data packets and determine an estimated transmission rate based on the transmission rate and / or latency. The historical data refers to the data packets sent by the Bluetooth module via Bluetooth during a historical time period. It will be appreciated that as the number of transmitted data packets changes over time, the calculated estimated transmission rate may also change. Therefore, the rate management unit can continuously update the estimated transmission rate. The process of calculating and updating the estimated transmission rate by the rate management unit will be further described in subsequent embodiments.

[0250] S203: The sending unit calculates the estimated sending quota for the current quota period according to the estimated sending rate and the quota period.

[0251] The estimated send quota indicates the amount of data that the Bluetooth module can send at the estimated send rate for one quota period.

[0252] Optionally, the sending unit may 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 an 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 recovery was performed in the previous quota period, the sum of the estimated sending quota for the current quota period and the sending quota recovered in the previous quota period can be calculated to obtain the initial sending quota for the current quota period; if quota overdraft was performed in the previous quota period, the sum of the estimated sending quota for the current quota period and the sending quota overdrawn in the previous quota period can be calculated to obtain the initial sending quota for the current quota period.

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

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

[0258] S207, the sending unit determines whether the initial sending quota is greater than 0; if so, execute step S208 to enter the blocking query process; if not, execute S210 to enter the dormant process.

[0259] It is understood that if the estimated sending rate determined based on historical data transmission is 0, and there was no quota recovery or a quota overdraft in the previous quota period, the calculated initial sending quota for the current quota period may be 0 or negative. Furthermore, if the estimated sending rate determined based on historical data transmission is very low, and there was a quota overdraft in the previous quota period, the calculated initial sending quota for the current quota period may be 0 or negative. This situation is particularly common for thin systems such as wearable devices, where bandwidth is limited. In this case, without available Bluetooth resources, sending data may cause data congestion, impacting Bluetooth transmission performance and user experience. Therefore, in this step, after determining the initial sending quota, a determination is made as to whether the initial sending quota is greater than 0. If the initial sending quota is greater than 0, indicating that Bluetooth resources are currently available and data can be sent, step S208 and subsequent steps are executed to query for congestion and send data. If the initial sending quota is less than or equal to 0, step S210 is executed, and the sending unit stops sending data and enters a dormant state. In this way, data blocking can be prevented and the stability of the system can be guaranteed.

[0260] 2. Blocking the query process

[0261] Continue to see Figure 14 In one embodiment, the blocking query process may include:

[0262] S208: The sending unit queries the Bluetooth module for congestion.

[0263] Specifically, the sending unit may send a blocking query request to the Bluetooth module. In response to the blocking query request, the Bluetooth module determines whether there is data currently queued for transmission in its buffer queue. If so, the Bluetooth module is currently blocked; if not, the Bluetooth module is currently unblocked. The Bluetooth module then sends the query result to the sending unit.

[0264] S209, the sending unit determines whether the query result is that the Bluetooth module is blocked; if so, execute step S210 to enter the sleep process; if not, execute step S301 to enter the data sending process.

[0265] If the Bluetooth module is blocked, it means that there is data in the buffer queue of the Bluetooth module. If more data is sent, data overflow may occur, resulting in service interruption and system performance degradation.

[0266] Therefore, in this embodiment, the sending unit executes the data transmission process when the Bluetooth module is not blocked. If the Bluetooth module is blocked, step S210 is executed, and the sending unit directly enters a dormant state and does not send data to the Bluetooth module. This prevents data overflow in the Bluetooth module's buffer queue and ensures system stability.

[0267] 3. Dormant process

[0268] Continue to see Figure 14 In one embodiment, the sleep process may include:

[0269] S210: The sending unit enters a dormant state and starts timer 1.

[0270] The sending unit enters the dormant state, and the sending engine task process ends. When timer 1 reaches the timer duration, the wake-up unit executes step S113 again and sends a wake-up instruction to the sending unit to enter the next sending cycle. This cycle repeats.

[0271] 4. Data sending process

[0272] For example, Figure 15 A flow chart of another data transmission method provided in an embodiment of the present application is shown as follows: Figure 15 As shown, the data sending process may include:

[0273] 1) High priority data sending 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 so, execute step S302; if not, execute step S401 and enter the medium-priority data sending process.

[0275] It can be understood that each time the sending unit obtains data from a certain priority queue, there may or may not be data in the priority queue. The absence of data may be that the data has not been added to the priority queue, or the added data may be temporarily sent. In an embodiment of the present application, before obtaining a data fragment from a certain priority queue, it can be determined whether there is a data fragment in the priority queue; for a high priority queue or a medium priority queue, if there is no data therein, the sending process of the next priority data is entered; if there is a data fragment, according to the first-in-first-out principle, a data fragment is obtained from the priority queue, and the sending operation is performed, and then the next data fragment in the priority queue is obtained, until all data fragments are sent, that is, there is no data fragment in the priority queue. For a low priority queue, if there is no data therein, the sleep process is entered.

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

[0277] S302: The sending unit obtains a high-priority data slice 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 quota as the sending unit sends various data fragments and continuously updates the sending quota. For ease of description, the sending quota at the current moment is referred to as the current sending quota. In essence, the current sending quota can be understood as the sending quota remaining after the initial sending quota of the current quota period has been consumed. The current sending quota represents the amount of data that the Bluetooth module is expected to send from the current moment to the end of the current quota period.

[0280] It should be understood that after the initial sending quota is calculated, before the first data fragment of the current quota period is sent, the current sending quota is equal to the initial sending quota; after the last data fragment of the current quota period is sent, the current sending quota is equal to the recovered 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 segment; if so, executes steps S305 to S307 to send the high-priority data segment and consumes the quota; if not, executes steps S308 to S314 to further determine whether to send the high-priority data segment.

[0282] If the current sending quota is greater than or equal to the size of the high-priority data slice, it indicates that the current sending quota is sufficient to send the high-priority data slice. Therefore, steps S305 to S307 can be executed to directly send the high-priority data slice and consume the quota. If the current sending quota is less than the size of the high-priority data slice, it indicates that the current sending quota is insufficient to send the high-priority data slice. Then, steps S308 to S314 are executed to further consider the relationship between the size of the data slice and the size of the current sending quota. The decision is whether to send the data slice using the quota or to enter a dormant state and wait for the next sending cycle to trigger a sending quota update before sending the data slice.

[0283] S305: The sending unit sends the high priority data fragments to the Bluetooth module.

[0284] After receiving the high-priority data fragment, the Bluetooth module sends the high-priority data fragment to the peer device, which will not be described in detail here. Figure 15 Not shown in the figure.

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

[0286] Specifically, the sending unit may send a quota consumption message to the quota management unit. The quota consumption message is used to indicate the consumption of the quota. The quota consumption message may carry the size of the quota to be consumed, that is, the size of the data slice currently being sent. Specifically, in the current step, the quota consumption message carries the size of the high-priority data slice.

[0287] S307: The quota management unit consumes the sending quota in response to the notification of the sending unit, and updates the current sending quota, and then returns to step S301.

[0288] Specifically, consuming the sending quota means reducing the value of the sending quota. The quota management unit can calculate the difference between the current sending quota and the size of the data fragment to be sent to obtain the sending quota after consumption. The current sending quota is updated to the sending quota after consumption. That is:

[0289] The updated sending quota = the sending quota before the update - the size of the data fragment to be sent.

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

[0291] S308. The sending unit determines whether the current sending quota is greater than n1% of the size of the high-priority data segment; if so, execute steps S309 to S311 and S210 to send the high-priority data segment and overdraw the sending quota, and then enter the sleep process; if not, execute steps S312 to S314 and S210 to cancel the sending of the high-priority data segment, reclaim the sending quota, and then enter the sleep process.

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

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

[0294] If the current sending quota is less than or equal to n1% of the size of the high-priority data fragment, it means that the size gap between the current sending quota and the high-priority data fragment is large (i.e., the high-priority data fragment is large). Even if the high-priority data fragment is sent through the quota, it may cause data congestion or even overflow, resulting in greater delay and affecting user experience. Therefore, the sending of the high-priority data fragment is abandoned, and steps S312 to S314 are executed to re-add the high-priority data fragment to the high-priority queue and reclaim the sending quota. Thereafter, step S210 is executed to put the sending unit into a dormant state, and the data fragment is sent again after the next sending cycle triggers the sending quota update. In other words, when the sending quota is small, the sending of the larger data fragment is abandoned to prevent the larger data fragment from blocking or even overflowing the Bluetooth module, thereby ensuring the stability and reliability of data transmission.

[0295] S309: The sending unit sends the high priority data fragments to the Bluetooth module.

[0296] After receiving the high-priority data fragment, the Bluetooth module sends the high-priority data fragment to the peer device, which will not be described in detail here. Figure 15 Not shown in the figure.

[0297] S310: The sending unit notifies the quota management unit to overdraw the sending quota.

[0298] Optionally, the sending unit may send a quota overdraft message to the quota management unit. The quota overdraft message is used to indicate the overdrawn quota. The quota overdraft message may carry the size of the quota to be overdrawn, that is, the size of the currently sent data slice. Specifically, in the current step, the overdraft consumption message carries the size of the high-priority data slice.

[0299] S311 : The quota management unit responds to the notification of the sending unit and overdraws the sending quota according to the size of the high-priority data slice.

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

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

[0302] It can be understood that the sending unit obtains data fragments from each priority queue according to the first-in-first-out principle. Therefore, when a data fragment is canceled from being sent, the data fragment is added to the priority queue again and placed at the first place in the priority queue, so that the data fragment can be obtained first from the priority queue during the next sending, thereby ensuring the correct transmission order of the data packets and improving 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 recovery message to the quota management unit, where the quota recovery message is used to indicate the recovery of the quota.

[0305] S314: The quota management unit reclaims the sending quota in response to the notification from the sending unit.

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

[0307] 2) Medium priority queue data sending process

[0308] For example, Figure 16 A flow chart of another data transmission method provided in an embodiment of the present application is shown as follows: 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 so, execute step S402; if not, execute step S501 and enter the high-priority data sending process.

[0310] That is, the sending unit determines whether there is a data fragment in the medium priority queue. If there is a data fragment in the medium priority queue, the following steps S402 and subsequent steps are executed to send the data fragment in the medium priority queue; if there is no data fragment in the medium priority queue, step S501 is executed 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 so, executes steps S405 to S407 to send the medium-priority data fragment and consumes the quota; if not, executes steps S408 to S414 to further determine whether to send the medium-priority data fragment.

[0314] S405: The sending unit sends the medium priority data fragments to the Bluetooth module.

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

[0316] S407: The quota management unit consumes the sending quota in response to the notification of the sending unit, and updates the current sending quota, and then returns to step S401.

[0317] After step S407, the process returns to step S401. This process is repeated to send each data fragment in the medium priority queue until there are no data fragments in the medium priority queue (i.e., the result of step S401 is no), or the sending quota is consumed and insufficient to send medium priority data fragments (i.e., the result of step S404 is no).

[0318] S408. The sending unit determines whether the current sending quota is greater than n2% of the size of the medium-priority data segment; if so, execute steps S409 to S411 and S210 to send the medium-priority data segment and overdraw the sending quota, and then enter the sleep process; if not, execute steps S412 to S414 and S210 to cancel the sending of the medium-priority data segment, reclaim the sending quota, and then enter 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. Optionally, n2 can be equal to or different from n1. In one embodiment, n2 can be greater than n1. That is to say, the threshold for sending medium-priority data slices within the overdraft quota is higher than that for sending high-priority data. In this way, high-priority data slices are sent as much as possible, and when sending medium-priority data slices, while considering the real-time sending, it is also necessary to prevent excessive overdraft of the sending quota of the next quota period, prevent affecting the sending of high-priority data slices of the next quota period, prevent freezes, and improve user experience.

[0320] S409: The sending unit sends the medium priority data fragments to the Bluetooth module.

[0321] S410: The sending unit notifies the quota management unit to overdraw the sending quota.

[0322] S411 : The quota management unit responds to the notification of the sending unit and overdraws 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 reclaims the sending quota in response to the notification from the sending unit.

[0326] The logic of the medium priority data sending process is similar to that of the high priority data sending process. For details, please refer to Figure 15 The description in the illustrated embodiment will not be repeated here.

[0327] 3) Low priority data sending process

[0328] For example, Figure 17 A flow chart of another data transmission method provided in an embodiment of the present application is shown as follows: 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 so, execute step S502; if not, execute step S210 and enter the sleep process.

[0330] That is to say, the sending unit determines whether there are data fragments in the low-priority queue. If there are data fragments in the low-priority queue, the following steps S402 and subsequent steps are executed to send the data fragments in the low-priority queue; if there are no data fragments in the low-priority queue, step S210 is executed 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 segment; if so, execute steps S505 to S507 to send the low-priority data segment and consume the quota; if not, execute steps S508 to S510 and S210 to cancel the sending of the low-priority data segment, reclaim the sending quota, and then enter the sleep process.

[0334] S505: The sending unit sends the 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: The quota management unit consumes the sending quota in response to the notification of the sending unit, and updates the current sending quota, and then returns to step S301.

[0337] As mentioned above, high-priority data packets are generally larger, so fragmentation results in a larger number of low-priority data fragments. Sending all the data fragments stored in the low-priority queue continuously can take a long time. During this transmission process, the business 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 the electronic device to freeze.

[0338] Based on this consideration, in an embodiment of the present application, after each low-priority data fragment is sent, the high-priority data sending process and the medium-priority sending process are returned to be executed once, so as to check whether there are 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 the data fragments in these two priority queues are sent, the low-priority data sending process will be entered again according to the logic (i.e., step S501 will be executed again) to send the next low-priority data fragment. If not, according to the above logic, the process will also enter the low-priority data sending process (i.e., step S501 will be 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 being stuck, and improve user experience.

[0339] S508. The sending unit adds the low-priority data fragment 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 reclaims the sending quota in response to the notification of the sending unit, and then executes step S210.

[0342] In addition, it is worth noting that in the low-priority data sending process, if the current sending quota is smaller than the size of the low-priority data fragment, the low-priority data fragment can be sent without using the transparent quota. Instead, the sending of the low-priority data fragment can be directly canceled, the quota can be recovered, and the system can then enter a dormant state. This is because low-priority data does not have high real-time requirements. On the one hand, it prevents low-priority data fragments from forming data congestion and affecting the sending of high- and medium-priority data in the next sending cycle. On the other hand, it can also save the sending quota and use it for the next quota cycle to give priority to sending subsequent high- and medium-priority data, further ensuring that these data are sent in a timely manner, preventing electronic devices from freezing, and improving the user experience.

[0343] And, as can be seen from the above process, only when the current sending quota is not enough to send data fragmentation (the judged result of step S308, S408 is no), that is, when the sending quota remains less, the remaining sending quota is reclaimed.When the current sending quota is enough to send data fragmentation (the judged result of step S308, S408 is yes), that is, when the sending quota remains more, after data fragmentation is sent, once again return to the data transmission process of former priority (returning execution in step S301, S401), through judging, in each priority queue, all do not have under the situation of data fragmentation, directly enter dormant state, do not reclaim for remaining sending quota. This is to consider, if sending quota remains under the situation of more, sending quota is reclaimed, the sending quota of each quota cycle can be made to accumulate gradually, cause sending quota to be too high, exceed the actual corresponding sending quota of bluetooth bandwidth, this belongs to false sending quota, can cause follow-up to be inaccurate to bandwidth allocation result, and sending rate control is inaccurate, thereby causes bluetooth transmission performance to be unstable. In other words, in the embodiment of the present application, the sending quota may be recycled only when there is less sending quota remaining. This can prevent the sending quota from becoming too high as the quota cycle continues to accumulate, prevent the occurrence of false sending quotas, improve the accuracy of the sending quota calculation, thereby improving the accuracy of bandwidth allocation and control, and further improving the accuracy of Bluetooth transmission performance.

[0344] The following describes the process of determining the estimated sending rate.

[0345] As described in the above embodiment, the Bluetooth transmission rate is significantly affected by the air interface environment, making it impossible to use a fixed transmission rate value to estimate the current transmission rate. Therefore, in the embodiment of the present application, the current transmission rate is estimated by measuring the transmission rate of historical data. Furthermore, in the embodiment of the present application, given the limited Bluetooth bandwidth, measuring the transmission rate using additional test data would consume additional air interface resources. Therefore, measuring the transmission rate using historical data sent by business applications does not consume additional Bluetooth air interface resources and bandwidth, thus conserving resources.

[0346] Furthermore, the inventors discovered that the size of data packets sent by business applications is highly random, and it is possible for only small data packets to be sent for extended periods. Small data packets cannot reflect Bluetooth's true transmission rate, meaning that transmission data measured based on small data packets is inaccurate. Therefore, in an embodiment of the present application, the size of the data packet is determined. If the packet is large, the rate is measured using that packet; if no large data packet exists, the data latency is measured using smaller data packets. Determining the transmission rate based on latency improves the accuracy of transmission rate measurements, thereby improving the accuracy of Bluetooth bandwidth allocation.

[0347] The following is a description with reference to the accompanying drawings.

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

[0349] S601: Service application A in electronic device A determines a corresponding priority according to the type of data in data packet A.

[0350] S602: Service application A in electronic device A adds a priority tag to data in data packet A.

[0351] S603: Business application A in electronic device A generates session message A, where session message A includes data packet A.

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

[0353] S605: The session management in electronic device A changes the size of data packet A to D send Sent to the rate management unit.

[0354] S606: The session management in electronic device A sets a measurement mark to data packet A according to the size of data packet A.

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

[0356] Specifically, the session management system may 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, the data packet is marked with a speed measurement flag; if the size of the data packet is less than the second threshold, the data packet is marked with a delay measurement flag. In a specific embodiment, the first threshold may be 16 kB, and the second threshold may be 980 kB.

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

[0358] As a possible implementation, the order of step S606 and step S607 can be reversed, i.e., fragmentation is performed first, and then the measurement tag is added to the first data fragment. This is not specifically limited. In other words, session management can first add a measurement tag to data packet A based on its size, then fragment it, and continue to add the measurement tag to the first data fragment A1 obtained after fragmentation. Alternatively, session management can first determine the size of data packet A, then fragment it, and then, based on the size of data packet A, set the measurement tag to the first data fragment A1 obtained after fragmentation.

[0359] It is understood that the first data fragment A1 refers to the data fragment that is first in the sending order after the data packet A is fragmented. It is understood that the sending time of the first data fragment A1 is also the sending time of the data packet A.

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

[0361] Priority queue A is a high priority queue, a medium priority queue, or a low priority queue.

[0362] S609: The wake-up unit in the sending engine in the electronic device A sends a wake-up instruction to the sending unit.

[0363] S610. The sending unit in electronic device A responds to the wake-up instruction and obtains data slices from each priority queue in descending order of priority, wherein data slice A is obtained from priority queue A.

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

[0365] S612: The sending unit in the electronic device A sends the data fragment A1 and other data fragments A to the Bluetooth module in sequence, and manages the sending 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 sends data fragment A1 and other data fragments A in sequence to the Bluetooth module of electronic device B. The Bluetooth module of electronic device B then sends these data fragments A to the sending engine in the data transmission module of electronic device B.

[0368] S614: The sending unit in electronic device A records the sending time T of data segment A1. send .

[0369] That is, in the process of sending each data fragment A of data packet 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, which is recorded 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 sending unit in electronic device A receives the acknowledgment message corresponding to data packet A sent by electronic device B, and records the receiving time T of the acknowledgment message. recv and the size of the confirmation message D recv .

[0372] It can be understood that electronic device A sends each data fragment of a data packet to electronic device B in sequence via Bluetooth. When electronic device B receives all the data fragments of a data packet, it will reply a confirmation message (also referred to as ack message) to electronic device A via Bluetooth to notify electronic device A that it has received the data packet. Therefore, after electronic device A sends all the data fragments of data packet A, it will receive a confirmation message for data packet A sent by electronic device B. After electronic device A receives the confirmation message, it can record the time when the confirmation is received, which is called the reception time T recv At the same time, electronic device A can determine the size of the received confirmation information, which is recorded as D recv .

[0373] Specifically, when the sending engine in electronic device B confirms that all data fragments A in data packet A have been received, on the one hand, the sending engine in electronic device B sends data packet A to the session management, and 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 the data in data packet A, executing the instructions in data packet A, or displaying the interface according to the data in data packet A. On the other hand, the sending engine in electronic device B sends a confirmation message to the Bluetooth module in electronic device B. The Bluetooth module in electronic device B forwards the confirmation message to the Bluetooth module of electronic device A. The Bluetooth module in electronic device A forwards the confirmation message to the sending unit in the sending engine in electronic device A. In this way, the sending unit of electronic device A can know the reception time T of the confirmation message. recv and the size of the confirmation message D recv .

[0374] S616: The sending unit in the electronic device A receives the time T recv and the size of the confirmation message D recv Sent to the rate management unit.

[0375] S617: The sending unit in the electronic device A sends a packet to the device according to the size D of the packet A. send , the size of the confirmation message D recv , receiving time T recv and sending time T send , calculate the sending rate A.

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

[0377]

[0378] Among them, RATE represents the sending rate. It can be understood that D send +D recv The result is also called the third value, which represents the sum of the data size of the sent data packet A and the returned confirmation 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 a piece of data to be sent from the sending unit to the electronic device B and then return, that is, the round-trip time of the data. The result can be considered as the data rate sent by the Bluetooth module to electronic device B.

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

[0380] That is, the sending rate A is determined as the current latest estimated sending rate.

[0381] As you can understand, the closer the historical send rate is to the current time, the closer it is to the actual send rate. Furthermore, compared to estimating the send rate based on latency, the directly calculated send rate is more accurate. Therefore, each time the send rate is calculated, it is used as the latest estimated send rate, which improves the accuracy of the estimated send rate.

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

[0383] S620, the sending unit in the electronic device A receives the time T recv Sent to the rate management unit.

[0384] S621: The rate management unit in the electronic device A sends data based on the transmission time T. send and receiving time T recv , calculate the delay A (also called the first delay).

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

[0386]

[0387] Among them, RTT represents the time delay. It can be understood that T recv +T send It indicates the time it takes for a data to be sent from the sending unit to electronic device B and then return, that is, the round trip time of the data. recv +T send The result of dividing by 2 can be considered as the time duration for the Bluetooth module to send data to electronic device B (one-way), and thus, the result can be used as the delay.

[0388] S622. The rate management unit in electronic device A determines whether the time from the current moment to the last update of the estimated sending rate is greater than or equal to the rate update period; if so, execute step S623; if not, end the current sending rate calculation process.

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

[0390] The inventors discovered that delay is also affected by the air interface environment, and found that there is a certain relationship between delay and transmission rate. When the air interface environment interference is low, the delay is low and the transmission rate is high; when the air interface environment interference is high, the delay is high and the transmission rate is low. Based on this, this embodiment provides a method that records a large amount of delay and transmission rate data and analyzes the relationship between the two to obtain a mapping relationship between delay and transmission rate (referred to as a delay-rate mapping relationship). In this way, when the data packet sent is small and the transmission rate cannot be accurately calculated, the delay is calculated and the transmission rate corresponding to the delay is estimated through the delay-rate mapping relationship. In this way, the problem of not being able to accurately measure the transmission rate in the scenario of sending small data packets can be solved, and the accuracy of the transmission rate estimation is improved.

[0391] The latency-rate mapping includes mappings between multiple preset latency ranges and 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 the preset latency range. In this embodiment, the transmission rate corresponding to latency A is denoted as transmission rate B.

[0392] The delay-rate mapping relationship will be further described in subsequent embodiments.

[0393] Furthermore, in this embodiment, the sending rate is updated based on latency only when it is determined that the time interval between the current moment and the last estimated sending rate update is greater than or equal to the rate update period. This is because the sending rate determined by latency is slightly less accurate than the sending rate calculated directly based on the send time, receive time, packet size, and acknowledgment message size of larger packets. Therefore, the directly calculated sending rate is preferred. This improves the accuracy of sending rate estimates, subsequent sending quota estimates, and, ultimately, bandwidth allocation.

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

[0395] It can be understood that, under normal circumstances, the size of the data packet to be sent is much smaller than the sending quota of a quota cycle. In other words, the sending quota of a quota cycle is sufficient to send data packets for multiple sending cycles. Therefore, the data fragments in the same data packet can basically all be sent to the opposite device in the same sending cycle. However, in some extreme cases, after a part of the data fragments in an individual data packet are sent to the opposite device in the first sending cycle, since the sending quota of the current quota cycle is not enough to send the next data fragment, the sending unit enters a dormant state, and the other part of the data fragments need to be allocated a sending quota in the next sending cycle before they can continue to be sent (for details, 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 The method shown calculates the sending rate or delay, receiving time T recv With sending time T send There is a sleep time (ie the above-mentioned preset duration 1) between them, so the calculated sending rate or delay is not accurate enough.

[0396] In view of this, an embodiment of the present application provides an implementation method. After the sending unit executes step S611 and determines the measurement mark of the first data fragment A1, if the measurement mark is a speed measurement mark or a delay measurement mark, 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 the data fragments in data packet A, and then continue to execute subsequent steps. If the current sending quota is less than the size of data packet A, it means that the current sending quota is not enough to send all the data fragments in data packet A, and the sending process of data packet A may include a sleep time for the sending unit. In this case, the measurement mark in the first data fragment A1 can be modified to an empty mark, and the sending rate or delay strategy for the data packet is not implemented. Alternatively, the sending unit can send a notification message to the rate management unit, and the subsequent rate management unit will receive the size D of data packet A even if it receives the size D of data packet A. send , the size of the confirmation message D recv , receiving time T recv and sending time T send , nor does it calculate the sending rate or delay. Alternatively, after receiving the notification message from the sending unit, the rate management unit can also calculate the sending rate using formula (3) and the delay using formula (4). In this way, the accuracy of the estimated sending rate calculation can be improved. Formula (3) and formula (4) are as follows:

[0397]

[0398] T1 is the preset duration 1, that is, the sleep duration of the sending unit.

[0399] The establishment and update process of the delay-rate mapping relationship is further described below.

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

[0401] For example, Figure 21 This is another example of a data transmission process diagram provided in the embodiment of the present application. Figure 21 As shown, the delay-rate mapping relationship can be created or updated according to the following process:

[0402] S701: The rate management unit records the calculated sending time T corresponding to each delay. send .

[0403] Specifically, after executing step S621 each time, the rate management unit may execute step S701 to record the sending time corresponding to the calculated delay.

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

[0405] Specifically, after executing step S617 each time, the rate management unit may execute step S702 to record the sending time corresponding to the calculated sending rate.

[0406] S703 : In each mapping update period, the rate management unit associates the delays and sending rates whose sending time differences are less than a preset time threshold according to the corresponding sending times to obtain an associated data group.

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

[0408] For example, see Figure 22The corresponding transmission times for delays RTT1, RTT2, RTT3, RTT4, RTT5, and RTT6 are time1, time2, time3, time4, time5, and time6, respectively. The corresponding transmission times for transmission rates RATE1, RATE2, RATE3, and RATE4 are time7, time8, time9, and time10, respectively. The time difference between time1 and time7 is less than the preset time threshold, so RTT1 is associated with RATE1. The time difference between time2 and time3 and time8 is less than the preset time threshold, so RTT2 and RTT3 are associated with RATE2. The time difference between time6 and time10 is less than the preset time threshold, so RTT6 is associated with RATE4. The time difference between time7 and time8 and the corresponding transmission rates is 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 by step S702 can be all recorded transmission rates and delays. When there is a newly calculated delay and / or transmission rate in each mapping update cycle, the newly calculated delay and transmission rate are also associated according to this process. In this way, more data association relationships can be obtained, and these data association relationships 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 associated data group, the more accurate the analyzed mapping relationship. Therefore, in this embodiment, all recorded association relationships are added to the associated data group as the basis for analyzing the mapping relationship, which can improve the accuracy of the obtained mapping relationship and thus improve the accuracy of the transmission rate estimation.

[0410] S704: The rate management unit determines a plurality of preset delay ranges according to the delays in the associated data group.

[0411] Part or all of the delays in the associated data group are within the delay range.

[0412] That is, the multiple preset delay ranges can reflect the range of delay values in the associated data group. The granularity of the division of the preset delay ranges can be set according to demand.

[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, namely: 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 respectively to obtain a transmission rate set corresponding to each preset delay range.

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

[0416] That is, the data in the transmission rate set corresponding to each delay range are processed respectively to obtain a transmission rate, and the transmission rate is determined as the transmission rate corresponding to the preset delay range.

[0417] Optionally, processing the data in the sending rate set may include averaging the data in the sending rate set.

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

[0419] In this embodiment, by analyzing and clustering multiple delays, multiple sending rates, and corresponding sending times, the delay-rate mapping relationship can be simply and accurately determined, thereby improving the accuracy of sending rate estimation.

[0420] The above describes in detail an example of a data sending method provided by an embodiment of the present application. It is understandable that, in order to implement 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 easily appreciate that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in a manner such as hardware or 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 combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.

[0421] The embodiment of the present application can divide the functional modules of the electronic device according to the above method example. For example, each function can be divided into various functional modules, such as a detection unit, a processing unit, a display unit, etc., or two or more functions can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0422] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to 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-mentioned data sending method, and thus can achieve the same effect as the above-mentioned implementation method.

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

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

[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 may be a Figure 8 or Figure 9 Device with the structure shown.

[0427] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the processor executes the data sending method of any of the above embodiments.

[0428] An embodiment of the present application further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the data sending method in the above-mentioned embodiment.

[0429] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory to enable the chip to execute the data sending method in the above-mentioned method embodiments.

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

[0431] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by 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 devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0433] Units described as separate components may or may not be physically separate, and components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0434] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0435] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0436] The above content is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A data transmission method, the method being executed by a first electronic device, characterized in that: The first electronic device is connected to the second electronic device via Bluetooth, and the method includes: Obtaining first data from the first sending queue; sending the first data to the second electronic device via Bluetooth; After the first data in the first sending queue is sent, obtaining the second data 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.

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

3. The method according to claim 1 or 2, characterized in that Before obtaining 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 tag to the second data according to a type of the second data; The second application adds the second data to the second sending queue according to the second priority tag.

4. The method according to any one of claims 1 to 3, characterized in that After the first data in the first sending queue is sent, obtaining the second data from the second sending queue includes: After the first data in the first sending queue is sent, obtaining third data from the third sending queue; the sending priority of the third data is lower than the sending priority of the first data and higher than the sending priority of the second data; sending the third data to the second electronic device via Bluetooth; After the data in the third sending queue is sent completely, the second data is obtained 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 any one of claims 1 to 5, characterized in that The first data is stored in the first sending queue in the form of multiple first data fragments; The obtaining of the first data from the first sending queue includes: Determining whether the first data fragment exists in the first sending queue; If the first data slice exists in the first sending queue, a first data slice is obtained from the first sending queue based on a first-in-first-out principle to obtain a first target data slice.

7. The method according to claim 6, characterized in that The sending of the first data to the second electronic device via Bluetooth includes: Obtaining a 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 representing 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 sending quota; 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 of determining whether the first data fragment exists in the first sending queue is returned; the first value is the product of the size of the first target data fragment and a first percentage, and the first percentage is greater than 0 and less than 100%.

8. The method according to claim 7, characterized in that If the current sending quota is greater than the first value, sending the first target data segment to the second electronic device via Bluetooth, comprising: 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 smaller than the size of the first target data segment, determining whether the current sending quota is larger than a first value; 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 sending quota of 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 method further comprises: If the current sending quota is less than or equal to the first value, the first target data slice is added to the first position of the first sending queue, and the current sending quota is recovered.

10. The method according to claim 9, characterized in that The first electronic device includes a sending unit; The determining whether the first data fragment exists in the first sending queue includes: After the sending unit enters the working state from the dormant state, the sending unit determines whether the first data fragment exists in the first sending queue; After overdrawing the sending quota of the next quota period according to the size of the first data fragment, and after recovering the current sending quota, the method further includes: The sending unit enters a dormant state.

11. The method according to any one of claims 6 to 10, 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, obtaining the second data from the second sending queue includes: If the first data fragment does not exist in the first sending queue, determining whether the second data fragment exists in the second sending queue; If the second data slice exists in the second sending queue, a second data slice is obtained from the second sending queue based on a first-in-first-out principle to obtain a second target data slice.

12. The method according to claim 11, characterized in that The sending the second data to the second electronic device via Bluetooth includes: Obtaining a 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 representing 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 sending quota; If the current sending quota is greater than or equal to the size of the second target data fragment, the second target data fragment is sent to the second electronic device via Bluetooth, and according to the size of the second target data fragment, the sending quota of the current quota period is consumed, and the current sending quota is updated, and the process of determining whether the first data fragment exists in the first sending queue is returned to be executed.

13. The method according to claim 12, characterized in that The method further comprises: If the current sending quota is smaller than the size of the second target data slice, the second target data slice is added to the first position of the second sending queue, and the current sending quota is recovered.

14. The method according to claim 13, characterized in that The first electronic device includes a sending unit; The method further comprises: If the second data fragment does not exist in the second sending queue, the sending unit enters a dormant state; After reclaiming the current sending quota, the method further includes: The sending unit enters a dormant state.

15. The method according to any one of claims 7 to 14, characterized in that The first electronic device includes a sending unit; before determining whether the first data fragment exists in the first sending queue, the method further includes: In response to the sending unit entering the working state, if a time difference between a current moment and a moment when the initial sending quota was last updated is greater than or equal to a duration of the quota period, obtaining a first sending rate; the first sending rate represents a rate at which the first electronic device sends data via Bluetooth, and the first sending rate is determined based on historical data; determining an initial sending quota for the current quota period according to the first sending rate; If the initial sending quota is greater than 0, determining whether the first data fragment exists in the first sending queue; If the initial sending quota is less than or equal to 0, the sending unit enters a dormant state.

16. The method according to claim 15, characterized in that The maximum duration that the sending unit is in the 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.

17. The method according to claim 15 or 16, characterized in that The determining, according to the first sending rate, the initial sending quota for the current quota period includes: Calculating the product of the first sending rate and the duration of the quota period to obtain an estimated sending quota; The sum of the estimated sending quota and the sending quota recovered in the previous quota period is calculated, or the difference between the estimated sending quota and the sending quota overdrawn in the previous quota period is calculated to obtain the initial sending quota for the current quota period.

18. The method according to any one of claims 15 to 17, characterized in that Before obtaining the first sending rate, the method further includes: In the process of sending a first history data packet to a third electronic device via Bluetooth, if the size of the first history data packet is greater than a first threshold, calculating the first sending rate based on a sending time of the first history data packet, a receiving time of a confirmation message, a size of the first history data packet, and a size of the confirmation message; the confirmation message is sent by the third electronic device and is used to confirm receipt of the first history data packet; If the size of the first historical data packet is smaller than a second threshold, a first delay is calculated according to the sending time and the receiving time, and the first sending rate is determined according to the first delay; and the second threshold is smaller than the first threshold.

19. The method according to claim 18, characterized in that The method further comprises: If the size of the first historical data packet is greater than the first threshold, setting a first mark to the first historical data packet; If the size of the first historical data packet is smaller than the second threshold, setting a second mark to the first historical data packet; In the process of sending a data packet to the third electronic device via Bluetooth, if it is determined that the data packet has the first mark, recording the sending time, the receiving time, the size of the first historical data packet, and the size of the confirmation message; If it is determined that the data packet has the second mark, the sending time and the receiving time are recorded.

20. The method according to claim 18 or 19, characterized in that The calculating the first sending rate according to the sending time of the first historical data packet, the receiving time of the confirmation message, the size of the first historical data packet, and the size of the confirmation message includes: Calculating the sum of the sending time and the receiving time to obtain a second value; Calculating the sum of the size of the first historical data packet and the size of the confirmation message to obtain a third value; A quotient of the third value and the second value is calculated to obtain the first delay.

21. The method according to any one of claims 18 to 20, characterized in that The calculating the first delay according to the sending time and the receiving time includes: Calculating the sum of the sending time and the receiving time to obtain a second value; The quotient of the second value and 2 is calculated to obtain the first sending rate.

22. The method according to any one of claims 18 to 21, characterized in that The determining the first sending rate according to the first time 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 a first preset delay range in the multiple preset delay ranges includes the first delay; According to the first mapping relationship, a sending rate corresponding to the first preset delay range is determined to obtain the first sending rate.

23. The method according to claim 22, characterized in that Before obtaining the first mapping relationship, the method further includes: Get multiple delays and corresponding sending times; Get multiple sending rates and corresponding sending times; Correlating the corresponding delays and sending rates whose sending time differences are less than a preset time threshold to obtain a correlated data group; determining the plurality of preset delay ranges according to the delays in the associated data group; Clustering the transmission rates corresponding to the 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; The sending rate corresponding to the second preset delay range is obtained by processing the sending rate in the first rate set.

24. The method according to any one of claims 18 to 23, characterized in that The determining the first sending rate according to the first time delay includes: When it is determined that the time difference between the current moment and the moment when the first sending rate was last updated is greater than or equal to a preset sending rate update period, the first sending rate is determined according to the first delay.

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

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

27. An electronic device, characterized in that: The electronic device includes: one or more processors, and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program code, where the computer program code includes computer instructions. The one or more processors call the computer instructions to enable the electronic device to execute the method according to any one of claims 1 to 26.

28. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1 to 26.

29. A computer-readable storage medium, characterized in that The computer-readable storage medium comprises instructions, which, when executed on an electronic device, cause the electronic device to perform the method according to any one of claims 1 to 26.

Citation Information

Patent Citations

  • Data transmission method and device

    CN107005461A

  • Data transmission method and related device

    CN114040510A

  • Data transmission method and device

    CN117376276A

  • Data transmission method and electronic equipment

    CN117632459A