Disclosure of Invention
The technical problem to be solved by the invention is to provide a Bluetooth device, a sleep control method and device thereof, and a computer readable storage medium, which can enable the Bluetooth device to enter into sleep for the remaining duration in a burst time interval comprising a plurality of cycles, so that more opportunities are provided for entering into deep sleep, and more power consumption is saved.
In order to solve the above technical problem, an embodiment of the present invention provides a sleep control method for a bluetooth device, including the following steps: determining a burst interval, the burst interval comprising a plurality of cycles; transmitting a plurality of data packets in a plurality of periods to a receiving device in a first period of each burst interval; determining the remaining time length in the burst time interval, and determining to enter shallow sleep or deep sleep based on the comparison result of the remaining time length and a first preset threshold.
Optionally, the determining a burst interval, where the burst interval includes a plurality of periods, includes: determining the size of a buffer space of the receiving device, and determining the number of cycles contained in the burst time interval based on the size of the buffer space.
Optionally, the data packets include an A2DP data packet and a service data packet other than the A2DP data packet, and the number of cycles included in the burst interval is determined by using the following formula:
wherein N represents the number of cycles contained in the burst interval;
s represents the size of the cache space;
b represents a preset bit rate for transmitting the A2DP data packets;
t represents the period;
L1representing the size of the pre-stored information in the period;
L2indicating the size of the service data packet.
Optionally, the bluetooth device includes one or more of: the Bluetooth receiving terminal comprises a Bluetooth sending terminal main device, a Bluetooth sending terminal controller and a Bluetooth receiving terminal controller.
Optionally, determining to enter shallow sleep or deep sleep based on a comparison result of the remaining time duration and a first preset threshold includes: when the remaining duration is greater than or equal to a first preset threshold, determining that the Bluetooth equipment enters deep sleep; and when the remaining time is less than a first preset threshold value, determining that the Bluetooth equipment enters shallow sleep.
Optionally, the data packets include an A2DP data packet and a service data packet, and sending, in a first period of each burst interval, a plurality of data packets in the plurality of periods to the receiving device includes: configuring the transmission priority of the data packet at the beginning of each burst interval, wherein the transmission priority of the service data packet is lower than that of the A2DP data packet, so that the A2DP data packet is preferentially transmitted in each burst interval.
Optionally, determining to enter shallow sleep or deep sleep based on a comparison result of the remaining time duration and a first preset threshold includes: determining, within the burst interval, a remaining time within the burst interval before transmitting each traffic data packet; and when the remaining time is less than a second preset threshold and is greater than or equal to the first preset threshold, entering deep sleep, and delaying the service data packet to a next burst time interval for sending, wherein the second preset threshold is greater than the first preset threshold.
Optionally, the service data packet includes one or more of the following items: and playing the data packet sent by the control service, playing the data packet sent by the information display service and playing the data packet sent by the volume control service.
In order to solve the above technical problem, an embodiment of the present invention provides a sleep control apparatus for a bluetooth device, including: a burst determination module adapted to determine a burst interval, the burst interval comprising a plurality of periods; a sending module, adapted to send a plurality of data packets in a plurality of periods to a receiving device in a first period of each burst interval; a sleep determination module adapted to determine a remaining time duration within the burst time interval and determine to enter shallow sleep or deep sleep based on a comparison of the remaining time duration with a first preset threshold.
Optionally, the burst determining module includes: and the period determining submodule is suitable for determining the size of the buffer space of the receiving equipment and determining the number of periods contained in the burst time interval based on the size of the buffer space.
Optionally, the data packets include an A2DP data packet and a service data packet other than the A2DP data packet, and the period determination submodule determines the number of periods included in the burst time interval by using the following formula:
wherein N represents the number of cycles contained in the burst interval;
s represents the size of the cache space;
b represents a preset bit rate for transmitting the A2DP data packets;
t represents the period;
L1representing the size of the pre-stored information in the period;
L2indicating the size of the service data packet.
Optionally, the bluetooth device includes one or more of: the Bluetooth receiving terminal comprises a Bluetooth sending terminal main device, a Bluetooth sending terminal controller and a Bluetooth receiving terminal controller.
Optionally, the sleep determination module includes: the deep sleep determining submodule is suitable for determining that the Bluetooth equipment enters deep sleep when the remaining duration is greater than or equal to a first preset threshold; and the light sleep determining submodule is suitable for determining that the Bluetooth equipment enters light sleep when the remaining time is less than a first preset threshold.
Optionally, the data packet includes an A2DP data packet and a service data packet, and the sending module includes: a priority configuration sub-module, adapted to configure the transmission priority of the data packet at the beginning of each burst interval, the transmission priority of the service data packet is lower than the transmission priority of the A2DP data packet, so that the A2DP data packet is preferentially transmitted in each burst interval.
Optionally, the sleep determination module includes: a time length determining submodule adapted to determine, within the burst interval, a remaining time within the burst interval before transmitting each service data packet; and the sleep control submodule is suitable for entering deep sleep and delaying the service data packet to a next burst time interval for sending when the remaining time is less than a second preset threshold and is greater than or equal to the first preset threshold, wherein the second preset threshold is greater than the first preset threshold.
Optionally, the service data packet includes one or more of the following items: and playing the data packet sent by the control service, playing the data packet sent by the information display service and playing the data packet sent by the volume control service.
To solve the above technical problem, an embodiment of the present invention provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are executed when the computer instructions execute the steps of the sleep control method of the bluetooth device according to any one of the above.
In order to solve the above technical problem, an embodiment of the present invention provides a bluetooth device, including a memory and a processor, where the memory stores computer instructions capable of running on the processor, and the processor executes the computer instructions to perform the steps of the sleep control method of the bluetooth device according to any one of the above items.
Compared with the prior art, the technical scheme of the embodiment of the invention has the following beneficial effects:
in an embodiment of the present invention, a burst interval is determined, the burst interval comprising a plurality of periods; transmitting a plurality of data packets in a plurality of periods to a receiving device in a first period of each burst interval; determining the remaining time length in the burst time interval, and determining to enter shallow sleep or deep sleep based on the comparison result of the remaining time length and a first preset threshold. By adopting the scheme, the burst time interval comprising a plurality of cycles can be configured, and the data packets of the plurality of cycles are sent in the first cycle of each burst time interval, so that the Bluetooth device can go to sleep in the rest time of the burst time interval.
Further, the bluetooth device may include one or more of: the Bluetooth receiving terminal comprises a Bluetooth sending terminal main device, a Bluetooth sending terminal controller and a Bluetooth receiving terminal controller. Thereby enabling more bluetooth devices to have the opportunity to go into deep sleep to save more power consumption.
Further, the data packets include A2DP data packets and service data packets, and in the embodiment of the present invention, by configuring the transmission priority of the data packets, each time before transmitting a service data packet, it is checked whether the remaining time in a burst time interval is still sufficient to enable the sending device to enter deep sleep, and if the remaining time is short, the service data packet is delayed to the next burst time interval for transmission, so as to preferentially guarantee the transmission of the A2DP data packets and the deep sleep of the bluetooth device, thereby saving more power consumption.
Detailed Description
In the existing bluetooth wireless transmission technology, according to the flow direction of data, can divide into bluetooth sending end and bluetooth receiving terminal with bluetooth equipment to all can include master equipment and controller, thereby carry out the receiving and dispatching of data packet through bluetooth sending end master equipment, bluetooth sending end controller, bluetooth receiving end controller and bluetooth receiving terminal master equipment.
Specifically, fig. 1 is a schematic view of a scenario of transmitting a bluetooth packet in the prior art, at a bluetooth transmitting end, a bluetooth transmitting end master device 101 transmits a packet 11 to a bluetooth transmitting end controller 102, and the bluetooth transmitting end controller 102 transmits a modulated packet 12 to a controller of a bluetooth receiving end through a radio frequency technology. Here, the transmission cycle is cycle 13. When the transmitted bluetooth data packets are A2DP data packets, the receiving end does not need to transmit and receive the data packets according to the original time interval of the A2DP data packets, as long as the receiving end can receive and buffer a plurality of complete A2DP data packets, and then demodulate and play the data packets according to the preset time interval, so that the played music can be ensured to be smooth.
In each transmission cycle, the sending device only occupies a part of the time slot to transmit the data packet, and in the remaining air interface time slots, the sending device is usually controlled to sleep in order to reduce power consumption.
Fig. 2 is a schematic diagram of an application scenario of a sleep control method of a bluetooth device in the prior art. In one transmission cycle 21, the bluetooth device is controlled to go to sleep during an idle time according to the transmission step.
Specifically, the transmission cycle of the A2DP data packet is 20ms, and the bluetooth device is described as an example of a bluetooth sender-side master device. The bluetooth sending end master device can encode and send an A2DP data packet to the bluetooth sending end controller in a time period 201, and the consumed time is about 1.6 ms; go to sleep for a period of time 202, approximately 4ms in duration; awakening by a Bluetooth sending end controller in a time period 203, and receiving a confirmation reply packet (NOCP), wherein the duration time is about 0.5 ms; sleep is entered during the time period 204, and the duration is the remaining duration of the transmission cycle, which is about 13 ms.
Further, when the bluetooth device is a bluetooth transmitting end controller, since it needs to receive an A2DP data packet of the bluetooth transmitting end master device, then send the data packet to the bluetooth receiving end controller, and send an acknowledgement reply packet to the bluetooth transmitting end master device, it can only go to sleep within the remaining time after the above steps are completed in the sending period, which is about 13 ms.
In the existing bluetooth wireless transmission technology, the time for the sending device to sleep in each sending period is too short, which is not enough to enable the bluetooth device to go into deep sleep after sending a data packet, so that the bluetooth device can only go into shallow sleep generally, and compared with deep sleep, the power consumption is very limited, and the power consumption requirement is difficult to meet.
The inventor of the present invention has found through research that, in the prior art, only one cycle of data packets is sent in each cycle, so that a bluetooth device can only go to sleep for the remaining duration of one cycle, and the sleep duration is too short. In the implementation, it is not required that each data packet must be transmitted in the current period, and it is only necessary that the receiving end can receive the complete data packet and buffer the data packet for processing on time. Specifically, taking the A2DP packet as an example, although the A2DP has a high requirement for real-time performance, it is possible to ensure that the played music is smooth if the receiving end receives and buffers a plurality of complete A2DP packets, and then demodulates and plays the packets at predetermined time intervals.
In an embodiment of the present invention, a burst interval is determined, the burst interval comprising a plurality of periods; transmitting a plurality of data packets in a plurality of periods to a receiving device in a first period of each burst interval; determining the remaining time length in the burst time interval, and determining to enter shallow sleep or deep sleep based on the comparison result of the remaining time length and a first preset threshold. By adopting the scheme, the burst time interval comprising a plurality of cycles can be configured, and the data packets of the plurality of cycles are sent in the first cycle of each burst time interval, so that the Bluetooth device can go to sleep in the rest time of the burst time interval.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
Referring to fig. 3, fig. 3 is a flowchart of a sleep control method of a bluetooth device in an embodiment of the present invention. The sleep control method may include steps S31 to S33:
step S31: determining a burst interval, the burst interval comprising a plurality of cycles;
step S32: transmitting a plurality of data packets in a plurality of periods to a receiving device in a first period of each burst interval;
step S33: determining the remaining time length in the burst time interval, and determining to enter shallow sleep or deep sleep based on the comparison result of the remaining time length and a first preset threshold.
In a specific implementation of step S31, determining a burst interval including multiple cycles, may directly set the number of cycles included in the burst interval, or may determine the size of the buffer space of the receiving device by detection or the like, and determine the number of cycles included in the burst interval based on the size of the buffer space.
Specifically, the size of the buffer space of the receiving device may be determined based on the buffer space of the buffer of the bluetooth receiving end, so that the master device of the bluetooth receiving end may take out the data packet from the buffer for demodulation and processing.
Further, the data packets include A2DP data packets and service data packets except the A2DP data packets, and the number of periods included in the burst interval may be determined by using the following formula:
wherein N represents the number of cycles contained in the burst interval;
s represents the size of the buffer space and can be determined based on a buffer of a specific Bluetooth receiving end;
b represents a preset bit rate for transmitting the A2DP data packets;
t represents the period, for example 20 ms;
b × T represents the bit number of the A2DP data packet in each period, and for example, the preset bit rate is 328kb/s, the period is 20ms, and the bit number of the A2DP data packet in each period is 6560 bits, that is, 820 bytes;
L1indicating the size of the pre-stored information in the period, such as the packet header information of A2 DP;
L2the size of the service data packet may be determined based on the specific service type.
In an implementation of step S32, during the first period of each burst interval, a plurality of packets in the period included in the burst interval are transmitted.
Referring to fig. 4, fig. 4 is a data flow diagram of a sleep control method of a bluetooth device in an embodiment of the present invention. The sleep control method may include steps S401 to S405, and each step is specifically described below.
Step S401: at the beginning of each burst interval 45 (i.e., at the beginning of burst interval 45 or at a time near the beginning), the bluetooth sender master 41 wakes up the bluetooth sender controller 42, encodes a packet to be sent, and sends a plurality of packets of a plurality of cycles included in the burst interval to the bluetooth sender controller 42.
Step S402: the bluetooth sender controller 42 sends a NOCP to the bluetooth sender master device 41 to acknowledge receipt of the data packet. When receiving the NOCP, the bluetooth sender master device 41 will be awakened briefly, and since there is still time remaining in the burst interval, the bluetooth sender master device 41 will continue to sleep. It should be noted that in some types of bluetooth devices, the bluetooth transmitting side controller 42 transmits the NOCP, while some do not, and in the embodiment of the present invention, there is no limitation on whether the bluetooth transmitting side controller transmits the NOCP.
Step S403: the bluetooth transmitting end controller 42 transmits the plurality of data packets to the bluetooth receiving end controller 43, and the bluetooth transmitting end controller 42 may go to sleep for the remaining duration in the burst interval.
Step S404: the bluetooth receiving end controller 43 sends the plurality of data packets to the bluetooth receiving end master device 44, and the bluetooth receiving end controller 43 may go to sleep for the remaining duration in the burst interval.
Step S405: at the beginning of the next burst interval, the bluetooth sender master device 41 sends a plurality of packets of a plurality of cycles included in the next burst interval to the bluetooth sender controller 42.
In particular implementations, the bluetooth device may include one or more of: the Bluetooth receiving terminal comprises a Bluetooth sending terminal main device, a Bluetooth sending terminal controller and a Bluetooth receiving terminal controller.
Referring to fig. 5, which is a schematic diagram of a scenario for transmitting a bluetooth packet, at a bluetooth transmitting end, a bluetooth transmitting end master device 501 transmits a packet 51 to a bluetooth transmitting end controller 502, and the bluetooth transmitting end controller 502 transmits a modulated packet 52 to a controller at a bluetooth receiving end through a radio frequency technology. Wherein the transmission period is a burst interval 53. The bluetooth sending end master device 501 and the bluetooth sending end controller 502 do not need to send and receive data packets according to the original time interval of the data packets, and can send a plurality of data packets of a plurality of periods included in the burst time interval to the next bluetooth device at the beginning of the burst time interval 53.
In the embodiment of the invention, more Bluetooth devices can enter deep sleep at a chance so as to save more power consumption.
With continued reference to fig. 3, in an implementation of step S33, determining a remaining time duration within the burst time interval, and determining to enter light sleep or deep sleep based on a comparison of the remaining time duration to a first preset threshold includes: when the remaining duration is greater than or equal to a first preset threshold, determining that the Bluetooth equipment enters deep sleep; and when the remaining time is less than a first preset threshold value, determining that the Bluetooth equipment enters shallow sleep.
Specifically, the first preset threshold may be set according to a specific bluetooth device, and as a non-limiting example, the first preset threshold may be set to a value of 30ms to 50 ms.
In the embodiment of the invention, the burst time interval comprising a plurality of cycles can be configured, and the data packets of the plurality of cycles are sent in the first cycle of each burst time interval, so that the Bluetooth device enters the sleep in the rest time of the burst time interval, and compared with the prior art that the Bluetooth device can only enter the sleep in the rest time of a single cycle, the Bluetooth device has more chances to enter the deep sleep, thereby saving more power consumption.
Further, the data packets sent by the bluetooth device include A2DP data packets and service data packets, and sending a plurality of data packets in a plurality of periods to the receiving device in the first period of each burst interval includes: configuring the transmission priority of the data packet at the beginning of each burst interval, wherein the transmission priority of the service data packet is lower than that of the A2DP data packet, so that the A2DP data packet is preferentially transmitted in each burst interval.
Wherein the service data packet may include one or more of the following: and playing the data packet sent by the control service, playing the data packet sent by the information display service and playing the data packet sent by the volume control service.
Specifically, the data packet sent by the play control service may be a data packet sent in the process of controlling to play the next audio file or the previous audio file; the data packet sent by the playing information display service can be a data packet sent in the process of controlling the Bluetooth equipment to display information such as the name, the size and the like of an audio file; the data packet sent by the volume control service may be a data packet sent in the process of controlling the bluetooth device to increase or decrease the volume.
In the embodiment of the invention, by setting the high sending priority for the A2DP data packet, the smoothness of the A2DP data stream can be ensured in the process of processing the service by the Bluetooth device, and the reduction of user experience due to the tone is avoided.
Referring to fig. 6, fig. 6 is a partial flowchart of another sleep control method for a bluetooth device in an embodiment of the present invention. The determining of the entering of the light sleep or the entering of the deep sleep based on the comparison result of the remaining time period with the first preset threshold may include steps S61 to S62:
step S61: determining, within the burst interval, a remaining time within the burst interval before transmitting each traffic data packet;
step S62: and when the remaining time is less than a second preset threshold and is greater than or equal to the first preset threshold, entering deep sleep, and delaying the service data packet to a next burst time interval for sending, wherein the second preset threshold is greater than the first preset threshold.
In the specific implementation of step S61, during the burst interval, the A2DP packets are transmitted first, and then the service packets are transmitted in sequence according to the configured transmission priority, and before each service packet is transmitted, the remaining time in the burst interval is determined.
In the specific implementation of step S62, when the remaining time is less than the second preset threshold, it is likely that the bluetooth device cannot enter deep sleep in the burst time interval if the service data packet is continuously sent, and at this time, the bluetooth device enters deep sleep after the service data packet is sent to the next burst time interval.
Specifically, the second preset threshold is greater than the first preset threshold, so that after the remaining time is determined, it is still sufficient for the bluetooth device to enter deep sleep. The second preset threshold may be set according to a specific bluetooth device, and as a non-limiting example, the second preset threshold may be set to a value of 32ms to 52 ms.
In the embodiment of the invention, by configuring the transmission priority of the A2DP data packet and the service data packet, before transmitting the service data packet, whether the remaining time in the burst time interval is enough to enable the sending device to enter deep sleep is checked, and the service data packet is delayed to the next burst time interval to be transmitted under the condition that the remaining time is short, so that the transmission of the A2DP data packet and the deep sleep of the Bluetooth device are preferentially ensured, and more power consumption is saved.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a sleep control apparatus of a bluetooth device in an embodiment of the present invention. The sleep control apparatus may include a burst determination module 71, a transmission module 72, and a sleep determination module 73.
Wherein the burst determining module 71 is adapted to determine a burst interval, the burst interval comprising a plurality of periods;
the sending module 72 is adapted to send a plurality of data packets in the plurality of periods to the receiving device in a first period of each burst interval;
the sleep determination module 73 is adapted to determine a remaining time duration within the burst time interval, and determine to enter shallow sleep or deep sleep based on a comparison result of the remaining time duration with a first preset threshold.
Further, the burst determining module includes a period determining submodule (not shown) adapted to determine a size of a buffer space of the receiving device, and determine a number of periods included in the burst time interval based on the size of the buffer space.
The data packets include an A2DP data packet and a traffic data packet other than the A2DP data packet, and the period determination submodule determines the number of periods included in the burst interval using the following formula:
wherein N represents the number of cycles contained in the burst interval;
s represents the size of the cache space;
b represents a preset bit rate for transmitting the A2DP data packets;
t represents the period;
L1representing the size of the pre-stored information in the period;
L2indicating the size of the service data packet.
Further, the bluetooth device includes one or more of: the Bluetooth receiving terminal comprises a Bluetooth sending terminal main device, a Bluetooth sending terminal controller and a Bluetooth receiving terminal controller.
Referring to fig. 8, fig. 8 is a schematic diagram of a specific implementation of the sleep determination module 73 in fig. 7. The sleep determination module 73 may include a deep sleep determination sub-module 731 and a shallow sleep determination sub-module 732.
The deep sleep determining submodule 731 is adapted to determine that the bluetooth device enters deep sleep when the remaining duration is greater than or equal to a first preset threshold.
The light sleep determination sub-module 732 is adapted to determine that the bluetooth device enters light sleep when the remaining time is less than a first preset threshold.
With continued reference to fig. 7, the data packets may include A2DP data packets and service data packets, and the sending module 72 may include: a priority configuration submodule (not shown) adapted to configure the transmission priority of the data packet at the beginning of each burst interval, the transmission priority of the service data packet being lower than the transmission priority of the A2DP data packet, so that the A2DP data packet is preferentially transmitted in each burst interval.
Further, the sleep determination module 73 may include: a duration determination sub-module (not shown) and a sleep control module (not shown).
Wherein the duration determination submodule is adapted to determine, within the burst interval, a remaining time within the burst interval before transmitting each service data packet;
the sleep control module is adapted to enter deep sleep and delay the service data packet to a next burst time interval for sending when the remaining time is less than a second preset threshold and greater than or equal to the first preset threshold, wherein the second preset threshold is greater than the first preset threshold.
Further, the service data packet may include one or more of the following: and playing the data packet sent by the control service, playing the data packet sent by the information display service and playing the data packet sent by the volume control service.
For more details of the sleep control apparatus of the bluetooth device, please refer to the related description of the sleep control method of the bluetooth device shown in fig. 1 to 6, which is not repeated herein.
The embodiment of the invention also provides a computer readable storage medium, which stores computer instructions, and the computer instructions execute the steps of the sleep control method of the bluetooth device when running. The computer readable storage medium may be an optical disc, a mechanical hard disk, a solid state hard disk, etc.
The embodiment of the invention also provides the Bluetooth equipment, which comprises a memory and a processor, wherein the memory is stored with computer instructions capable of running on the processor, and the processor executes the steps of the sleep control method of the Bluetooth equipment when running the computer instructions. The Bluetooth device can be used for various terminal devices such as smart phones and tablet computers.
Although the present invention is disclosed above, the present invention is not limited thereto. Various changes and modifications may be effected therein by one skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.