A communication module switching method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202210952827.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-09
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2042-08-09
AI Technical Summary
[0003]目前,单一的使用一种短程通信的方式进行数据传输,无法满足用户对于数据传输的高要求
[0043]采用本发明实施例的方案,可以获取数据发送端与该数据接收端之间的开机时长偏差,通过与数据发送端建立连接的第一短程通信模块接收该数据发送端发送的目标数据,该目标数据中包括该目标数据发送时该数据发送端的第一开机时长,根据该第一开机时长和该开机时长偏差,确定该目标数据发送时该数据接收端的第二开机时长,确定接收该目标数据时数据接收端的第三开机时长,基于该第二开机时长和该第三开机时长,计算该目标数据的传输耗时,若该传输耗时大于预设的传输耗时阈值,通过第二短程通信模块与该数据发送端建立连接,通过该第二短程通信模块进行数据传输;由于在本发明实施例中,基于数据发送端与数据接收端之间在传输目标数据对应的数据发送端的开机时长和数据接收端的开机时长,确定出传输目标数据时的耗时,并根据耗时动态的切换数据接收端中与数据发送端进行通信的短程通信模块,因此,可以实现不同短程通信方式的自动切换,无需用户手动设置,改善用户的数据传输体验,实现在多种场景下都可以进行低延时高品质的数据传输。
Smart Images

Figure CN117156537B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and more specifically to a communication module switching method, apparatus, electronic device, and storage medium. Background Technology
[0002] With the improvement of living standards and the development of science and technology, devices that can transmit data through short-range communication are being used more and more widely in people's lives, and people's requirements for data transmission between devices are getting higher and higher.
[0003] Currently, relying solely on a single short-range communication method for data transmission cannot meet users' high demands for data transfer. For example, some short-range communication methods suffer from high latency and data corruption due to compression caused by low bandwidth. Others are prone to significant latency due to issues such as co-frequency interference and contention for transmission channel resources. Therefore, using only one short-range communication method will negatively impact the user's data transmission experience and cannot guarantee low-latency, high-quality data transmission in various scenarios. Summary of the Invention
[0004] This invention provides a communication module switching method, apparatus, electronic device, and storage medium, which can realize automatic switching between different short-range communication methods, improve the user's data transmission experience, and enable low-latency, high-quality data transmission in various scenarios.
[0005] This invention provides a communication module switching method, applied to a data receiving end, comprising:
[0006] Obtain the power-on time deviation between the data sending end and the data receiving end;
[0007] The first short-range communication module, which establishes a connection with the data sending end, receives target data sent by the data sending end. The target data includes the first power-on duration of the data sending end when the target data is sent.
[0008] Based on the first power-on duration and the power-on duration deviation, the second power-on duration of the data receiving end is determined when the target data is sent;
[0009] Determine the third power-on duration of the data receiving end when receiving the target data, and calculate the transmission time of the target data based on the second power-on duration and the third power-on duration;
[0010] If the transmission time exceeds a preset transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data transmission is performed through the second short-range communication module.
[0011] Optionally, embodiments of the present invention provide a communication module switching device, applied at a data receiving end, comprising:
[0012] The duration deviation acquisition unit is used to acquire the power-on duration deviation between the data sending end and the data receiving end;
[0013] A data receiving unit is configured to receive target data sent by the data sending end through a first short-range communication module that establishes a connection with the data sending end, wherein the target data includes a first power-on duration of the data sending end when the target data is sent.
[0014] The second duration determination unit is used to determine the second power-on duration of the data receiving end when the target data is sent, based on the first power-on duration and the power-on duration deviation.
[0015] A transmission time calculation unit is used to determine the third power-on duration of the data receiving end when receiving the target data, and to calculate the transmission time of the target data based on the second power-on duration and the third power-on duration.
[0016] The communication module switching unit is used to establish a connection with the data sending end through the second short-range communication module and perform data transmission through the second short-range communication module if the transmission time is greater than a preset transmission time threshold.
[0017] Optionally, the communication module switching unit is used to maintain the connection between the first short-range communication module and the data sending end if the transmission time is greater than a preset transmission time threshold.
[0018] A connection is established with the data sending end through the second short-range communication module, and data transmission is performed through the second short-range communication module;
[0019] The communication module switching device provided in this embodiment of the invention further includes a first communication module continuing transmission unit, which is used to perform transmission time calculation through a first short-range communication module that maintains a connection with the data sending end, and determine the new transmission time of the first short-range communication module when transmitting data;
[0020] If the new transmission time is not greater than the switching time threshold, the connection between the second short-range communication module and the data sending end is disconnected, and data transmission continues through the first short-range communication module.
[0021] Optionally, the duration deviation acquisition unit is used to acquire the time synchronization data packet corresponding to the time synchronization moment, wherein the time synchronization data packet includes the power-on duration of the data sending end and the data receiving end;
[0022] Based on the power-on duration, calculate the power-on duration deviation between the data sending end and the data receiving end corresponding to the time interval.
[0023] Optionally, the duration deviation acquisition unit is used to acquire the first time synchronization power-on duration of the data receiving end at the time of the time synchronization.
[0024] The first time synchronization power-on duration is sent to the data sending end, triggering the data sending end to determine the second time synchronization power-on duration when the first time synchronization power-on duration is received. An initial time synchronization data packet is generated based on the first time synchronization power-on duration and the second time synchronization power-on duration. When sending the initial time synchronization data packet to the data receiving end, the third time synchronization power-on duration of the data sending end at the sending time is added to the initial time synchronization data packet to obtain the time synchronization data packet.
[0025] Receive the time synchronization data packet.
[0026] Optionally, the communication module switching device provided in this embodiment of the invention further includes a fourth duration determination unit, used to determine the fourth time synchronization power-on duration of the data receiving end when receiving the time synchronization data packet;
[0027] The duration deviation acquisition unit is used to calculate the power-on duration deviation between the data sending end and the data receiving end corresponding to the time synchronization time based on the first time synchronization power-on duration, the second time synchronization power-on duration, the third time synchronization power-on duration and the fourth time synchronization power-on duration in the time synchronization data packet.
[0028] Optionally, the communication module switching device provided in this embodiment of the invention further includes a bidirectional transmission time calculation unit, used to determine the bidirectional data transmission time between the data receiving end and the data sending end based on the first time synchronization power-on duration, the second time synchronization power-on duration, the third time synchronization power-on duration and the fourth time synchronization power-on duration in the time synchronization data packet;
[0029] The duration deviation acquisition unit is used to calculate the power-on duration deviation between the data sending end and the data receiving end corresponding to the time synchronization moment, based on the bidirectional data transmission time and the first time synchronization power-on duration, the second time synchronization power-on duration, the third time synchronization power-on duration and the fourth time synchronization power-on duration in the time synchronization data packet, if the bidirectional data transmission time is not greater than a preset bidirectional data transmission time threshold.
[0030] Optionally, the communication module switching unit is used to, if the transmission time is greater than a preset transmission time threshold, count the reference transmission time of each time the data sent by the data sending end is received through the first short-range communication module within a preset time after the transmission of the target data.
[0031] If the transmission time for each reference is greater than the transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data is transmitted through the second short-range communication module.
[0032] Optionally, the communication module switching unit is used to, if the transmission time is greater than a preset transmission time threshold, count the reference transmission time of each time the data sent by the data sending end is received through the first short-range communication module within a preset time after the transmission of the target data.
[0033] Calculate the average transmission time corresponding to the reference transmission time;
[0034] If the average transmission time is greater than the transmission time threshold, a connection is established with the data sending end through the second short-range communication module, and data is transmitted through the second short-range communication module.
[0035] Optionally, the target data is audio frame data, the data sending end is an audio source sending end, and the data receiving end is an audio playback end.
[0036] Optionally, the communication module switching device provided in this embodiment of the invention further includes an audio frame processing unit, used to determine the difference audio frame between the second audio frame data and the first audio frame data based on the first audio frame data received when transmitting audio data through the first short-range communication module and the second audio frame data received when switching from the first short-range communication module to the second short-range communication module.
[0037] Based on the difference audio frames, speed-changing but pitch-unchanged processing is performed to obtain the processed difference audio frames.
[0038] Audio is played based on the processed differential audio frames and the second audio frame data.
[0039] Optionally, the first short-range communication module is a WiFi communication module, and the second short-range communication module is a Bluetooth communication module.
[0040] Accordingly, embodiments of the present invention also provide an electronic device, including a memory and a processor; the memory stores an application program, and the processor is used to run the application program in the memory to perform the steps in any of the communication module switching methods provided in the embodiments of the present invention.
[0041] Accordingly, embodiments of the present invention also provide a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in any of the communication module switching methods provided in embodiments of the present invention.
[0042] Furthermore, embodiments of the present invention also provide a computer program product, including a computer program or instructions, wherein when the computer program or instructions are executed by a processor, they implement the steps in any of the communication module switching methods provided in embodiments of the present invention.
[0043] Using the scheme of this embodiment of the invention, the power-on duration deviation between the data sending end and the data receiving end can be obtained. A first short-range communication module connected to the data sending end receives target data sent by the data sending end. The target data includes a first power-on duration of the data sending end when the target data is sent. Based on the first power-on duration and the power-on duration deviation, a second power-on duration of the data receiving end when the target data is sent is determined. A third power-on duration of the data receiving end when receiving the target data is determined. Based on the second and third power-on durations, the transmission time of the target data is calculated. If the transmission time is greater than a preset transmission time... A threshold is set, and a connection is established with the data sender through a second short-range communication module. Data transmission is then performed through this second short-range communication module. In this embodiment of the invention, the transmission time of the target data is determined based on the power-on duration of the data sender and the data receiver corresponding to the transmission target data. The short-range communication module communicating with the data sender in the data receiver is dynamically switched according to the transmission time. Therefore, automatic switching between different short-range communication methods can be achieved without manual settings by the user, improving the user's data transmission experience and enabling low-latency, high-quality data transmission in various scenarios. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a schematic diagram of a scenario for the communication module switching method provided in an embodiment of the present invention;
[0046] Figure 2 This is a flowchart of the communication module switching method provided in an embodiment of the present invention;
[0047] Figure 3 This is a flowchart illustrating the process of obtaining the boot-up duration scene according to an embodiment of the present invention;
[0048] Figure 4 This is a schematic diagram of data interaction between a data sending end and a data receiving end provided in an embodiment of the present invention;
[0049] Figure 5This is a schematic diagram illustrating the technical implementation of determining transmission time provided in an embodiment of the present invention;
[0050] Figure 6 This is a schematic diagram of the communication module switching device provided in an embodiment of the present invention;
[0051] Figure 7 This is another structural schematic diagram of the communication module switching device provided in an embodiment of the present invention;
[0052] Figure 8 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0053] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0054] This invention provides a communication module switching method, apparatus, electronic device, and computer-readable storage medium. Specifically, this invention provides a communication module switching method applicable to a communication module switching apparatus, which can be integrated into an electronic device.
[0055] The electronic device can be a terminal or other device, including but not limited to mobile terminals and fixed terminals. For example, mobile terminals include but are not limited to smartphones, smartwatches, tablets, laptops, smart vehicles, etc., while fixed terminals include but are not limited to desktop computers, smart TVs, etc.
[0056] The electronic device can also be a server or other similar device. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, but it is not limited to these.
[0057] The communication module switching method of this invention can be implemented by the terminal or by both the terminal and the server.
[0058] The following example illustrates the method of switching communication modules using both a terminal and a server.
[0059] like Figure 1As shown, the communication module switching system provided in this embodiment of the invention includes a terminal 10 and a server 20, etc.; the terminal 10 and the server 20 are connected through a network, such as through a wired or wireless network, etc., wherein the terminal 10 can exist as a terminal for a user to request data from the server 20.
[0060] The server 20 can be used to store target data and send target data to the terminal 10, etc.
[0061] Terminal 10 can be used to obtain the power-on time deviation between server 20 and terminal 10. It receives target data sent by server 20 through a first short-range communication module that establishes a connection with server 20. The target data includes the first power-on time of server 20 when the target data is sent. Based on the first power-on time and the power-on time deviation, the second power-on time of terminal 10 when the target data is sent is determined. The third power-on time of terminal 10 when the target data is received is determined. Based on the second power-on time and the third power-on time, the transmission time of the target data is calculated. If the transmission time is greater than a preset transmission time threshold, a connection is established with server 20 through the second short-range communication module, and data is transmitted through the second short-range communication module.
[0062] The following sections provide detailed descriptions of each example. It should be noted that the order in which the embodiments are described is not intended to limit the preferred order of the embodiments.
[0063] This invention will be described from the perspective of a communication module switching device, which can be integrated into a server or terminal.
[0064] like Figure 2 As shown, the specific process of the communication module switching method in this embodiment can be as follows:
[0065] 201. Obtain the power-on time deviation between the data sending end and the data receiving end.
[0066] In this context, the data sender is an electronic device capable of sending data to other devices. The data sender may store data requested by other devices, or it may retrieve requested data from certain storage locations based on requests from other devices.
[0067] Specifically, a data receiver is an electronic device capable of requesting data from a data sender and receiving data sent by the data sender. Generally, a data receiver can support at least two different short-range communication methods.
[0068] For example, the data sender can be a smartphone, and the data receiver can be a smart vehicle. The smart vehicle can have at least two short-range communication functions, such as WiFi, Bluetooth, NFC, and infrared transmission. The smart vehicle can actively request certain data from the smartphone based on user operations, or it can passively receive data sent by the smartphone. When sending data, the smartphone can select certain data from its own stored data or download data from the internet, and so on.
[0069] The boot-up time deviation refers to the difference in boot-up time between the data sending end and the data receiving end.
[0070] It is understandable that the power-on times of the data sending end and the data receiving end may not be the same. Correspondingly, during data transmission, the time elapsed from the power-on time of the data sending end to that time at the same moment will also differ from the time elapsed for the data receiving end. To quantify this difference, the power-on time deviation can be calculated at a specific time. That is, the step "obtaining the power-on time deviation between the data sending end and the data receiving end" can include:
[0071] Obtain the time synchronization data packet corresponding to the current time. The time synchronization data packet includes the power-on duration of the data sender and the data receiver.
[0072] Based on the power-on duration, calculate the power-on duration deviation between the data sending end and the data receiving end corresponding to the time point.
[0073] Among them, the time synchronization data packet can be a data packet sent from the data sender to the data receiver.
[0074] In addition to the power-on duration of the data sender and receiver, the time synchronization data packet may not include other data. Alternatively, in addition to the power-on duration of the data sender and receiver, the time synchronization data packet may also include the target data that the data sender needs to send to the data receiver in order to save transmission resources.
[0075] It is understood that the time synchronization data packet is not necessarily sent by the data sender at the exact time of time synchronization; it can also be generated and sent by the data sender based on certain operations at the time of time synchronization. In some optional embodiments, the step "obtaining the time synchronization data packet corresponding to the time synchronization moment" may specifically include:
[0076] Obtain the first time synchronization power-on duration of the time synchronization data receiving end;
[0077] The first time synchronization power-on duration is sent to the data sending end, triggering the data sending end to determine the second time synchronization power-on duration when the first time synchronization power-on duration is received. An initial time synchronization data packet is generated based on the first time synchronization power-on duration and the second time synchronization power-on duration. When sending the initial time synchronization data packet to the data receiving end, the third time synchronization power-on duration of the data sending end at the sending time is added to the initial time synchronization data packet to obtain the time synchronization data packet.
[0078] Receive time synchronization data packets.
[0079] In other words, such as Figure 3 As shown, at the time synchronization point, the data receiving end determines the time T1 that has elapsed since its own power-on, i.e., the first time synchronization power-on duration, and sends T1 to the data sending end. After receiving T1, the data sending end determines the time T2 that has elapsed since its own power-on at the time of receiving T1, i.e., the second time synchronization power-on duration.
[0080] The data sender assembles T1 and T2 into an initial time synchronization data packet, ready to send it via short-range communication. During transmission, the data sender adds the elapsed time T3 since its power-on (the third time since power-on) to the initial time synchronization data packet, thus obtaining the final time synchronization data packet. The data sender then sends the time synchronization data packet to the data receiver.
[0081] In practical applications, time synchronization can be calculated using the time difference between the data receiver and the data sender based on the power-on duration when the time synchronization data packet is received by the data receiver and the time intervals T1, T2, and T3 in the time synchronization data packet. Therefore, before the step "calculate the power-on duration deviation between the data sender and the data receiver at the corresponding time synchronization moment based on the power-on duration", the communication module switching method provided in this embodiment of the invention may further include:
[0082] Determine the fourth time synchronization startup duration of the data receiving end when receiving time synchronization data packets;
[0083] Accordingly, the step "calculate the power-on duration deviation between the data sending end and the data receiving end corresponding to the time interval based on the power-on duration" can specifically include:
[0084] Based on the first, second, third, and fourth time synchronization startup durations in the time synchronization data packet, calculate the startup duration deviation between the data sending end and the data receiving end corresponding to the time synchronization moment.
[0085] For example, assuming that the uplink and downlink data transmission are symmetrical, i.e., the network round-trip time is equal, the power-on time deviation Toffset can be calculated using the following formula:
[0086] Toffset = ((T2+T3)-(T1+T4)) / 2
[0087] At this point, Toffset represents the difference between the power-on time of the data sending end and the power-on time of the data receiving end.
[0088] Alternatively, the boot time deviation Toffset can also be calculated using the following formula:
[0089] Toffset = ((T1+T4)-(T2+T3)) / 2
[0090] At this point, Toffset represents the difference between the power-on time of the data receiving end and the power-on time of the data sending end.
[0091] The power-on durations of the first, second, third, and fourth time synchronization pairs, as well as the power-on duration deviation, can be expressed in milliseconds. This embodiment of the invention does not limit the form of this expression.
[0092] It is understandable that, considering the impact of network fluctuations and uplink / downlink asymmetry, when calculating the power-on time deviation, the time spent transmitting data back and forth between the data sending and receiving ends can be considered, and the power-on time deviation can be averaged or otherwise processed. That is, before the step "calculating the power-on time deviation between the data sending end and the data receiving end corresponding to the time synchronization time based on the first, second, third, and fourth time synchronization power-on times in the time synchronization data packet," the communication module switching method provided in this embodiment of the invention may further include:
[0093] Based on the first, second, third, and fourth time synchronization startup durations in the time synchronization data packet, the bidirectional data transmission time between the data receiver and the data sender is determined.
[0094] Specifically, the bidirectional data transmission time Tdelay can be calculated using the following formula:
[0095] Tdelay = T4 - T1 - (T3 - T2)
[0096] In other words, Tdelay actually represents the total time for transmitting a set of data between the data receiving end and the data sending end, minus the time for the data sending end to perform packet assembly and other processing. That is, Tdelay represents the time it takes for data to be transmitted back and forth between the data sending end and the data receiving end once.
[0097] Accordingly, the step "calculating the power-on duration deviation between the data sender and receiver at the corresponding time synchronization moment based on the first, second, third, and fourth time synchronization power-on durations in the time synchronization data packet" can specifically include:
[0098] If the bidirectional data transmission time is not greater than the preset bidirectional data transmission time threshold, based on the bidirectional data transmission time and the first, second, third, and fourth time synchronization startup times in the time synchronization data packet, calculate the startup time deviation between the data sending end and the data receiving end corresponding to the time synchronization moment.
[0099] In practical applications, if the bidirectional data transmission time is not greater than the preset bidirectional data transmission time threshold, the calculation error for the boot time deviation can be considered small. In this case, the calculated value can be directly used as the boot time deviation.
[0100] If the bidirectional data transmission time exceeds the preset bidirectional transmission time threshold, it can be considered that the calculation error of the boot time deviation is large. In this case, the historical boot time deviations obtained from several previous calculations can be obtained, and the average value of the current boot time deviation and the historical boot time deviations can be calculated. The result of the average value calculation is taken as the true boot time deviation to reduce the impact of factors such as network fluctuations.
[0101] 202. Receive target data sent by the data sender through the first short-range communication module that establishes a connection with the data sender. The target data includes the first power-on duration of the data sender when the target data is sent.
[0102] Among them, the first short-range communication module is a module in the data receiving end that can realize short-range communication function.
[0103] Specifically, the target data can be specific data requested by the data receiver from the data sender, or it can be data sent by the data sender to the data receiver.
[0104] Optionally, the target data can be audio data, text data, image data, video data, etc. The embodiments of the present invention do not limit the form and content of the target data.
[0105] The first power-on duration is the time elapsed from the power-on time of the data sending end to the time when the target data is sent.
[0106] In some optional embodiments, the target data can be audio frame data, and correspondingly, the data sender is the audio source sender, which can send audio frame data to the data receiver. For example, a user can choose to send a song or a chat voice message to the data receiver from the data sender. In this case, the target data is the audio frame data corresponding to the song or chat voice message, and the data sender is the audio source sender.
[0107] 203. Based on the first power-on duration and the power-on duration deviation, determine the second power-on duration of the data receiving end when the target data is sent.
[0108] The second power-on duration is the time elapsed from the moment the data receiver powers on until the moment the target data is sent.
[0109] Specifically, if Toffset represents the difference between the power-on time of the data receiver and the power-on time of the data sender, then the second power-on time can be obtained as follows:
[0110] Ts = Tnow + Toffset
[0111] Optionally, if Toffset represents the difference between the power-on time of the data sending end and the power-on time of the data receiving end, then the second power-on time can be obtained as follows:
[0112] Ts = Tnow - Toffset
[0113] Tnow represents the first boot duration.
[0114] Therefore, the second power-on duration Ts represents the time elapsed since the data receiver started transmitting the target data.
[0115] In some optional embodiments, the target data can be audio frame data. Correspondingly, the data sender is the audio source sender, which can send audio frame data to the data receiver. The data receiver is the audio playback end, which can receive and play the audio frame data sent by the audio source sender. For example, a user can select to send a segment of audio to the data receiver from the data sender. In this case, the target data is the audio frame data corresponding to this audio segment, the data sender is the audio source sender, and the data receiver is the audio playback end.
[0116] It is understood that, in this embodiment of the invention, the power-on duration deviation can be updated periodically or irregularly while the data receiving end and the data sending end maintain a connection. When calculating the second power-on duration, the latest power-on duration deviation is generally used at the time of calculation.
[0117] For example, such as Figure 3As shown, a thread can be set in the data receiving end to repeatedly execute the step of calculating the boot time deviation. It can be executed once every 10 seconds until the data receiving end disconnects from the data sending end.
[0118] To conserve thread processing resources on both the data sender and receiver, the data receiver can generate a first thread termination flag and send it to the data sender when it needs to disconnect from the data sender. Alternatively, the first thread termination flag can be generated at a preset time.
[0119] For example, technicians can set the data receiver to generate the first thread termination marker 10 minutes after the data sender and receiver establish a connection; or, technicians can set the data receiver to generate the first thread termination marker 10 times after the data sender and receiver calculate the boot time deviation.
[0120] In this embodiment of the invention, the first thread termination flag can instruct the data sending end and the data receiving end to terminate the thread used to calculate the boot time deviation.
[0121] 204. Determine the third power-on duration of the data receiving end when receiving target data, and calculate the transmission time of the target data based on the second power-on duration and the third power-on duration.
[0122] The third power-on duration is the time elapsed from the moment the data receiver powers on until it receives the target data.
[0123] Specifically, transmission time is the duration it takes for the target data to be transmitted from the data sender to the data receiver.
[0124] Optionally, if Toffset represents the difference between the power-on time of the data receiver and the power-on time of the data sender, then the transmission time Ta can be calculated using the following formula:
[0125] Ta = T0 - (Tnow + Toffset)
[0126] Optionally, if Toffset represents the difference between the power-on time of the data sender and the power-on time of the data receiver, then the transmission time Ta can be calculated using the following formula:
[0127] Ta = T0 - (Tnow - Toffset)
[0128] T0 is the third power-on duration.
[0129] In this embodiment of the invention, the thread that calculates the transmission time and the thread that calculates the boot time deviation can be two different threads.
[0130] like Figure 4As shown, both the data receiving end and the data sending end can include a discovery and connection unit, a data transmission unit, and a communication module selection unit. The discovery and connection module is primarily responsible for discovering and securely connecting to the wireless speaker. During the initial discovery, security authentication for different short-range communication methods (such as Wi-Fi and Bluetooth) is performed and paired, allowing the communication module selection unit to automatically and seamlessly switch between communication modules.
[0131] The data transmission unit is used for data transmission between the data sending end and the data receiving end.
[0132] Taking audio data as an example, the data transmission module is the audio transmission module. The audio transmission module primarily transmits the audio frame data from the audio source to the audio playback end via the first short-range communication module. The audio source acquires and losslessly encodes the sound, then transmits it to the audio playback end via a socket. Upon receiving the sound, the audio playback end performs decoding, error correction, buffering, and anti-jitter algorithms before playing it out.
[0133] The transmitted audio frame format can be: audio time header (64 bits, 8 bytes) + audio frame data. The audio time header is filled with the number of milliseconds Tnow that the audio source sending device has been powered on since the audio frame was generated. This data is used for the delay calculation of each audio frame in the communication module's optimization unit.
[0134] 205. If the transmission time exceeds the preset transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data is transmitted through the second short-range communication module.
[0135] The second short-range communication module is another module in the data receiver that can realize short-range communication function.
[0136] It should be noted that the latency of the short-range communication method corresponding to the first short-range communication module can be less than the latency of the corresponding short-range communication method of the second short-range communication module under normal transmission conditions. For example, the first short-range communication module can be a WiFi communication module, and the second short-range communication module can be a Bluetooth communication module.
[0137] Specifically, the transmission time threshold can be set by technicians or users based on actual application requirements. For example, it can be determined based on the delay difference between the first short-range communication module and the second short-range communication module.
[0138] For example, the first short-range communication module can be a WiFi communication module, and the second short-range communication module can be a Bluetooth communication module. In this case, the transmission latency threshold Tbt can be set as the delay time for the Bluetooth communication module to transmit audio. It is understandable that different devices may have different latency values for their Bluetooth communication modules. Depending on the device, the transmission latency threshold Tbt can be set between 120 and 200 milliseconds.
[0139] In practical applications, regardless of whether a second short-range communication module is used for data transmission, the data receiving end and the data sending end always maintain data transmission and reception through the first short-range communication module in order to calculate the transmission time of the first short-range communication module and to achieve faster seamless switching. That is, the step "If the transmission time exceeds a preset transmission time threshold, establish a connection with the data sending end through the second short-range communication module and transmit data through the second short-range communication module" can specifically include:
[0140] If the transmission time exceeds the preset transmission time threshold, maintain the connection between the first short-range communication module and the data sender.
[0141] A connection is established with the data sender through the second short-range communication module, and data is transmitted through the second short-range communication module.
[0142] In other words, regardless of which short-range communication module is used for data transmission, the first short-range communication module will maintain a continuous connection with the data sender.
[0143] Accordingly, the communication module switching method provided in this embodiment of the invention may further include:
[0144] The transmission time is calculated by the first short-range communication module that maintains a connection with the data sender, and the new transmission time of the first short-range communication module when transmitting data is determined.
[0145] If the new transmission time is not greater than the switching time threshold, disconnect the connection between the second short-range communication module and the data sender, and continue data transmission through the first short-range communication module.
[0146] The switching time threshold can be set by technicians or users based on actual application requirements. For example, it can be determined based on the delay difference between the first short-range communication module and the second short-range communication module.
[0147] For example, the first short-range communication module can be a WiFi communication module, and the second short-range communication module can be a Bluetooth communication module. In this case, the switching time threshold can be set to the delay time of the WiFi communication module transmitting audio.
[0148] For example, such as Figure 5 As shown, Ta can be monitored continuously for 10 seconds. If Ta is less than 80 (the switching time threshold) each time, or if the average value calculated by sliding filter (the average value after removing the fluctuations of the maximum and minimum values) is less than 80, then the system will switch back to using the audio data transmitted by the first short-range communication module, thereby ensuring that the latency is less than 80 milliseconds when returning to the first short-range communication module.
[0149] Optionally, when determining the new transmission time of the first short-range communication module during data transmission, the new transmission time can be calculated by transmitting the target data currently being transmitted by the second short-range communication module through the first short-range communication module, or by transmitting specific test data or empty data packets through the first short-range communication module.
[0150] In some optional embodiments, to avoid the impact of transmission time calculation errors and to prevent frequent switching of the short-range communication module from burdening the data receiver and data sender, the step "If the transmission time is greater than a preset transmission time threshold, establish a connection with the data sender through the second short-range communication module and perform data transmission through the second short-range communication module" may specifically include:
[0151] If the transmission time is greater than the preset transmission time threshold, the reference transmission time of each time the data sent by the data sending end is received through the first short-range communication module within the preset time after the target data is transmitted is counted.
[0152] If the transmission time for each reference is greater than the transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data is transmitted through the second short-range communication module.
[0153] For example, it could monitor Ta continuously for 5 seconds. If Ta is greater than Tbt each time, then switch to the second short-range communication module to transmit audio. At this time, notify the data sender to open the second short-range communication module to connect with the data receiver and transmit data.
[0154] In some alternative embodiments, the step "if the transmission time is greater than a preset transmission time threshold, establish a connection with the data sender through the second short-range communication module, and perform data transmission through the second short-range communication module" may specifically include:
[0155] If the transmission time is greater than the preset transmission time threshold, the reference transmission time of each time the data sent by the data sending end is received through the first short-range communication module within the preset time after the target data is transmitted is counted.
[0156] Calculate the average transmission time corresponding to the reference transmission time;
[0157] If the average transmission time exceeds the transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data transmission is performed through the second short-range communication module.
[0158] For example, it could involve continuously monitoring Ta for 5 seconds. If the average value of the transmission time for each reference (the average after removing fluctuations of the maximum and minimum values) calculated using sliding filtering, Ta, is greater than Tbt, then the system switches to the second short-range communication module to transmit audio. At this point, the data sender is notified to open the second short-range communication module to connect with the data receiver and transmit data.
[0159] Optionally, to enhance the user's audiovisual experience, such as Figure 5 As shown, during short-range communication module switching, audio fusion needs to be performed on both the pre- and post-switching audio modules before outputting the new audio. The communication module switching method provided in this embodiment of the invention may further include:
[0160] Based on the first audio frame data received when transmitting audio data through the first short-range communication module, and the second audio frame data received when switching from the first short-range communication module to the second short-range communication module, the difference audio frame between the second audio frame data and the first audio frame data is determined;
[0161] Based on the difference audio frames, speed-changing without pitch-changing processing is performed to obtain the processed difference audio frames;
[0162] Audio is played based on the processed difference audio frames and the second audio frame data.
[0163] During switching, the first audio frame data received during audio data transmission through the first short-range communication module is compared with the second audio frame data received during audio data transmission through the second short-range communication module. The frames that are the same but different are identified, and the frames that are different are accelerated and played back while maintaining the same pitch, thus enabling seamless switching.
[0164] Through the embodiments of the present invention, users will not perceive any stuttering or audio dropouts. If the second short-range communication module (e.g., Bluetooth) switches back to the first short-range communication module (e.g., WiFi), a data packet is sent to notify the audio source to turn off Bluetooth after the audio fusion is completed.
[0165] Specifically, variable speed without pitch processing can be achieved by using methods such as Synchronized Overlap-Add (SOLA), Synchronized Overlap-Add and Fixed Synthesis (SOLA-FS), resampling, interpolation and decimation of the signal spectrum to process audio frame data.
[0166] It should be noted that the data receiving end can generate a second thread termination flag and send it to the data sending end when it needs to disconnect from the data sending end.
[0167] In this embodiment of the invention, the second thread termination flag may be the same as or different from the first thread termination flag. The second thread termination flag can instruct the data sender and data receiver to terminate the thread used for data transmission.
[0168] As can be seen from the above, the embodiments of the present invention can obtain the power-on duration deviation between the data sending end and the data receiving end, and receive the target data sent by the data sending end through a first short-range communication module that establishes a connection with the data sending end. The target data includes the first power-on duration of the data sending end when the target data is sent. Based on the first power-on duration and the power-on duration deviation, the second power-on duration of the data receiving end when the target data is sent is determined, and the third power-on duration of the data receiving end when receiving the target data is determined. Based on the second power-on duration and the third power-on duration, the transmission time of the target data is calculated. If the transmission time is greater than a preset transmission time threshold, the method is used to... The second short-range communication module establishes a connection with the data sending end and performs data transmission through the second short-range communication module. In this embodiment of the invention, the transmission time of the target data is determined based on the power-on duration of the data sending end and the power-on duration of the data receiving end corresponding to the transmission target data. The short-range communication module communicating with the data sending end in the data receiving end is dynamically switched according to the transmission time. Therefore, automatic switching of different short-range communication methods can be realized without manual settings by the user, improving the user's data transmission experience and enabling low-latency, high-quality data transmission in various scenarios.
[0169] To better implement the above methods, this embodiment of the invention also provides a communication module switching device.
[0170] refer to Figure 6 The device includes:
[0171] The duration deviation acquisition unit 601 can be used to acquire the power-on duration deviation between the data sending end and the data receiving end;
[0172] The data receiving unit 602 can be used to receive target data sent by the data sending end through a first short-range communication module that establishes a connection with the data sending end. The target data may include the first power-on duration of the data sending end when the target data is sent.
[0173] The second duration determination unit 603 can be used to determine the second power-on duration of the data receiving end when the target data is sent, based on the first power-on duration and the power-on duration deviation.
[0174] The transmission time calculation unit 604 can be used to determine the third power-on duration of the data receiving end when receiving the target data, and calculate the transmission time of the target data based on the second power-on duration and the third power-on duration;
[0175] The communication module switching unit 605 can be used to establish a connection with the data sending end through the second short-range communication module and perform data transmission through the second short-range communication module if the transmission time is greater than a preset transmission time threshold.
[0176] In some optional embodiments, the communication module switching unit 605 can be used to maintain the connection between the first short-range communication module and the data sending end if the transmission time is greater than a preset transmission time threshold.
[0177] A connection is established with the data sending end through the second short-range communication module, and data transmission is performed through the second short-range communication module;
[0178] like Figure 7 As shown, the communication module switching device provided in this embodiment of the invention may further include a first communication module continuing transmission unit 606, which can be used to calculate the transmission time through a first short-range communication module that maintains a connection with the data sending end, and determine the new transmission time of the first short-range communication module when transmitting data.
[0179] If the new transmission time is not greater than the switching time threshold, the connection between the second short-range communication module and the data sending end is disconnected, and data transmission continues through the first short-range communication module.
[0180] In some optional embodiments, the duration deviation acquisition unit 601 can be used to acquire the time synchronization data packet corresponding to the time synchronization moment, and the time synchronization data packet may include the power-on duration of the data sending end and the data receiving end;
[0181] Based on the power-on duration, calculate the power-on duration deviation between the data sending end and the data receiving end corresponding to the time interval.
[0182] In some optional embodiments, the duration deviation acquisition unit 601 can be used to acquire the first time synchronization power-on duration of the data receiving end at the time of time synchronization.
[0183] The first time synchronization power-on duration is sent to the data sending end, triggering the data sending end to determine the second time synchronization power-on duration when the first time synchronization power-on duration is received. An initial time synchronization data packet is generated based on the first time synchronization power-on duration and the second time synchronization power-on duration. When sending the initial time synchronization data packet to the data receiving end, the third time synchronization power-on duration of the data sending end at the sending time is added to the initial time synchronization data packet to obtain the time synchronization data packet.
[0184] Receive the time synchronization data packet.
[0185] In some optional embodiments, the communication module switching device provided in this embodiment of the invention may further include a fourth duration determination unit 607, which can be used to determine the fourth time synchronization power-on duration of the data receiving end when receiving the time synchronization data packet;
[0186] The duration deviation acquisition unit 601 can be used to calculate the power-on duration deviation between the data sending end and the data receiving end corresponding to the time synchronization moment based on the first time synchronization power-on duration, the second time synchronization power-on duration, the third time synchronization power-on duration and the fourth time synchronization power-on duration in the time synchronization data packet.
[0187] In some optional embodiments, the communication module switching device provided in this embodiment of the invention may further include a bidirectional transmission time calculation unit, which can be used to determine the bidirectional data transmission time between the data receiving end and the data sending end based on the first time synchronization power-on duration, the second time synchronization power-on duration, the third time synchronization power-on duration and the fourth time synchronization power-on duration in the time synchronization data packet.
[0188] The duration deviation acquisition unit 601 can be used to calculate the power-on duration deviation between the data sending end and the data receiving end corresponding to the time synchronization moment, based on the bidirectional data transmission time and the first time synchronization power-on duration, the second time synchronization power-on duration, the third time synchronization power-on duration and the fourth time synchronization power-on duration in the time synchronization data packet, if the bidirectional data transmission time is not greater than a preset bidirectional data transmission time threshold.
[0189] In some optional embodiments, the communication module switching unit 605 can be used to count the reference transmission time of each time the data sent by the data sending end is received through the first short-range communication module within a preset time after the transmission of the target data if the transmission time is greater than a preset transmission time threshold.
[0190] If the transmission time for each reference is greater than the transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data is transmitted through the second short-range communication module.
[0191] In some optional embodiments, the communication module switching unit 605 can be used to count the reference transmission time of each time the data sent by the data sending end is received through the first short-range communication module within a preset time after the transmission of the target data if the transmission time is greater than a preset transmission time threshold.
[0192] Calculate the average transmission time corresponding to the reference transmission time;
[0193] If the average transmission time is greater than the transmission time threshold, a connection is established with the data sending end through the second short-range communication module, and data is transmitted through the second short-range communication module.
[0194] In some optional embodiments, the target data is audio frame data, the data sending end is an audio source sending end, and the data receiving end is an audio playback end.
[0195] In some optional embodiments, the communication module switching device provided in this embodiment of the invention may further include an audio frame processing unit 608, which can be used to determine the difference audio frame between the second audio frame data and the first audio frame data based on the first audio frame data received when transmitting audio data through the first short-range communication module and the second audio frame data received when switching from the first short-range communication module to the second short-range communication module.
[0196] Based on the difference audio frames, speed-changing but pitch-unchanged processing is performed to obtain the processed difference audio frames.
[0197] Audio is played based on the processed differential audio frames and the second audio frame data.
[0198] In some optional embodiments, the first short-range communication module is a WiFi communication module, and the second short-range communication module is a Bluetooth communication module.
[0199] As shown above, the power-on time deviation between the data sending end and the data receiving end can be obtained through the communication module switching device. The target data sent by the data sending end is received through the first short-range communication module connected to the data sending end. The target data includes the first power-on time of the data sending end when the target data is sent. Based on the first power-on time and the power-on time deviation, the second power-on time of the data receiving end when the target data is sent is determined, and the third power-on time of the data receiving end when receiving the target data is determined. Based on the second and third power-on times, the transmission time of the target data is calculated. If the transmission time is greater than a preset transmission time threshold, [the process is interrupted]. A connection is established with the data sending end through the second short-range communication module, and data transmission is performed through the second short-range communication module. In this embodiment of the invention, the transmission time of the target data is determined based on the power-on duration of the data sending end and the power-on duration of the data receiving end corresponding to the transmission target data. The short-range communication module communicating with the data sending end in the data receiving end is dynamically switched according to the transmission time. Therefore, automatic switching of different short-range communication methods can be realized without manual settings by the user, improving the user's data transmission experience and enabling low-latency, high-quality data transmission in various scenarios.
[0200] Furthermore, embodiments of the present invention also provide an electronic device, which may be a terminal or a server, etc. Figure 8 As shown, it illustrates a structural schematic diagram of the electronic device involved in an embodiment of the present invention, specifically:
[0201] The electronic device may include a radio frequency (RF) circuit 801, a memory 802 including one or more computer-readable storage media, an input unit 803, a display unit 804, a sensor 805, an audio circuit 806, a wireless Fidelity (WiFi) module 807, a processor 808 including one or more processing cores, and a power supply 809, etc. Those skilled in the art will understand that... Figure 8 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0202] RF circuit 801 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and hands it over to one or more processors 808 for processing; additionally, it transmits uplink data to the base station. Typically, RF circuit 801 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, RF circuit 801 can also communicate wirelessly with networks and other devices. Wireless communication can use any communication standard or protocol, including but not limited to GSM, GPRS, CDMA, WCDMA, LTE, email, and SMS.
[0203] The memory 802 can be used to store software programs and modules. The processor 808 executes various functional applications and data processing by running the software programs and modules stored in the memory 802. The memory 802 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device (such as audio data, telephone directory, etc.). In addition, the memory 802 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 802 may also include a memory controller to provide access to the memory 802 for the processor 808 and the input unit 803.
[0204] Input unit 803 can be used to receive input digital or character information, and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control. Specifically, in one embodiment, input unit 803 may include a touch-sensitive surface and other input devices. A touch-sensitive surface, also known as a touch display or touchpad, can collect user touch operations on or near it (e.g., user operations using fingers, styluses, or any suitable object or accessory on or near the touch-sensitive surface) and drive corresponding connection devices according to a pre-set program. Optionally, the touch-sensitive surface may include a touch detection device and a touch controller. The touch detection device detects the user's touch orientation and the signal generated by the touch operation, transmitting the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, sends it to the processor 808, and can receive and execute commands from the processor 808. Furthermore, various types of touch-sensitive surfaces, such as resistive, capacitive, infrared, and surface acoustic wave, can be used. In addition to the touch-sensitive surface, input unit 803 may also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0205] Display unit 804 can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of electronic devices. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Display unit 804 may include a display panel, optionally configured as a liquid crystal display (LCD), organic light-emitting diode (OLED), or similar form. Furthermore, a touch-sensitive surface may cover the display panel. When the touch-sensitive surface detects a touch operation on or near it, it transmits the information to processor 808 to determine the type of touch event. Subsequently, processor 808 provides corresponding visual output on the display panel according to the type of touch event. Although in Figure 8 In this context, the touch-sensitive surface and the display panel are two separate components for implementing input and output functions. However, in some embodiments, the touch-sensitive surface and the display panel can be integrated to achieve both input and output functions.
[0206] Electronic devices may also include at least one sensor 805, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel according to the ambient light level, and the proximity sensor can turn off the display panel and / or backlight when the electronic device is moved to the ear. As a type of motion sensor, a gravity acceleration sensor can detect the magnitude of acceleration in various directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that recognize the phone's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometers, taps), etc. Other sensors that may be configured in electronic devices, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.
[0207] Audio circuitry 806, a speaker, and a microphone provide an audio interface between the user and the electronic device. Audio circuitry 806 converts received audio data into electrical signals, transmits them to the speaker, and the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuitry 806, converted back into audio data, and processed by processor 808. The processed data is then transmitted via RF circuitry 801 to, for example, another electronic device, or output to memory 802 for further processing. Audio circuitry 806 may also include an earphone jack to facilitate communication between peripheral headphones and the electronic device.
[0208] WiFi is a short-range wireless transmission technology. Electronic devices using the WiFi module 807 can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 8 WiFi module 807 is shown, but it is understood that it is not a necessary component of an electronic device and can be omitted as needed without changing the nature of the invention.
[0209] The processor 808 is the control center of the electronic device, connecting various parts of the phone via various interfaces and lines. It executes various functions and processes data by running or executing software programs and / or modules stored in the memory 802, and by calling data stored in the memory 802. Optionally, the processor 808 may include one or more processing cores; preferably, the processor 808 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 808.
[0210] The electronic device also includes a power supply 809 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 808 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 809 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0211] Although not shown, the electronic device may also include a camera, Bluetooth module, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 808 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 802 according to the following instructions, and the processor 808 runs the applications stored in the memory 802 to realize various functions, as follows:
[0212] Obtain the power-on time deviation between the data sending end and the data receiving end;
[0213] The first short-range communication module, which establishes a connection with the data sender, receives the target data sent by the data sender. The target data includes the first power-on duration of the data sender when the target data is sent.
[0214] Based on the first power-on duration and the power-on duration deviation, determine the second power-on duration of the data receiving end when the target data is sent.
[0215] Determine the third power-on duration of the data receiving end when receiving the target data, and calculate the transmission time of the target data based on the second power-on duration and the third power-on duration;
[0216] If the transmission time exceeds the preset transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data transmission is performed through the second short-range communication module.
[0217] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0218] To this end, embodiments of the present invention provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the communication module switching methods provided in the embodiments of the present invention. For example, the instructions can execute the following steps:
[0219] Obtain the power-on time deviation between the data sending end and the data receiving end;
[0220] The first short-range communication module, which establishes a connection with the data sender, receives the target data sent by the data sender. The target data includes the first power-on duration of the data sender when the target data is sent.
[0221] Based on the first power-on duration and the power-on duration deviation, determine the second power-on duration of the data receiving end when the target data is sent.
[0222] Determine the third power-on duration of the data receiving end when receiving the target data, and calculate the transmission time of the target data based on the second power-on duration and the third power-on duration;
[0223] If the transmission time exceeds the preset transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data transmission is performed through the second short-range communication module.
[0224] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0225] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0226] Since the instructions stored in the computer-readable storage medium can execute the steps in any of the communication module switching methods provided in the embodiments of the present invention, the beneficial effects that any of the communication module switching methods provided in the embodiments of the present invention can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0227] According to one aspect of this application, a computer program product or computer program is also provided, comprising computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the methods provided in the various optional implementations of the above embodiments.
[0228] The foregoing has provided a detailed description of a communication module switching method, apparatus, electronic device, and storage medium provided by embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A communication module switching method, characterized in that, Applied to the data receiving end, including: Obtain the power-on time deviation between the data sending end and the data receiving end; The first short-range communication module, which establishes a connection with the data sending end, receives target data sent by the data sending end. The target data includes the first power-on duration of the data sending end when the target data is sent. Based on the first power-on duration and the power-on duration deviation, the second power-on duration of the data receiving end is determined when the target data is sent; Determine the third power-on duration of the data receiving end when receiving the target data, and calculate the transmission time of the target data based on the second power-on duration and the third power-on duration; If the transmission time exceeds a preset transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data transmission is performed through the second short-range communication module.
2. The communication module switching method according to claim 1, characterized in that, If the transmission time exceeds a preset transmission time threshold, a connection is established with the data sender via a second short-range communication module, and data transmission is performed via the second short-range communication module, including: If the transmission time is greater than the preset transmission time threshold, the connection between the first short-range communication module and the data sending end is maintained. A connection is established with the data sending end through the second short-range communication module, and data transmission is performed through the second short-range communication module; The method further includes: The transmission time is calculated by the first short-range communication module that maintains a connection with the data sending end, and the new transmission time of the first short-range communication module when transmitting data is determined. If the new transmission time is not greater than the switching time threshold, the connection between the second short-range communication module and the data sending end is disconnected, and data transmission continues through the first short-range communication module.
3. The communication module switching method according to claim 1, characterized in that, The method of obtaining the power-on time deviation between the data sending end and the data receiving end includes: Obtain the time synchronization data packet corresponding to the time synchronization moment, wherein the time synchronization data packet includes the power-on duration of the data sending end and the data receiving end; Based on the power-on duration, calculate the power-on duration deviation between the data sending end and the data receiving end corresponding to the time interval.
4. The communication module switching method according to claim 3, characterized in that, The step of obtaining the time synchronization data packet corresponding to the specified time includes: Obtain the first time synchronization power-on duration of the data receiving end at the specified time. The first time synchronization power-on duration is sent to the data sending end, triggering the data sending end to determine the second time synchronization power-on duration when the first time synchronization power-on duration is received. An initial time synchronization data packet is generated based on the first time synchronization power-on duration and the second time synchronization power-on duration. When sending the initial time synchronization data packet to the data receiving end, the third time synchronization power-on duration of the data sending end at the sending time is added to the initial time synchronization data packet to obtain the time synchronization data packet. Receive the time synchronization data packet.
5. The communication module switching method according to claim 4, characterized in that, Before calculating the power-on duration deviation between the data sending end and the data receiving end corresponding to the specified time based on the power-on duration, the method further includes: Determine the fourth time synchronization power-on duration of the data receiving end when receiving the time synchronization data packet; The step of calculating the power-on duration deviation between the data sending end and the data receiving end corresponding to the specified time interval based on the power-on duration includes: Based on the first, second, third, and fourth time synchronization startup durations in the time synchronization data packet, the startup duration deviation between the data sending end and the data receiving end corresponding to the time synchronization moment is calculated.
6. The communication module switching method according to claim 5, characterized in that, Before calculating the power-on duration deviation between the data sending end and the data receiving end corresponding to the time synchronization moment based on the first time synchronization power-on duration, the second time synchronization power-on duration, the third time synchronization power-on duration, and the fourth time synchronization power-on duration in the time synchronization data packet, the method further includes: Based on the first time synchronization startup duration, the second time synchronization startup duration, the third time synchronization startup duration, and the fourth time synchronization startup duration in the time synchronization data packet, the bidirectional data transmission time between the data receiving end and the data sending end is determined. The calculation of the power-on duration deviation between the data sending end and the data receiving end corresponding to the time synchronization moment, based on the first time synchronization power-on duration, the second time synchronization power-on duration, the third time synchronization power-on duration, and the fourth time synchronization power-on duration in the time synchronization data packet, includes: If the bidirectional data transmission time is not greater than a preset bidirectional data transmission time threshold, based on the bidirectional data transmission time and the first time synchronization startup time, the second time synchronization startup time, the third time synchronization startup time and the fourth time synchronization startup time in the time synchronization data packet, the startup time deviation between the data sending end and the data receiving end corresponding to the time synchronization moment is calculated.
7. The communication module switching method according to claim 1, characterized in that, If the transmission time exceeds a preset transmission time threshold, a connection is established with the data sender via a second short-range communication module, and data transmission is performed via the second short-range communication module, including: If the transmission time is greater than the preset transmission time threshold, the reference transmission time for each time the data sent by the data sending end is received through the first short-range communication module within the preset time after the target data is transmitted is counted. If the transmission time for each reference is greater than the transmission time threshold, a connection is established with the data sender through the second short-range communication module, and data is transmitted through the second short-range communication module.
8. The communication module switching method according to claim 1, characterized in that, If the transmission time exceeds a preset transmission time threshold, a connection is established with the data sender via a second short-range communication module, and data transmission is performed via the second short-range communication module, including: If the transmission time is greater than the preset transmission time threshold, the reference transmission time for each time the data sent by the data sending end is received through the first short-range communication module within the preset time after the target data is transmitted is counted. Calculate the average transmission time corresponding to the reference transmission time; If the average transmission time is greater than the transmission time threshold, a connection is established with the data sending end through the second short-range communication module, and data is transmitted through the second short-range communication module.
9. The communication module switching method according to any one of claims 1-8, characterized in that, The target data is audio frame data, the data sending end is the audio source sending end, and the data receiving end is the audio playback end.
10. The communication module switching method according to claim 9, characterized in that, The method further includes: Based on the first audio frame data received when transmitting audio data through the first short-range communication module, and the second audio frame data received when switching from the first short-range communication module to the second short-range communication module, the difference audio frame between the second audio frame data and the first audio frame data is determined; Based on the difference audio frames, speed-changing but pitch-unchanged processing is performed to obtain the processed difference audio frames. Audio is played based on the processed differential audio frames and the second audio frame data.
11. The communication module switching method according to any one of claims 1-10, characterized in that, The first short-range communication module is a WiFi communication module, and the second short-range communication module is a Bluetooth communication module.
12. A communication module switching device, characterized in that, Applied to the data receiving end, including: The duration deviation acquisition unit is used to acquire the power-on duration deviation between the data sending end and the data receiving end; A data receiving unit is configured to receive target data sent by the data sending end through a first short-range communication module that establishes a connection with the data sending end, wherein the target data includes a first power-on duration of the data sending end when the target data is sent. The second duration determination unit is used to determine the second power-on duration of the data receiving end when the target data is sent, based on the first power-on duration and the power-on duration deviation. A transmission time calculation unit is used to determine the third power-on duration of the data receiving end when receiving the target data, and to calculate the transmission time of the target data based on the second power-on duration and the third power-on duration. The communication module switching unit is used to establish a connection with the data sending end through the second short-range communication module and perform data transmission through the second short-range communication module if the transmission time is greater than a preset transmission time threshold.
13. An electronic device, characterized in that, It includes a memory and a processor; the memory stores an application program, and the processor runs the application program within the memory to perform the steps in the communication module switching method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of instructions adapted for loading by a processor to perform the steps of the communication module switching method according to any one of claims 1 to 11.
15. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by the processor, they implement the steps of the communication module switching method as described in any one of claims 1 to 11.
Citation Information
Patent Citations
Data processing method and device, mobile terminal and storage medium
CN109683821A
Application processing method and device, electronic equipment and computer readable storage medium
CN110032431A