Dual-mode Bluetooth working timing control method, device, Bluetooth device and storage medium
The software logical time scheduler is divided into isochronous and non-isochronous scheduling containers, which solves the problem of high timing control cost of dual-mode Bluetooth, and realizes resource conservation and scenario satisfaction.
Patent Information
- Application Number
- CN202311078474.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-25
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2043-08-25
AI Technical Summary
In the prior art, the dual-mode Bluetooth timing control mechanism is implemented through hardware, which is economically costly, resulting in waste of resources, and lacks clear protocol specifications and implementation mechanisms.
Through the software logical time scheduler mechanism, the time scheduler is divided into isochronous scheduling containers and non-isochronous scheduling containers, and the time slot management and control of different events of dual-mode Bluetooth are carried out to achieve reasonable allocation and control of dual-mode Bluetooth timing.
There is no need to implement dual-mode Bluetooth timing control through hardware, which reduces costs and saves resources, and meets the needs of dual-mode Bluetooth operation scenarios.
Smart Images

Figure CN117202384B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Bluetooth technology, and in particular to a dual-mode Bluetooth working timing control method, device, Bluetooth device and storage medium. Background Art
[0002] There are two Bluetooth modes in the Bluetooth field, single-mode Bluetooth mode and dual-mode Bluetooth mode. Single-mode Bluetooth mode includes two Bluetooth modes: low-power Bluetooth and classic Bluetooth. Generally, low-power Bluetooth can be applied to low-power devices such as bracelets and headphones. Classic Bluetooth can be applied to traditional wireless audio devices, old Android system devices, etc. Dual-mode Bluetooth mode is: low-power Bluetooth and classic Bluetooth work at the same time.
[0003] Timing control in different state machines during Bluetooth operation is one of the keys to normal operation. The existing protocol specification clearly points out the timing control process of single-mode Bluetooth, and timing control in different state machines can be completed based on the protocol.
[0004] However, there is no clear protocol specification for dual-mode Bluetooth timing control, and there is currently no reference implementation mechanism. Some manufacturers implement dual-mode Bluetooth timing control mechanisms through hardware, which is economically costly and causes waste of resources. Summary of the invention
[0005] In view of this, the embodiments of the present application provide a dual-mode Bluetooth working timing control method, apparatus, Bluetooth device and storage medium to solve the problem in the prior art that the dual-mode Bluetooth timing control mechanism is implemented by hardware, which is economically costly and causes waste of resources.
[0006] According to a first aspect of an embodiment of the present application, a dual-mode Bluetooth working timing control method is provided, comprising:
[0007] When receiving an event to be inserted, if the event to be inserted is an event running in equal time slots, it is inserted into the isochronous scheduling container; if the event to be inserted is an event running in non-equal time slots, it is inserted into the non-isochronous scheduling container;
[0008] When it is detected that an event is inserted into an isochronous scheduling container or a non-isochronous scheduling container, an event to be executed is determined from the isochronous scheduling container and the non-isochronous scheduling container, and the event to be executed is recorded in a queue of events to be executed;
[0009] Scheduling is performed based on pending events in the pending event queue and events being executed.
[0010] According to a second aspect of the embodiment of the present application, a dual-mode Bluetooth working timing control device is provided, comprising:
[0011] The inserting module is configured to, upon receiving an event to be inserted, insert the event to be inserted into the isochronous scheduling container if the event to be inserted is an event running in equal time slots, and insert the event to be inserted into the non-isochronous scheduling container if the event to be inserted is an event running in non-equal time slots;
[0012] A determination module is configured to, when detecting that an event is inserted into the isochronous scheduling container or the non-isochronous scheduling container, determine the event to be executed from the isochronous scheduling container and the non-isochronous scheduling container, and record the event to be executed into a queue of events to be executed;
[0013] The scheduling module is configured to schedule based on the pending events in the pending event queue and the events being executed.
[0014] According to a third aspect of an embodiment of the present application, a Bluetooth device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0015] According to a fourth aspect of an embodiment of the present application, a readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0016] Compared with the prior art, the embodiments of the present application have the following beneficial effects: when receiving an event to be inserted, if the event to be inserted is an event running in equal time slots, it is inserted into an isochronous scheduling container; if the event to be inserted is an event running in non-equal time slots, it is inserted into a non-isochronous scheduling container; when an event is detected to be inserted into an isochronous scheduling container or a non-isochronous scheduling container, the event to be executed is determined from the isochronous scheduling container and the non-isochronous scheduling container, and the event to be executed is recorded in the queue of events to be executed; scheduling is performed based on the events to be executed and the events being executed in the queue of events to be executed. That is, the present embodiment realizes the reasonable allocation and control of the dual-mode Bluetooth timing through software, which can meet the dual-mode Bluetooth operation scenario, and does not need to realize the dual-mode Bluetooth timing control mechanism through hardware, which reduces costs and saves resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 It is a flow chart of a dual-mode Bluetooth working timing control method provided in an embodiment of the present application;
[0019] Figure 2It is a schematic diagram of storage structure distribution of an isochronous scheduling container and a non-isochronous scheduling container provided in an embodiment of the present application;
[0020] Figure 3 It is a structural schematic diagram of a dual-mode Bluetooth working timing control device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0022] Since classic Bluetooth and low-power Bluetooth have their own timing control in different states, their events can be scheduled normally. However, there is no clear protocol specification for dual-mode Bluetooth timing control, and there is currently no reference implementation mechanism. Some manufacturers implement dual-mode Bluetooth timing control mechanisms through hardware, which is economically costly and wastes resources.
[0023] To this end, the embodiments of the present application provide a dual-mode Bluetooth working timing control method, apparatus, Bluetooth device and storage medium, aiming to solve the above technical problems of the prior art.
[0024] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0025] In the dual-mode Bluetooth operating environment, classic Bluetooth and low-power Bluetooth work at the same time. The two working modes have different states, and events in different states may be scheduled at the same time. Therefore, the embodiment of the present application provides a dual-mode Bluetooth working timing control method. Through a software logic time scheduler mechanism, the timing of the dual-mode Bluetooth is reasonably allocated and controlled, so that the dual-mode Bluetooth can work normally and meet the dual-mode Bluetooth operation scenario.
[0026] Figure 1 The figure is a flow chart of a dual-mode Bluetooth working timing control method provided in an embodiment of the present application. The dual-mode Bluetooth includes classic Bluetooth and low-power Bluetooth. Figure 1 A dual-mode Bluetooth working timing control method can be executed by a Bluetooth device. The Bluetooth device can be a classic Bluetooth master device, a classic Bluetooth slave device, a low-power Bluetooth master device, or a low-power Bluetooth slave device.
[0027] like Figure 1 As shown, the dual-mode Bluetooth working timing control method includes:
[0028] S101, when receiving an event to be inserted, if the event to be inserted is an event running in equal time slots, insert it into an isochronous scheduling container; if the event to be inserted is an event running in non-equal time slots, insert it into a non-isochronous scheduling container;
[0029] S102, when it is detected that an event is inserted into an isochronous scheduling container or a non-isochronous scheduling container, determining an event to be executed from the isochronous scheduling container and the non-isochronous scheduling container, and recording the event to be executed into a queue of events to be executed;
[0030] S103: Scheduling based on the pending events in the pending event queue and the events being executed.
[0031] Specifically, the embodiment of the present application sets a set of logical time scheduler frameworks through software, divides the time scheduler into isochronous scheduling containers and non-isochronous scheduling containers, manages and controls time slots of different dual-mode Bluetooth events to complete the dual-mode Bluetooth function. The dual-mode Bluetooth working timing control method of this embodiment can be applied to a variety of application scenarios, for example, a classic Bluetooth master device and a classic Bluetooth slave device work simultaneously, a classic Bluetooth master device and a low-power Bluetooth slave device work simultaneously, a low-power Bluetooth master device and a classic Bluetooth slave device work simultaneously, and a low-power Bluetooth master device and a low-power Bluetooth slave device work simultaneously.
[0032] The classic Bluetooth mode works normally, the master and slave devices are interconnected and data is transmitted, and the following states need to be experienced:
[0033] Query status: used for the Bluetooth master device to discover the slave device stage;
[0034] Paging state: used for the Bluetooth master device to initiate the connection phase;
[0035] Inquiry scanning status: used for the Bluetooth slave device to respond to the master device inquiry;
[0036] Paging scan status: used for the Bluetooth slave device to respond to the master device paging;
[0037] Connection state: used for the Bluetooth master-slave device connection completion stage. After entering the connection state, there are three logical links for different business transmissions, such as the ACL logical link (asynchronous connection logical link) is the first logical link after entering the connection state, which is used to transmit asynchronous data and control data; the SCO logical link (synchronous connection logical link) is used for synchronous audio transmission; the ESCO logical link (extended synchronous connection logical link) is used for synchronous audio transmission and supports a retransmission mechanism.
[0038] The low-power Bluetooth mode works normally, the master and slave devices are interconnected and data is transmitted, and the following states need to be experienced:
[0039] Announcement state: used for the Bluetooth slave device announcement phase;
[0040] Scanning state: used for the Bluetooth master device to discover the slave device stage;
[0041] Initiating state: used for the Bluetooth master device to initiate the connection phase;
[0042] Connection status: used for the Bluetooth master-slave device connection completion stage, data and audio transmission can be performed.
[0043] In classic Bluetooth, paging events and query events can be scheduled in pre-allocated equal-time slots. The time slots of query events and paging events are 625 μs (microseconds) per time slot, and the TX or RX actions are performed respectively, and the entire time slot length is pre-allocated.
[0044] The connection events of classic Bluetooth include three logical links: ESCO logical link (extended synchronous connection oriented logical link), SCO logical link (synchronous connection oriented logical link) and ACL logical link (asynchronous connection logical link). All three events can be scheduled in pre-allocated equal-time slots.
[0045] The ESCO logical link operates in a 625μs time slot and has a retransmission window. The SCO logical link uses a 625μs time slot to send TX or receive RX actions respectively, and the entire time slot length is until the SCO logical link is disconnected. The ACL logical link uses a 625μs time slot to send TX or receive RX actions respectively, and the entire time slot length is until the connection state is exited.
[0046] Therefore, the paging events, query events and three connection events of classic Bluetooth can be stored and managed through the isochronous scheduling container.
[0047] The paging scan event and inquiry scan event of classic Bluetooth can be scheduled in the pre-allocated non-isochronous time slot. All events of low-power Bluetooth can be scheduled in the pre-allocated non-isochronous time slot. All events include announcement events, scan events, initiation events and connection events.
[0048] Therefore, the paging scan events and inquiry scan events of classic Bluetooth, as well as the announcement events, scan events, initiation events and connection events of low-power Bluetooth can be stored and managed through non-isochronous scheduling containers.
[0049] Thus, when an event to be inserted is received, if the event to be inserted is an event running in equal time slots, the event to be inserted is inserted into the isochronous scheduling container; if the event to be inserted is an event running in unequal time slots, the event to be inserted is inserted into the unequal scheduling container.
[0050] According to the technical solution provided by the embodiment of the present application, when an event to be inserted is received, if the event to be inserted is an event running in equal time slots, it is inserted into the isochronous scheduling container, and if the event to be inserted is an event running in non-equal time slots, it is inserted into the non-isochronous scheduling container; when an event is detected to be inserted into an isochronous scheduling container or a non-isochronous scheduling container, the event to be executed is determined from the isochronous scheduling container and the non-isochronous scheduling container, and the event to be executed is recorded in the queue of events to be executed; scheduling is performed based on the events to be executed and the events being executed in the queue of events to be executed. That is, this embodiment realizes the reasonable allocation and control of the dual-mode Bluetooth timing through software, which can meet the dual-mode Bluetooth operation scenario, and does not need to implement the dual-mode Bluetooth timing control mechanism through hardware, which reduces costs and saves resources.
[0051] In some embodiments, each event of the dual-mode Bluetooth corresponds to a preset priority; specifically, each event of the dual-mode Bluetooth can be assigned a corresponding priority, such as being divided into five levels: ultra-high priority, high priority, medium priority, low priority, and normal priority. Of course, other numbers of priorities can be assigned according to actual conditions, and this application does not limit this.
[0052] Exemplarily, for Classic Bluetooth:
[0053] The priority of the ESCO logical link of the connection event is: super high priority;
[0054] The priority of the SCO logical link of the connection event is: high priority;
[0055] The priorities of the ACL logical link of the connection event are: normal priority;
[0056] The priorities of paging events and query events are: low priority;
[0057] The priority of paging scan events and inquiry scan events is medium priority.
[0058] For example, for Bluetooth Low Energy:
[0059] The priorities of announcement events, scanning events, and initiation events are all medium priority;
[0060] The priority of the connection event is: Ultra High Priority.
[0061] Figure 2 Schematic diagram of the storage structure distribution of an isochronous scheduling container and a non-isochronous scheduling container provided in an embodiment of the present application. Figure 2As shown, the isochronous scheduling container can be used to store and manage: ESCO logical links, SCO logical links, ACL logical links, paging events and query events of classic Bluetooth connection events. The non-isochronous scheduling container can be used to store and manage: query scanning events, paging scanning events, initiation events, announcement events, scanning events and connection events of classic Bluetooth.
[0062] In some embodiments, if the event to be inserted is an event that runs in equal time slots, it is inserted into the isochronous scheduling container, including: if the event to be inserted is an event that runs in equal time slots, the event to be inserted is inserted into the corresponding isochronous time slot in the isochronous scheduling container according to the event type; the isochronous time slot is an isochronous time slot reserved according to the event type.
[0063] Specifically, Figure 2 As shown, the isochronous scheduling container: divides the entire time slot into multiple isochronous slots, 1.25ms for one isochronous slot, and the logical processing of sending TX and receiving RX in one isochronous slot is completed by the corresponding state machine module of the Bluetooth device itself. When the Bluetooth device enters the relevant state, the isochronous scheduling container is activated, and the isochronous slot is reserved in advance according to the event type. The events in the isochronous scheduling container can be scheduled based on time and priority election.
[0064] Optionally, 5 isochronous time slots may be reserved for the ESCO logical link of classic Bluetooth, of which 2 isochronous time slots are occupied by data transmission at most, and 3 isochronous time slots are occupied by the retransmission window at most, and they are preset as the highest priority for cyclic scheduling;
[0065] Optionally, three isochronous time slots may be reserved for the SCO logical link of classic Bluetooth, and preset for round-robin scheduling with high priority;
[0066] Optionally, one isochronous time slot may be reserved for the ACL logical link of classic Bluetooth, and it is preset to normal priority for round-robin scheduling;
[0067] Optionally, 8 isochronous time slots may be reserved for paging and query events of classic Bluetooth, 8 isochronous time slots in one cycle, and they are preset to low priority for cyclic scheduling.
[0068] In some embodiments, if the event to be inserted is an event that runs in non-equidistant time slots, inserting it into the non-equidistant scheduling container includes:
[0069] Compare whether the time period of the event to be inserted overlaps with the time period of the event in the non-isochronous scheduling container;
[0070] If yes, set the event that overlaps with the event to be inserted as the first event, and insert the event to be inserted into the non-isochronous scheduling container according to the priority of the event to be inserted and the priority of the first event;
[0071] If not, the event to be inserted is inserted into the non-isochronous scheduling container according to the principle of insertion.
[0072] In some embodiments, inserting the event to be inserted into the non-isochronous scheduling container according to the priority of the event to be inserted and the priority of the first event includes:
[0073] Compare the priority of the event to be inserted with the priority of the first event;
[0074] When the priority of the event to be inserted is the same as the priority of the first event, the event to be inserted is shifted backward by the first time interval, and the shifted event to be inserted is reinserted into the non-isochronous scheduling container;
[0075] When the priority of the event to be inserted is different from the priority of the first event, the event with a higher priority between the event to be inserted and the first event is determined as a high priority event, and the event with a lower priority between the event to be inserted and the first event is determined as a low priority event;
[0076] Adjust the start time or end time of the low priority event so that the high priority event occupies part of the time period of the low priority event, or, after shifting the low priority event backward by a second time interval, reinsert the shifted low priority event into the non-isochronous scheduling container.
[0077] In some embodiments, adjusting the start time or end time of the low priority event so that the high priority event occupies part of the time period of the low priority event, or, after shifting the low priority event backward for a second time interval, reinserting the shifted low priority event into the non-isochronous scheduling container, includes:
[0078] When the time period of a low-priority event partially overlaps with the time period of a high-priority event, the start time or end time of the low-priority event is adjusted so that the high-priority event occupies part of the time period of the low-priority event;
[0079] When the time period of a high-priority event completely covers the time period of a low-priority event, the start and end times of the low-priority event are adjusted so that the time period of the low-priority event is offset backward by a second time interval, and the offset low-priority event is reinserted into the non-isochronous scheduling container.
[0080] It should be noted that the time period of low priority events cannot cover the time period of high priority events. Only the time period of low priority events is covered by the time period of high priority events, and then the time period of low priority events is shifted backward according to the above method.
[0081] In this application, "complete coverage" means that one time period is greater than or equal to another time period. For example, the time period of high-priority events is 12:00:00-12:00:48, and the time period of low-priority events is 12:00:10-12:00:34, or the time period of low-priority events is 12:00:00-12:00:48, and the time period of high-priority events completely covers the time period of low-priority events. This example is only used to explain that "complete coverage" means that one time period is greater than or equal to another time period.
[0082] Specifically, Figure 2 As shown, the non-isochronous scheduling container is a serial link based on the priority and time continuous linked list of events, which can be scheduled in sequence according to the start time of the event. The insertion principle of the non-isochronous scheduling container is as follows:
[0083] First, compare whether the time period of the event to be inserted overlaps with the time period of the event in the non-isochronous scheduling container;
[0084] If there is no overlap, the event to be inserted is inserted into the non-isochronous scheduling container according to the principle of insertion, based on the start time and end time of the event to be inserted, and on a first-come, first-served basis.
[0085] If there is overlap, the event that overlaps with the event to be inserted is set as the first event, and the priority of the event to be inserted is compared with the first event;
[0086] When the priority of the event to be inserted is the same as the priority of the first event, the event to be inserted is shifted backward by the first time interval, and the shifted event to be inserted is reinserted into the non-isochronous scheduling container;
[0087] When the priority of the event to be inserted is different from the priority of the first event, the event with a higher priority between the event to be inserted and the first event is determined as a high priority event, and the event with a lower priority between the event to be inserted and the first event is determined as a low priority event;
[0088] Exemplarily, a high priority event occupies part of the time period of a low priority event, and the specific settings are as follows:
[0089] The start time of the high priority event: T_START1;
[0090] End time of high priority event: T_END1;
[0091] Time interval for high priority events: EVENT1_ITVL;
[0092] The start time of the low priority event: T_START2;
[0093] End time of low priority event: T_END2;
[0094] Time interval of low-priority event: EVENT2_ITVL;
[0095] When T_END1 < T_END2, the following settings are made:
[0096] T_START2 = T_END1;
[0097] Give priority to high-priority events, adjust the start time of low-priority events, and high-priority events occupy part of the time period of low-priority events. For example Figure 2 In the time period of 33.75 ms to 45 ms of the non-isochronous scheduling container in the non-isochronous scheduling container, the priority of the low-power Bluetooth connection event is ultra-high priority, the priority of the classic Bluetooth inquiry scan event is medium priority, the priority of the low-power Bluetooth connection event is higher than that of the classic Bluetooth inquiry scan event, and the low-power Bluetooth connection event occupies the previous part of the time period of the classic Bluetooth inquiry scan event.
[0098] When T_END1 > T_END2 and T_START1 > T_START2, the following settings are made:
[0099] T_END2 = T_START1;
[0100] Give priority to high-priority events, adjust the end time of low-priority events, and high-priority events occupy part of the time period of low-priority events. For example Figure 2 In the time period of 45 ms to 56.25 ms of the non-isochronous scheduling container in the non-isochronous scheduling container, the priority of the low-power Bluetooth connection event is ultra-high priority, the priority of the classic Bluetooth paging scan event is medium priority, the priority of the low-power Bluetooth connection event is higher than that of the classic Bluetooth paging scan event, and the low-power Bluetooth connection event occupies the latter part of the time period of the classic Bluetooth paging scan event.
[0101] When T_START1 < T_START2 and T_END1 > T_END2, the following settings are made:
[0102] T_START2 = T_START2 + EVENT2_ITVL;
[0103] T_END2 = T_END2 + EVENT2_ITVL;
[0104] Give priority to high-priority events, adjust the start time and end time of low-priority events, so that the entire time sequence of low-priority events is shifted backward by the second time interval, and the second time interval is the time interval of low-priority events, and the shifted low-priority events are inserted into the non-isochronous scheduling container.
[0105] In some embodiments, determining the to-be-executed events from the isochronous scheduling container and the non-isochronous scheduling container includes:
[0106] Determine the earliest start time of an event from an isochronous scheduling container and a non-isochronous scheduling container;
[0107] If the event with the earliest start time is unique, the event with the earliest start time is determined as the event to be executed;
[0108] If there are multiple events with the earliest start time, compare the priorities of the multiple events with the earliest start time;
[0109] If the priorities of multiple events with the earliest start times are different, the event with the earliest start time with the highest priority is determined as the event to be executed; if the event determined as the earliest start time of the event to be executed is in the non-isochronous scheduling container, the event determined as the earliest start time of the event to be executed is removed from the non-isochronous scheduling container; if the event not determined as the earliest start time of the event to be executed is in the non-isochronous scheduling container, detect whether the time period of the event determined as the earliest start time of the event to be executed completely covers the time period of the event not determined as the earliest start time of the event to be executed; if so, adjust the start time and end time of the event not determined as the earliest start time of the event to be executed, so that the event not determined as the earliest start time of the event to be executed is offset backward by the fifth time interval, and reinsert the offset event not determined as the earliest start time of the event to be executed into the non-isochronous scheduling container; if not, adjust the start time of the event not determined as the earliest start time of the event to be executed, so that the event determined as the earliest start time of the event to be executed occupies part of the time period of the event not determined as the earliest start time of the event to be executed;
[0110] If the priorities of multiple events with the earliest start times are the same, the event with the earliest start time corresponding to the low-power Bluetooth in the non-isochronous scheduling container is determined as the event to be executed.
[0111] And, record the pending events into the pending events queue, including:
[0112] If the event to be executed is in the non-isochronous scheduling container, after the event to be executed is removed from the non-isochronous scheduling container, the event to be executed is recorded in the queue of events to be executed.
[0113] That is, when it is detected that an event is inserted into the isochronous scheduling container or the non-isochronous scheduling container, the event to be executed is determined from the isochronous scheduling container and the non-isochronous scheduling container. If the event to be executed is in the non-isochronous scheduling container, the event to be executed is removed from the non-isochronous scheduling container and recorded in the queue of events to be executed.
[0114] It should be noted that if the event to be executed is in the isochronous scheduling container, there is no need to remove the event to be executed from the isochronous scheduling container. Because the isochronous scheduling container pre-allocates the corresponding isochronous slots according to the event type, the duration of each isochronous slot is 1.25ms, and each time the event to be executed is determined, the time is shifted back by 1.25ms, and there is no concept of sorting. The non-isochronous scheduling container is a serial link based on the priority of the event and the time continuous linked list, and is sorted according to the start time of the event, so the event to be executed needs to be removed from the non-isochronous scheduling container. After the event to be executed is determined, the event to be executed is recorded in the queue of events to be executed; the timing starts based on the start time of the event to be executed, and the scheduling is triggered when the start time of the waiting execution event arrives.
[0115] After each event is inserted, an election is performed, that is, the pending events are determined from the isochronous scheduling container and the non-isochronous scheduling container, the next pending event is determined and recorded in the pending event queue, and the timing is started based on the start time of the next pending event. When the start time of the execution event arrives, the scheduling is triggered.
[0116] In some embodiments, scheduling is performed based on the pending events in the pending event queue and the events being executed, including:
[0117] Check if there is an event being executed;
[0118] If there is no event being executed, execute the pending event;
[0119] If there is an event being executed, and the type of the event being executed is the same as the type of the event to be executed, then the event being executed will continue to be executed;
[0120] If there is an event being executed, and the type of the event being executed is different from the type of the event to be executed, then the priority of the event being executed is compared with the priority of the event to be executed;
[0121] If the priority of the event being executed is lower than the priority of the event to be executed, the event to be executed will be executed, and the execution of the event being executed will be stopped, and the scheduling of the event being executed will be postponed;
[0122] If the priority of the event being executed is not lower than the priority of the event to be executed, the event being executed is executed and the event to be executed is postponed.
[0123] In some embodiments, the scheduling of the executing event is postponed, including: if the executing event is an event that runs in non-equidistant time slots, adjusting the start time of the executing event so that the event to be executed occupies a part of the time period of the executing event, reinserting the adjusted executing event into the non-equidistant scheduling container, or shifting the executing event backward by a third time interval, and reinserting the shifted executing event into the non-equidistant scheduling container;
[0124] The event to be executed is postponed for scheduling, including: if the event to be executed is an event that runs in non-equidistant time slots, adjusting the start time of the event to be executed so that the event being executed occupies a part of the time period of the event to be executed, reinserting the adjusted event to be executed into the non-equidistant scheduling container, or shifting the event to be executed backward by a fourth time interval, and reinserting the shifted event to be executed into the non-equidistant scheduling container.
[0125] Specifically, during scheduling, first check whether there is an event being executed, and selectively skip or execute the pending events in the pending event queue, and record the executing events. The specific settings are as follows:
[0126] Executing event: EVENT1, start time: T1_START, end time: T1_END, executing event time interval: EVENT1_ITVL;
[0127] Event to be executed: EVENT2, start time: T2_START, end time: T2_END, time interval of the event to be executed: EVENT2_ITVL;
[0128] Specifically, detect whether event EVENT1 is being executed;
[0129] If there is no event EVENT1 being executed, the event EVENT2 to be executed will be executed directly;
[0130] When there is an event EVENT1 being executed, and the type of the event EVENT1 being executed is the same as that of the event EVENT2 to be executed, the event EVENT1 being executed is executed without interrupting and skipping the event scheduling, and the event to be executed continues to exist in the queue to be executed. In this embodiment, the same type refers to the same event type, for example, EVENT1 and EVENT2 are both paging scan events of classic Bluetooth.
[0131] When there is an event EVENT1 being executed and the type of the executing event EVENT1 is different from the type of the event EVENT2 to be executed, then compare the priorities of the executing event EVENT1 and the event EVENT2 to be executed; the different types in this embodiment refer to different event types. For example, EVENT1 is a query scan event of classic Bluetooth, and EVENT2 is a paging scan event of classic Bluetooth.
[0132] When the priority of the executing event EVENT1 is lower than the priority of the event EVENT2 to be executed, then execute the event EVENT2 to be executed, notify the executing event EVENT1 to stop execution, and postpone the scheduling of the executing event EVENT1 according to the following principles;
[0133] When the executing event EVENT1 is an event that does not run in equal time slots:
[0134] When T1_END > T2_END, then set as follows:
[0135] T1_START = T2_END;
[0136] Adjust the start time of the executing event EVENT1 so that the event EVENT2 to be executed occupies a part of the time period of the executing event EVENT1, and re-insert the adjusted executing event EVENT1 into the non-equal-time scheduling container.
[0137] When T1_END < T2_END, then set as follows:
[0138] T1_START = T1_START + EVENT1_ITVL;
[0139] T1_END = T1_END + EVENT1_ITVL;
[0140] Adjust the start time and end time of the executing event EVENT1 so that the entire time sequence of the executing event EVENT1 is shifted backward by a third time interval, and the third time interval is the time interval of the executing event EVENT1, and re-insert the shifted executing event EVENT1 into the non-equal-time scheduling container.
[0141] When the executing event EVENT1 is an event that runs in equal time slots, no processing is performed.
[0142] When the priority of the executing event EVENT1 is higher than the priority of the event EVENT2 to be executed, or the priority of the executing event EVENT1 is the same as the priority of the event EVENT2 to be executed, then execute the executing event EVENT1, and delay the scheduling of the event EVENT2 to be executed according to the following principles.
[0143] When the event EVENT2 to be executed is a non-equal time slot running event:
[0144] When T1_END < T2_END, then set as follows:
[0145] T2_START = T1_END;
[0146] Adjust the start time of the event EVENT2 to be executed so that the executing event EVENT1 occupies a part of the time period of the event EVENT2 to be executed, and re-insert the adjusted event EVENT2 to be executed into the non-equal time scheduling container.
[0147] When T1_END > T2_END, then set as follows:
[0148] T2_START = T2_START + EVENT2_ITVL;
[0149] T2_END = T2_END + EVENT2_ITVL;
[0150] Adjust the start time and end time of the event EVENT2 to be executed so that the entire time sequence of the event EVENT2 to be executed is shifted backward by the fourth time interval, and the fourth time interval is the time interval of the event EVENT2 to be executed, and re-insert the shifted event EVENT2 to be executed into the non-equal time scheduling container.
[0151] When the event EVENT2 to be executed is an equal time slot running event, no processing is performed.
[0152] In some embodiments, the dual-mode Bluetooth working time sequence control method further includes:
[0153] Receive the first feedback signal of the scheduling event; the scheduling event is the executing event after scheduling judgment;
[0154] Based on the first feedback signal, judge whether the equal time slot of the scheduling event has expired;
[0155] If so, clear the record of the scheduling event.
[0156] In some embodiments, the dual-mode Bluetooth working time sequence control method further includes:
[0157] Receive the second feedback signal of the scheduling event;
[0158] Based on the second feedback signal, determining whether the execution action of the scheduling event is completed;
[0159] If so, the scheduling event will be recorded and cleared.
[0160] In some embodiments, the dual-mode Bluetooth working timing control method further includes:
[0161] receiving a third feedback signal of the scheduling event;
[0162] Based on the third feedback signal, determine whether the scheduling event is to be renewed; renewal means that the event continues to occupy the execution time;
[0163] If so, continue recording the scheduling event.
[0164] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0165] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0166] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0167] Figure 3 Schematic diagram of a dual-mode Bluetooth working timing control device provided in an embodiment of the present application. Figure 3 As shown, the dual-mode Bluetooth working timing control device includes:
[0168] The inserting module 301 is configured to, upon receiving an event to be inserted, insert the event to be inserted into an isochronous scheduling container if the event to be inserted is an event running in equal time slots, or insert the event to be inserted into a non-isochronous scheduling container if the event to be inserted is an event running in non-equal time slots;
[0169] The determination module 302 is configured to, when detecting that an event is inserted into the isochronous scheduling container or the non-isochronous scheduling container, determine the event to be executed from the isochronous scheduling container and the non-isochronous scheduling container, and record the event to be executed into the event queue to be executed;
[0170] The scheduling module 303 is configured to perform scheduling based on the pending events and the executing events in the pending event queue.
[0171] The embodiment of the present application can realize the reasonable allocation and control of the dual-mode Bluetooth timing through the insertion module, the determination module and the scheduling module, and can meet the dual-mode Bluetooth operation scenario.
[0172] In some embodiments, each event of the dual-mode Bluetooth corresponds to a preset priority;
[0173] The insertion module 301 is specifically configured to, if the event to be inserted is an event running in an isochronous time slot, insert the event to be inserted into the corresponding isochronous time slot in the isochronous scheduling container according to the event type; the isochronous time slot is an isochronous time slot reserved according to the event type;
[0174] The insertion module 301 is specifically configured to compare whether the time period of the event to be inserted overlaps with the time period of the event in the non-isochronous scheduling container; if so, the event that overlaps with the event to be inserted is set as the first event, and the event to be inserted is inserted into the non-isochronous scheduling container according to the priority of the event to be inserted and the priority of the first event; if not, the event to be inserted is inserted into the non-isochronous scheduling container according to the principle of insertion.
[0175] Further, the insertion module 301 is specifically configured to compare the priority of the event to be inserted with the first event; when the priority of the event to be inserted is the same as the priority of the first event, offset the event to be inserted backward by a first time interval, and reinsert the offset event to be inserted into the non-isochronous scheduling container; when the priority of the event to be inserted is different from the priority of the first event, determine the event with a higher priority between the event to be inserted and the first event as a high priority event, and determine the event with a lower priority between the event to be inserted and the first event as a low priority event; adjust the start time or end time of the low priority event so that the high priority event occupies part of the time period of the low priority event, or, after offsetting the low priority event backward by a second time interval, reinsert the offset low priority event into the non-isochronous scheduling container.
[0176] Further, the insertion module 301 is specifically configured to, when the time period of the low priority event partially overlaps with the time period of the high priority event, adjust the start time or end time of the low priority event so that the high priority event occupies part of the time period of the low priority event;
[0177] Furthermore, the insertion module 301 is specifically configured to, when the time period of the high-priority event completely covers the time period of the low-priority event, adjust the start time and end time of the low-priority event so that the time period of the low-priority event is offset backward by a second time interval, and reinsert the offset low-priority event into the non-isochronous scheduling container.
[0178] In some embodiments, the determination module 302 is specifically configured to determine the event with the earliest start time from the isochronous scheduling container and the non-isochronous scheduling container, and if the event with the earliest start time is unique, determine the event with the earliest start time as the event to be executed;
[0179] If there are multiple events with the earliest start time, compare the priorities of the multiple events with the earliest start time;
[0180] If the priorities of multiple events with the earliest start times are different, the event with the earliest start time with the highest priority is determined as the event to be executed;
[0181] If the priorities of multiple events with the earliest start times are the same, the event with the earliest start time corresponding to the low-power Bluetooth in the non-isochronous scheduling container is determined as the event to be executed;
[0182] If the event to be executed is in the non-isochronous scheduling container, after the event to be executed is removed from the non-isochronous scheduling container, the event to be executed is recorded in the queue of events to be executed.
[0183] In some embodiments, the scheduling module 303 is specifically configured to detect whether there is an event being executed; if there is no event being executed, execute the event to be executed;
[0184] If there is an event being executed, and the type of the event being executed is the same as the type of the event to be executed, then the event being executed will continue to be executed;
[0185] If there is an event being executed, and the type of the event being executed is different from the type of the event to be executed, then the priority of the event being executed is compared with the priority of the event to be executed;
[0186] If the priority of the event being executed is lower than the priority of the event to be executed, the event to be executed will be executed, and the execution of the event being executed will be stopped, and the scheduling of the event being executed will be postponed;
[0187] If the priority of the event being executed is not lower than the priority of the event to be executed, the event being executed is executed and the event to be executed is postponed.
[0188] Further, the scheduling module 303 is specifically configured to, if the executing event is an event that runs in non-equidistant time slots, adjust the start time of the executing event so that the event to be executed occupies a part of the time period of the executing event, reinsert the adjusted executing event into the non-equidistant scheduling container, or shift the executing event backward by a third time interval, and reinsert the shifted executing event into the non-equidistant scheduling container;
[0189] Further, the scheduling module 303 is specifically configured to, if the event to be executed is an event that runs in non-equivalent time slots, adjust the start time of the event to be executed so that the event being executed occupies a partial time period of the event to be executed, and reinsert the adjusted event to be executed into the non-equivalent scheduling container, or offset the event to be executed backward by a fourth time interval, and reinsert the offset event to be executed into the non-equivalent scheduling container.
[0190] Based on the same inventive concept, an embodiment of the present application provides a Bluetooth device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0191] The Bluetooth device provided in the embodiment of the present application has the same inventive concept and the same beneficial effects as the previous embodiments. The contents not shown in detail in the Bluetooth device can be referred to the previous embodiments and will not be repeated here.
[0192] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and is characterized in that when the computer program is executed by a processor, the steps of the above method are implemented.
[0193] The computer-readable storage medium provided in the embodiment of the present application has the same inventive concept and the same beneficial effects as the previous embodiments. The contents not shown in detail in the computer-readable storage medium can be referred to the previous embodiments and will not be repeated here.
[0194] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0195] If the integrated module / 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 (e.g., a computer-readable storage medium). Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. Computer-readable media may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0196] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A dual-mode Bluetooth working timing control method, characterized in that: The method comprises: When an event to be inserted is received, if the event to be inserted is an event running in equal time slots, it is inserted into an isochronous scheduling container; if the event to be inserted is an event running in unequal time slots, it is inserted into a non-isochronous scheduling container; wherein the isochronous scheduling container is used to store and manage: paging events, query events of classic Bluetooth and ESCO logical links, SCO logical links, and ACL logical links of connection events of classic Bluetooth; the non-isochronous scheduling container is used to store and manage: query scanning events, paging scanning events of classic Bluetooth and initiation events, announcement events, scanning events, and connection events of low-power Bluetooth; When it is detected that an event is inserted into the isochronous scheduling container or the non-isochronous scheduling container, determining a to-be-executed event from the isochronous scheduling container and the non-isochronous scheduling container, and recording the to-be-executed event into a to-be-executed event queue; Scheduling is performed based on the to-be-executed events and the events being executed in the to-be-executed event queue.
2. The method according to claim 1, characterized in that: Each event of dual-mode Bluetooth corresponds to a preset priority; If the event to be inserted is an event that runs in equal time slots, inserting it into the isochronous scheduling container includes: If the event to be inserted is an event that runs in an isochronous time slot, insert the event to be inserted into the corresponding isochronous time slot in the isochronous scheduling container according to the event type; the isochronous time slot is an isochronous time slot reserved according to the event type; And, if the event to be inserted is an event that runs in non-equidistant time slots, inserting it into the non-equidistant scheduling container includes: Compare whether the time period of the event to be inserted overlaps with the time period of the event in the non-isochronous scheduling container; If yes, setting the event overlapping with the event to be inserted as the first event, and inserting the event to be inserted into the non-isochronous scheduling container according to the priority of the event to be inserted and the priority of the first event; If not, the event to be inserted is inserted into the non-isochronous scheduling container according to the insertion principle.
3. The method according to claim 2, characterized in that Inserting the event to be inserted into the non-isochronous scheduling container according to the priority of the event to be inserted and the priority of the first event includes: Comparing the priority of the event to be inserted with that of the first event; When the priority of the event to be inserted is the same as the priority of the first event, the event to be inserted is shifted backward by a first time interval, and the shifted event to be inserted is reinserted into the non-isochronous scheduling container; When the priority of the event to be inserted is different from the priority of the first event, determining the event with a higher priority between the event to be inserted and the first event as a high priority event, and determining the event with a lower priority between the event to be inserted and the first event as a low priority event; Adjust the start time or end time of the low priority event so that the high priority event occupies part of the time period of the low priority event, or, after shifting the low priority event backward for a second time interval, reinsert the shifted low priority event into the non-isochronous scheduling container.
4. The method according to claim 3, characterized in that The method further comprises: adjusting the start time or the end time of the low priority event so that the high priority event occupies part of the time period of the low priority event, or shifting the low priority event backward by a second time interval and reinserting the shifted low priority event into the non-isochronous scheduling container, comprising: When the time period of the low priority event partially overlaps with the time period of the high priority event, adjusting the start time or end time of the low priority event so that the high priority event occupies part of the time period of the low priority event; When the time period of the high-priority event completely covers the time period of the low-priority event, the start time and the end time of the low-priority event are adjusted so that the time period of the low-priority event is shifted backward by a second time interval, and the shifted low-priority event is reinserted into the non-isochronous scheduling container.
5. The method according to claim 1, characterized in that Determining the events to be executed from the isochronous scheduling container and the non-isochronous scheduling container includes: Determine an event with the earliest start time from the isochronous scheduling container and the non-isochronous scheduling container; If the event with the earliest start time is unique, the event with the earliest start time is determined as the event to be executed; If there are multiple events with the earliest start time, compare the priorities of the multiple events with the earliest start time; If the priorities of multiple events with the earliest start times are different, the event with the earliest start time with the highest priority is determined as the event to be executed; If the priorities of multiple events with the earliest start times are the same, determining the event with the earliest start time corresponding to the low-power Bluetooth in the non-isochronous scheduling container as the event to be executed; And, recording the pending event into a pending event queue, including: If the event to be executed is in the non-isochronous scheduling container, after the event to be executed is removed from the non-isochronous scheduling container, the event to be executed is recorded in a queue of events to be executed.
6. The method according to any one of claims 1 to 5, characterized in that: Scheduling based on the pending events and the executing events in the pending event queue includes: Check if there is an event being executed; If the event being executed does not exist, executing the event to be executed; If there is an event being executed, and the type of the event being executed is the same as the type of the event to be executed, then continue to execute the event being executed; If there is an event being executed, and the type of the event being executed is different from the type of the event to be executed, comparing the priorities of the event being executed and the event to be executed; If the priority of the event being executed is lower than the priority of the event to be executed, the event to be executed is executed, and the execution of the event being executed is stopped, and the scheduling of the event being executed is postponed; If the priority of the event being executed is not lower than the priority of the event to be executed, the event being executed is executed and the event to be executed is postponed for scheduling.
7. The method according to claim 6, characterized in that The executing event is postponed for scheduling, comprising: if the executing event is an event running in non-equidistant time slots, adjusting the start time of the executing event so that the event to be executed occupies a part of the time period of the executing event, reinserting the adjusted executing event into the non-equidistant scheduling container, or shifting the executing event backward by a third time interval, reinserting the shifted executing event into the non-equidistant scheduling container; The event to be executed is postponed for scheduling, including: if the event to be executed is an event running in non-equidistant time slots, adjusting the start time of the event to be executed so that the event being executed occupies a partial time period of the event to be executed, reinserting the adjusted event to be executed into the non-equidistant scheduling container, or shifting the event to be executed backward by a fourth time interval, and reinserting the shifted event to be executed into the non-equidistant scheduling container.
8. A dual-mode Bluetooth working timing control device, characterized in that: The device comprises: The insertion module is configured to, when receiving an event to be inserted, insert the event to be inserted into an isochronous scheduling container if the event to be inserted is an event running in equal time slots, and insert the event to be inserted into a non-isochronous scheduling container if the event to be inserted is an event running in unequal time slots; wherein the isochronous scheduling container is used to store and manage: paging events, query events of classic Bluetooth and ESCO logical links, SCO logical links, and ACL logical links of connection events of classic Bluetooth; the non-isochronous scheduling container is used to store and manage: query scanning events, paging scanning events of classic Bluetooth and initiation events, announcement events, scanning events, and connection events of low-power Bluetooth; A determination module configured to, when detecting that an event is inserted into the isochronous scheduling container or the non-isochronous scheduling container, determine an event to be executed from the isochronous scheduling container and the non-isochronous scheduling container, and record the event to be executed into a queue of events to be executed; The scheduling module is configured to perform scheduling based on the to-be-executed events and the events being executed in the to-be-executed event queue.
9. A Bluetooth device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
