Method of selecting an antenna and electronic device

By monitoring link status to determine the connection mode and executing antenna switching strategies, the problem of poor network stability in multi-protocol systems is solved, achieving more efficient network connection stability and signal utilization.

CN123184686APending Publication Date: 2026-11-27ECOFLOW INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610031781.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-09
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In systems where multiple wireless communication protocols coexist, the simple antenna switching methods in existing technologies cannot meet the performance requirements of different protocols, leading to a decrease in network stability.

Method used

By monitoring the link status corresponding to each communication protocol, the connection status mode of electronic devices can be determined, and the corresponding antenna switching strategy can be executed based on the mode to select the appropriate antenna for operation, thereby reducing the risk of network interruption and improving network connection stability.

Benefits of technology

In complex application scenarios, it improves the overall stability of the network and the efficient utilization of signals, and reduces the probability of network outages caused by unreasonable antenna switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123184686A_ABST
    Figure CN123184686A_ABST
Patent Text Reader

Abstract

The application provides a method for selecting an antenna and an electronic device, and relates to the technical field of communication. The method for selecting an antenna provided by the application is applied to an electronic device, the electronic device has at least two antennas, supports a first wireless communication protocol and a second wireless communication protocol, the transmission distance of the first wireless communication protocol is farther than that of the second wireless communication protocol; the method comprises the following steps: obtaining a first link state corresponding to the first wireless communication protocol and a second link state corresponding to the second wireless communication protocol; determining a connection state mode in which the electronic device is located based on the first link state and the second link state; and performing corresponding antenna selection operations on each antenna based on an antenna switching strategy corresponding to the connection state mode. The electronic device selects an antenna based on the connection state mode, so that the network stability can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a method for selecting an antenna and an electronic device. Background Technology

[0002] With the widespread use of smart devices, their usage environments and installation scenarios are becoming increasingly complex, placing higher demands on the experience and stability of their wireless connections. For example, in complex application scenarios such as when the device antenna is blocked, the device moves, or is in a strong interference environment, using dual-antenna or multi-antenna switching has become a necessary means to improve connection robustness.

[0003] However, in systems where multiple wireless communication protocols (such as Wi-Fi and Bluetooth) coexist, using a dual-mode System-on-Chip (SoC) can support applications using multiple wireless communication protocols. Due to the differences in RF characteristics between different protocols, performance constraints may arise when sharing the same RF front-end and antenna. Related technologies often employ simple antenna switching methods, which, for complex application scenarios, cannot simultaneously meet the performance requirements of multiple protocols, thus leading to decreased network stability. Summary of the Invention

[0004] According to various embodiments of this application, a method and electronic device for selecting an antenna are provided, which can improve network stability.

[0005] In a first aspect, this application provides a method for selecting an antenna, applied to an electronic device having at least two antennas, supporting a first wireless communication protocol and a second wireless communication protocol, wherein the transmission distance of the first wireless communication protocol is longer than that of the second wireless communication protocol; the method includes: Obtain the first link state corresponding to the first wireless communication protocol and the second link state corresponding to the second wireless communication protocol; determine the connection state mode of the electronic device based on the first link state and the second link state; and perform corresponding antenna selection operations on each antenna based on the antenna switching strategy corresponding to the connection state mode.

[0006] By obtaining the first link state corresponding to the first wireless communication protocol and the second link state corresponding to the second wireless communication protocol, the current connection state mode of the electronic device is determined. Based on the current connection state mode, the corresponding antenna switching strategy is invoked to select the appropriate antenna for operation, reducing the risk of network interruption caused by unreasonable antenna switching. In the case of coexistence of different wireless communication protocols, the stability of the overall network connection is guaranteed. The antenna switching strategy based on the connection state mode can better cope with signal fluctuations caused by location movement, obstruction, or interference, making antenna resources more efficient in time and space, and improving the overall stability of the network. It has strong ease of use and practicality.

[0007] In one possible implementation of the first aspect, determining the connection state mode of the electronic device based on the first link state and the second link state includes at least one of the following: When the first link state is disconnected and the second link state is disconnected, the connection state mode is determined to be the first mode; When the first link state is connected and the second link state is disconnected, the connection state mode is determined to be the second mode; When the first link state is disconnected and the second link state is connected, the connection state mode is determined to be the third mode; When both the first link state and the second link state are connected, the connection state mode is determined to be the fourth mode.

[0008] In one possible implementation of the first aspect, performing a corresponding antenna selection operation on each of the antennas based on the antenna switching strategy corresponding to the connection state mode includes: When the connection state mode is the first mode, the antennas that are working are periodically switched among the antennas.

[0009] In one possible implementation of the first aspect, performing a corresponding antenna selection operation on each of the antennas based on the antenna switching strategy corresponding to the connection state mode includes: When the connection state mode is the second mode, the first signal strength detected by each antenna corresponding to the first wireless communication protocol is obtained; Based on the strength of each of the first signals, each of the antennas operates by switching at different periods.

[0010] In one possible implementation of the first aspect, performing a corresponding antenna selection operation on each of the antennas based on the antenna switching strategy corresponding to the connection state mode includes: When the connection state mode is the third mode, the signal fluctuation value of the currently working antenna is obtained; When the signal fluctuation value exceeds a preset switching threshold, the system switches to the antenna with the highest signal strength based on the second signal strength detected by each antenna corresponding to the second wireless communication protocol.

[0011] In one possible implementation of the first aspect, performing a corresponding antenna selection operation on each of the antennas based on the antenna switching strategy corresponding to the connection state mode includes: When the connection state mode is the fourth mode, the first signal fluctuation value corresponding to the first link state and the second signal fluctuation value corresponding to the second link state are obtained; When the first signal fluctuation value is greater than a preset first fluctuation threshold, or the second signal fluctuation value is greater than a second fluctuation threshold, the first signal strength corresponding to the first wireless communication protocol and the second signal strength corresponding to the second wireless communication protocol detected by each antenna are obtained. Based on the first signal strength and the second signal strength corresponding to each antenna, a corresponding antenna selection operation is performed on each antenna.

[0012] In one possible implementation of the first aspect, when the first signal fluctuation value is greater than a preset first fluctuation threshold, the step of performing a corresponding antenna selection operation on each of the antennas based on the first signal strength and the second signal strength corresponding to each antenna includes: When the first signal strength corresponding to the currently operating antenna is lower than the first signal threshold, or when the second signal strength corresponding to the currently operating antenna is lower than the second signal threshold, the antenna with the highest first signal strength is selected from the antennas with the second signal strength greater than the third signal threshold for operation. When the first signal strength corresponding to the currently operating antenna is higher than or equal to the first signal threshold, and the second signal strength corresponding to the currently operating antenna is higher than or equal to the second signal threshold, the currently operating antenna remains in operation.

[0013] In one possible implementation of the first aspect, when the second signal fluctuation value is greater than the second fluctuation threshold, the step of performing a corresponding antenna selection operation on each of the antennas based on the first signal strength and the second signal strength corresponding to each of the antennas includes: When the first signal strength corresponding to the currently operating antenna is lower than the fourth signal threshold, or when the second signal strength corresponding to the currently operating antenna is lower than the fifth signal threshold, the antenna with the highest first signal strength is selected from the antennas with the second signal strength greater than the sixth signal threshold for operation. When the first signal strength corresponding to the currently operating antenna is higher than or equal to the fourth signal threshold, and the second signal strength corresponding to the currently operating antenna is higher than or equal to the fifth signal threshold, the currently operating antenna remains in operation.

[0014] In one possible implementation of the first aspect, the method further includes: The antenna remains in operation when the first signal fluctuation value is less than the first fluctuation threshold and the second signal fluctuation value is less than the second fluctuation threshold.

[0015] Secondly, this application provides an antenna selection device, comprising: The acquisition unit is used to acquire a first link state corresponding to the first wireless communication protocol and a second link state corresponding to the second wireless communication protocol; The processing unit is configured to determine the connection state mode of the electronic device based on the first link state and the second link state. The control unit is used to perform corresponding antenna selection operations on each of the antennas based on the antenna switching strategy corresponding to the connection state mode.

[0016] Thirdly, this application provides an electronic device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described in any one of the first aspects.

[0017] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any one of the first aspects.

[0018] Fifthly, this application provides a computer program product that, when run on a device, causes the device to perform the method described in any one of the first aspects above.

[0019] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 A schematic diagram of the architecture of an application scenario provided in one embodiment of this application; Figure 2 A schematic diagram illustrating the implementation flow of an antenna selection method provided in one embodiment of this application; Figure 3 A schematic diagram illustrating an antenna switching strategy based on signal strength range, provided in one embodiment of this application; Figure 4 This is a schematic diagram of signal strength changes and antenna switching effects provided in one embodiment of the present application; Figure 5 A schematic diagram illustrating a signal fluctuation-based antenna switching strategy provided in one embodiment of this application; Figure 6 This is a schematic diagram of the structure of a selective antenna device provided in one embodiment of this application; Figure 7 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Detailed Implementation

[0022] The embodiments of the technical solution of this application will now be described in detail with reference to the accompanying drawings. These embodiments are only used to more clearly illustrate the technical solution of this application and are therefore merely examples, and should not be used to limit the scope of protection of this application.

[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.

[0024] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.

[0025] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0026] Currently, for electronic devices supporting multiple wireless communication protocols, the differences in radio frequency characteristics between different protocols make it a challenge to simultaneously ensure the communication performance of multiple protocols in different application scenarios. Related technologies employ dual-antenna or multi-antenna switching to achieve time-division multiplexing of the same antenna for data transmission and reception of multiple protocols. However, for complex application scenarios, simple switching and time-division multiplexing cannot simultaneously meet the communication performance requirements of multiple protocols, resulting in poor network stability.

[0027] To address the above technical issues, this application provides a method for selecting antennas. For electronic devices with multiple antennas and supporting multiple communication protocols (taking support for two wireless communication protocols as an example), the method simultaneously monitors the communication link status corresponding to each communication protocol to determine the connection modes between the electronic device and other devices based on different communication protocols. This allows for the determination of an antenna switching strategy, and based on the antenna switching strategy, it determines whether to switch antennas and how to select the operating antenna. This method can simultaneously consider the communication connection stability corresponding to different protocols, reduce the probability of disconnection caused by frequent antenna switching, and select antennas with better signal strength based on the antenna switching strategy corresponding to each connection mode, thereby improving network stability and distribution experience.

[0028] The following describes the application scenario architecture of this power distribution method.

[0029] Please see Figure 1 , Figure 1 This application provides a schematic diagram of a system architecture applicable to one of the above-described distribution network methods in an embodiment of this application; such as... Figure 1 As shown, the system architecture may include electronic devices, mobile terminals, network devices, and may also include other devices (such as servers).

[0030] The aforementioned network devices are used to create and maintain wireless networks. For example, these network devices can be routers, switches, base stations, smart gateways, and other devices with wireless network capabilities.

[0031] Mobile terminals can be used to control electronic devices, such as for network distribution to electronic devices.

[0032] Electronic devices connect to the wireless network of network devices, such as a wireless local area network (WLAN), through configured network information. Electronic devices can also establish communication connections with other devices through other types of wireless communication, such as forming a network with other devices via Bluetooth.

[0033] The other devices mentioned above can be determined according to the actual scenario. For example, they may include servers, which can communicate and connect with network devices to provide data support and other cloud services.

[0034] In this system architecture, electronic devices have high requirements for the stability of their wireless network connections. Because the antennas of electronic devices exhibit significant directionality in some application environments, the hardware of these devices typically supports dual-antenna / multi-antenna designs (such as single-pole double-throw). Switching between different antennas is achieved by controlling the output level of a general-purpose input / output interface through software, allowing data from different protocols to be time-division multiplexed using the same antenna during transmission and reception.

[0035] For this system architecture, the electronic device determines its current connection state by detecting the link status corresponding to different protocols, such as communication connections with network devices and with other devices. Based on this connection state, it determines an antenna switching strategy, and then decides whether to switch antennas and how to select them, rather than randomly and frequently switching antennas. This approach is more adaptable to the current application environment while considering the communication status of links corresponding to different protocols, thus improving network stability and communication quality. For example, when other devices communicating with the electronic device move frequently, the electronic device can determine its antenna switching strategy based on the current connection state and then switch antennas appropriately to ensure the stability of communication connections between the electronic device and other devices.

[0036] Based on the above system architecture, the specific implementation process of the antenna selection method will be described below through an example.

[0037] Please see Figure 2 , Figure 2 This is a schematic diagram illustrating the implementation flow of the antenna selection method provided in this application embodiment. The execution entity of this method can be... Figure 1 The electronic device shown has at least two antennas and supports a first wireless communication protocol and a second wireless communication protocol, wherein the transmission distance of the first wireless communication protocol is longer than that of the second wireless communication protocol. This electronic device can be a wireless terminal such as a smart home device, a mobile energy storage device, a home energy storage device, an IoT device, or a wearable device. Figure 2 As shown, the method may include the following steps: S201, obtain the first link state corresponding to the first wireless communication protocol and the second link state corresponding to the second wireless communication protocol.

[0038] In some embodiments, taking an electronic device supporting two wireless communication protocols as an example, the first wireless communication protocol can be Wireless Fidelity (WiFi), and the second wireless communication protocol can be Bluetooth, or other protocols such as Zigbee, Long Term Evolution (LTE), etc. The first and second wireless communication protocols are based on different radio frequency characteristics and have different corresponding transmission distances. Specifically, the transmission distance of the first wireless communication protocol can be longer than that of the second wireless communication protocol.

[0039] For example, the first link state is the link state of a wireless channel (hereinafter referred to as the first wireless communication connection) established by an electronic device with other devices (such as a router) based on a first wireless communication protocol. The second link state is the link state of a wireless channel (hereinafter referred to as the second wireless communication connection) established by an electronic device with other devices (such as a Bluetooth device) based on a second wireless communication protocol. The above link states may include one or more status parameters such as connectivity, communication quality, and service activity status.

[0040] The connectivity status can include both connected and disconnected states, such as whether the electronic device is connected to the network device's wireless network, or whether the electronic device has paired with a Bluetooth device and is in a connected state. Communication quality refers to the signal quality of the electronic device when it establishes communication connections with other devices based on a first wireless communication protocol and a second wireless communication protocol, such as received signal strength, signal-to-noise ratio, and bit error rate, used to indicate the stability of the link. Service activity status indicates whether the link is in an active data transmission phase, such as whether a file is being downloaded via WiFi, whether audio / multimedia data is being transmitted via Bluetooth, or whether it is in a silent state.

[0041] For example, an electronic device can obtain the first link status and the second link status through the underlying network protocol stack driver and hardware abstraction layer. Specifically, the electronic device can determine connectivity by querying the connection management module of the protocol stack, for example, by querying the current connectivity status (e.g., connected or not connected) through the driver of the first wireless communication protocol, and by querying the existence of a connection handle to a specific device through the protocol stack of the second wireless communication protocol. The electronic device reads real-time statistical information through the physical layer or media access control layer of the wireless chip, such as periodically reading the reported signal strength (RSSI) value from the wireless chip register.

[0042] By independently and accurately detecting the link status corresponding to each wireless communication protocol, a comprehensive evaluation of the link status corresponding to each wireless communication protocol is conducted, providing a real-time and reliable reference benchmark for subsequent antenna selection, so as to take into account the communication status of different links in various application environments.

[0043] S202, based on the first link state and the second link state, determine the connection state mode of the electronic device.

[0044] In some embodiments, the link status may include information such as the connectivity of the communication channel (e.g., connected or disconnected) and communication quality (e.g., signal strength). For the first link status and the second link status, a preset link status classification strategy is used to determine the current connection status mode of the electronic device, while also taking into account the communication conditions possible with different wireless communications.

[0045] In some embodiments, determining the connection state mode of the electronic device based on the first link state and the second link state includes at least one of the following: When both the first and second links are disconnected, the connection status mode is determined to be the first mode; when both the first and second links are connected, the connection status mode is determined to be the second mode; when both the first and second links are connected, the connection status mode is determined to be the third mode; when both the first and second links are connected, the connection status mode is determined to be the fourth mode.

[0046] For example, if the first link state is disconnected (e.g., the electronic device's WiFi component is not connected to any network device), and the second link state is also disconnected (e.g., the electronic device's Bluetooth component is not paired with any device), the current connection state mode of the electronic device is determined to be a double disconnected mode, i.e., the first mode. At this time, the electronic device is in a ready, discoverable initial state. For example, the electronic device is in the WiFi scanning phase and may be discoverable by other Bluetooth devices.

[0047] For example, an electronic device detects that the first link is connected and stable (e.g., WiFi is connected and the signal is good), while the second link is not connected. The device then determines that its current connection mode is the first wireless communication protocol-only connection mode, i.e., the second mode. In this case, the electronic device needs to maintain a stable internet connection while potentially allowing itself to be discovered by other devices (e.g., Bluetooth wake-up pairing).

[0048] For example, if an electronic device detects that the first link is disconnected and the second link is connected (or connected but the signal is fluctuating wildly), it determines that the current connection mode of the electronic device is the second wireless communication protocol-only connection mode, i.e., the third mode. At this time, the electronic device needs to ensure the stability of the point-to-point connection of the established second link.

[0049] For example, if an electronic device detects that both the first and second link states are connected, it determines that the current connection state of the electronic device is a dual-connection mode, i.e., the fourth mode. In this case, the electronic device needs to collaboratively maintain the stability of the two data channels.

[0050] By classifying connection state modes based on the link states (e.g., connectivity) corresponding to each wireless communication protocol, decision-making complexity is reduced. Electronic devices can perform simple mode matching based solely on link states. This approach considers all link states while making subsequent antenna switching strategies more targeted and responsive to changes in the application environment. Furthermore, this mode classification based on connectivity provides a robust abstraction, allowing the connection state mode determination process to tolerate minor fluctuations in underlying state information, thereby avoiding frequent and unnecessary changes to antenna switching strategies.

[0051] S203, based on the antenna switching strategy corresponding to the connection state mode, performs the corresponding antenna selection operation for each antenna.

[0052] In some embodiments, corresponding antenna switching strategies are pre-configured for different connection state modes of the electronic device; for example, after determining the connection state mode, the antenna switching strategy corresponding to the currently determined connection state mode is invoked. Based on the antenna switching strategy, each antenna is controlled to enter a preset working sequence and state; such as controlling the antenna to periodically scan, maintain the working state of the antenna, and periodically switch the working antennas, etc.

[0053] For example, the first mode (dual unconnected) corresponds to a periodic antenna switching strategy; the second mode (first wireless communication protocol connected only) corresponds to an antenna switching strategy that maintains the stability of the first wireless communication connection; the third mode (second wireless communication protocol connected only) corresponds to a strategy that maintains the stability of the second wireless communication connection; and the fourth mode (dual connected) corresponds to a collaboratively optimized antenna switching strategy. Based on different modes, the corresponding antenna switching strategy is invoked to determine the appropriate antenna switching timing and select the appropriate antenna to enter the working state.

[0054] By controlling the dynamic selection of antennas based on antenna switching strategies, the antennas can operate more intelligently to adapt to the current application scenario, thereby achieving the goal of comprehensively improving connection stability in complex wireless environments.

[0055] Accordingly, taking WiFi as the first wireless communication protocol and Bluetooth as the second wireless communication protocol as examples, the antenna strategy corresponding to each of the above four connection state modes will be explained below.

[0056] In some embodiments, when the connection state mode is the first mode, the antennas that are in operation are periodically switched among the antennas.

[0057] In the first mode, when both the first and second links are disconnected, the corresponding antenna switching strategy involves switching antenna operation at fixed intervals (e.g., 1 second, 2 seconds, 5 seconds, etc.). When neither the first nor the second wireless communication protocol has established a connection, the first wireless communication protocol has a longer transmission distance than the second. Switching between different antennas has a smaller impact on the first wireless communication protocol but a more significant impact on the second. Therefore, priority is given to ensuring that the electronic device can be discovered and connected to by other devices based on the second wireless communication protocol, avoiding the inability to be discovered and connected by other devices supporting the second wireless communication protocol due to the poor signal strength of the antenna. This results in fixed-period switching of antennas (e.g., onboard antenna ANT0 and external antenna ANT1). Signals are transmitted or received using the first and second wireless communication protocols via different antennas to quickly establish connections with other devices; the fixed switching interval can be determined based on the actual application scenario.

[0058] For example, taking WiFi as the first wireless communication protocol and Bluetooth as the second wireless communication protocol, when the electronic device has no WiFi connection or Bluetooth connection, it can periodically switch the antenna to emit or receive Bluetooth signals so that it can be quickly discovered and paired with other devices (such as Bluetooth devices) in the vicinity if other devices supporting the Bluetooth protocol are present, thus establishing a Bluetooth communication connection.

[0059] In some embodiments, in this first mode, if the electronic device receives a network configuration trigger event (such as a network configuration command issued by a mobile terminal) and enters the WiFi network configuration connection state, the electronic device can prioritize executing the logic of the WiFi network configuration phase. For example, after network configuration begins, the electronic device switches between the onboard antenna and the external antenna to scan the corresponding wireless network list, and aggregates the two obtained wireless network lists, retaining the antenna with the highest signal strength for each wireless network to obtain the target network list. When determining to initiate a connection to a target network in the target network list, the device switches to the corresponding target antenna based on the target network, and establishes a communication connection with the target network based on the target antenna, ensuring that the currently used target antenna is the antenna with the strongest signal of the currently connected target network.

[0060] The electronic device automatically configures the network after power-on and restarting, acquiring a list of target networks that can be historical network configuration data stored in the storage unit. If the storage unit contains a list of target networks, a rapid scan can be performed based on this historical network configuration data after the target network is identified to determine the antenna with the strongest signal for that target network. When the storage unit is empty, i.e., there is no historical network configuration data, the electronic device re-scans the entire network using different antennas, obtaining a list of wireless networks for subsequent aggregation processing and network connection operations.

[0061] In some embodiments, in the first mode, if the electronic device detects the presence of a wireless network with a first wireless communication protocol in the vicinity, the electronic device can access the wireless network and update the connection status mode to the second mode.

[0062] In some embodiments, when the connection state mode is the second mode, the first signal strength detected by each antenna corresponding to the first wireless communication protocol is obtained; based on each first signal strength, antennas that operate in each antenna are switched at different periods.

[0063] Second mode: The first link is connected and the second link is disconnected. The corresponding antenna switching strategy is to prioritize the first wireless communication connection of the first wireless communication protocol to ensure the connection stability of the first wireless communication connection and avoid the first wireless communication connection from being disconnected due to antenna switching. At the same time, the connection status of the second wireless communication connection of the second wireless communication protocol should also be taken into account. If the antenna signal allows, the antenna can be switched.

[0064] For example, when the first link is connected and the second link is disconnected, the signal strength of the first wireless communication connection can be detected by each antenna separately to further classify the specific situation and switch antennas accordingly. Taking a dual-antenna setup as an example... Figure 3 As shown, a first threshold and a second threshold corresponding to the signal strength can be set for the first antenna and the second antenna, where the first threshold is greater than the second threshold, such as the first threshold being -50dBm and the second threshold being -70dBm.

[0065] refer to Figure 3 Based on the first and second thresholds, we can divide the cases into nine categories, from case 2.1 to case 2.9.

[0066] Regarding scenario 2.1, if the signal strength of both the first and second antennas is greater than the first threshold, it indicates that the signal strength of both antennas is relatively strong. Switching to either antenna will not significantly affect the stability of the first wireless communication connection. Therefore, in this case, antenna switching can be performed based on the first cycle, such as switching the working antenna once every 1 second, to avoid remaining on the antenna with a relatively poor signal for the second wireless communication protocol and thus being unable to be discovered and connected by other devices that support the second wireless communication protocol.

[0067] In case 2.4, the signal strength of the first antenna and the signal strength of the second antenna are both less than the first threshold and greater than the second threshold, indicating that the signal strength of the first wireless communication connection detected by each antenna is relatively weak. In order to ensure the stability of the first wireless communication connection and to take into account the establishment of the second wireless communication connection, the switching period can be adjusted to the second period, which is slower than the first period. The antenna switching is based on the second period, such as switching the working antenna once every 5 seconds.

[0068] For scenarios 2.2 and 2.3, based on the first wireless communication connection, since one antenna detects a higher signal strength than the other (e.g., in scenario 2.2, the signal strength of the second antenna is higher than that of the first antenna, and in scenario 2.3, the signal strength of the first antenna is higher than that of the second antenna), it is possible to control the antenna switching process by keeping the stronger antenna engaged for a longer period and the weaker antenna engaged for a shorter period. In other words, each antenna can be controlled to switch based on its corresponding signal strength at different intervals. For example, the engagement time of the two antennas can be adjusted by calculating the difference in signal strength between them. For instance, for every 3dBm difference in signal strength between the two antennas, the stronger antenna engages for one more second, and the weaker antenna engages for one less second, with a minimum engagement time of one second.

[0069] For cases 2.5, 2.6, 2.7, and 2.8, if the signal strength of one antenna is too poor, no periodic switching operation is performed on the antenna; instead, the antenna with the stronger signal is switched directly to work. For case 2.9, if the signal strength of both antennas is poor, no periodic switching of the antennas is performed in order to ensure the stability of the first wireless communication connection.

[0070] In another possible implementation, when the connection state mode is the second mode, the fluctuation value of the currently working antenna signal is obtained; when the fluctuation value exceeds the preset switching threshold, the antenna with the highest first signal strength is switched to work based on the first signal strength detected by each antenna corresponding to the first wireless communication protocol.

[0071] In some embodiments, when the connection state mode is the third mode, the signal fluctuation value of the currently working antenna is obtained; when the signal fluctuation value exceeds a preset switching threshold, the antenna with the highest second signal strength is switched to work based on the second signal strength detected by each antenna corresponding to the second wireless communication protocol.

[0072] The third mode: the first link is not connected and the second link is connected; the corresponding antenna switching strategy is to stop periodic antenna switching and determine whether to switch to the backup antenna by monitoring the signal fluctuation value corresponding to the second wireless communication connection, so as to ensure the connection stability of the second wireless communication connection.

[0073] For example, signal fluctuation values ​​can be calculated based on a reference offset detection algorithm, as shown in Figure 4. The input signal can be the signal strength of the second wireless communication connection detected in real time by the currently operating antenna (such as the raw signal strength (Raw RSSI)). The real-time detected signal strength is processed by Kalman filtering to filter out transient interference and hardware measurement noise in the environment, resulting in a smooth curve that reflects the true signal trend, such as... Figure 4 The filtered signal strength (Filtered RSSI) is shown in the figure.

[0074] For example, the filtered signal strength values ​​are cached in two circular queues (data caches) with different time lengths, allowing for signal strength analysis at different time scales. For instance, the filtered signal strength values ​​over a longer time window (e.g., the past 30 seconds) are stored, and a baseline value is determined based on the average of the signal strength values ​​in the queue (e.g., calculated based on the current cumulative sum of all signal strength values ​​in the circular queue (Queue2 Current Sum) and the number of collected signal strength values) or the median. Figure 4 The signal strength baseline value shown represents the expected signal strength level perceived by the system over a recent period, serving as a reference anchor point for judging whether there is a slight deviation in the current signal strength. For example, it stores filtered signal strength values ​​within a very short time window (e.g., the past 1-2 seconds). The current value is determined based on the last signal strength value in the queue, and the previous value is determined based on the second-to-last signal strength value in the queue. The current value represents the signal state at the very last instant, reflecting the latest short-term trend of the signal, while the previous value is used to calculate the suppression term for transient changes in the current value. When the queue is full, the signal fluctuation value ans is calculated using the baseline offset detection algorithm formula; the calculation formula is as follows:

[0075] The reference value, current value, and previous value are determined based on the filtered signal strength values ​​stored in two circular queues with different time lengths. The absolute value of the difference between the reference value and the current value measures the absolute distance of the current signal strength from its long-term normal level. If this value is large, it indicates that the signal has moved far from its expected level, and the corresponding fluctuation may be severe. The absolute value of the difference between the previous value and the current value measures the degree of change in the current signal strength between the last two observations. The larger the absolute value, the faster the signal strength is increasing or decreasing. Kd is the damping coefficient, which can be a constant between 0 and 1 (e.g., 0.3). Since signal strength fluctuations may be due to transient interference, this damping coefficient is used to suppress short-term abrupt changes caused by transient interference. The difference between the previous value and the current value multiplied by the damping coefficient Kd can be used as a suppression term for the transient changes of the current value. The signal fluctuation value is obtained by subtracting the damped short-term change (i.e., the suppression term) from the long-term offset.

[0076] Correspondingly, when the signal strength is stable and continuously deteriorating, the long-term offset will gradually increase while the short-term change is small. In this case, the signal fluctuation value will be a continuously increasing positive number. If the signal strength only jitters violently and then recovers, the short-term change will be larger, while the long-term offset may not change much. After damping, the signal fluctuation value will be very small or even negative. Therefore, when a continuously increasing positive signal fluctuation value appears, it indicates that the signal may be fluctuating.

[0077] For example, by setting a switching threshold, the calculated signal fluctuation value is compared with the preset switching threshold. When the signal fluctuation value is greater than the switching threshold, it is determined that an abnormal and trending signal fluctuation has occurred, and the stability of the second wireless communication connection is affected. A trigger signal for switching the antenna is sent to initiate the process of attempting to switch the antenna. Otherwise, it is confirmed that the signal fluctuation value is within the normal range, and there is no need to switch the antenna. The signal strength of the current working antenna is continuously monitored.

[0078] When antenna switching is required, the signal strength of the candidate antenna can be obtained based on the historical cache. By comparing the current signal strength of the candidate antenna in the cache with the signal strength of the currently working antenna, the antenna with the highest signal strength is selected to work. For example, if the signal strength of the candidate antenna is higher, the system switches to the candidate antenna to work; otherwise, it stays on the currently working antenna and keeps the current antenna working.

[0079] In addition, the signal strength in the cache can be dynamically updated as the signal strength changes, and can be cleared if it is not updated for a preset period of time. If the signal strength cannot be obtained from the historical cache, the real-time signal strength is obtained by switching to the alternative antenna. By comparing the signal strength of the currently working antenna and the alternative antenna, the antenna with the highest signal strength is selected to work.

[0080] like Figure 4 The simulation effect diagram shown above illustrates that before the two final trigger signals, the filtered signal strength exhibits a significant and continuous downward trend. As the signal strength decreases, the current value (filtered signal strength) gradually deviates from the reference value. Based on the above calculation formula, the signal fluctuation value is calculated in real time. Due to the continuous decrease in signal strength and the increase in long-term offset, when the calculated signal fluctuation value exceeds the switching threshold, a step signal is immediately generated in the final trigger event. That is, the antenna switching instruction is triggered by the rising or falling edge of the step signal. After the trigger is completed, the electronic device may have switched antennas, the signal quality is improved, the signal fluctuation value decreases, and the trigger signal is then set.

[0081] The process of calculating signal fluctuation values ​​and the procedure for switching antennas described above also apply to the application scenario in the second mode where the signal fluctuation value exceeds the preset switching threshold, and the antenna with the highest first signal strength is switched to operate based on the first signal strength detected by each antenna corresponding to the first wireless communication connection.

[0082] By using signal fluctuation values, it is possible to more accurately determine both normal and abnormal signal strength fluctuations, avoiding blind periodic switching. Through Kalman filtering of the input signal and the use of damping coefficients to suppress short-term abrupt changes, the signal fluctuation of the first or second wireless communication connection is monitored, ensuring the stability of antenna switching decisions and avoiding frequent invalid switching due to transient interference. It reliably identifies changes in signal strength and issues precise antenna switching commands.

[0083] In some embodiments, when the connection state mode is the fourth mode, the first signal fluctuation value corresponding to the first link state and the second signal fluctuation value corresponding to the second link state are obtained; when the first signal fluctuation value is greater than a preset first fluctuation threshold, or the second signal fluctuation value is greater than a second fluctuation threshold, the first signal strength corresponding to the first wireless communication protocol and the second signal strength corresponding to the second wireless communication protocol detected by each antenna are obtained; based on the first signal strength and the second signal strength corresponding to each antenna, the corresponding antenna selection operation is performed on each antenna.

[0084] Fourth mode: The first link is connected and the second link is connected. The corresponding antenna switching strategy is to ensure the connection stability of the first wireless communication connection and the second wireless communication connection, while monitoring the signal fluctuation of the first link and the second link. Based on the above signal fluctuation value calculation method, a judgment is made on whether to perform antenna switching, and the antenna switching operation is executed based on the above-mentioned antenna switching triggering process.

[0085] For example, the signal fluctuation values ​​of the first wireless communication connection and the second wireless communication connection are monitored in parallel and compared with their respective preset switching thresholds (i.e., the first fluctuation threshold and the second fluctuation threshold); when the signal fluctuation value of one of the links exceeds the switching threshold, the signal strength of each antenna is compared and the corresponding antenna switching strategy is determined.

[0086] For example, for the first wireless communication connection (such as a WiFi communication link), the calculated signal fluctuation value exceeds the first switching threshold. When the first signal strength of the current antenna (i.e., the signal strength of the first wireless communication connection) is weak and the second signal strength (i.e., the signal strength of the second wireless communication connection) is extremely strong, and the first signal strength of the alternative antenna is relatively strong and the second signal strength is moderate, in order to ensure the connection stability of the first wireless communication connection, an antenna switching operation is performed, switching to the alternative antenna. After the antenna switching, the signal strength of the first wireless communication connection with excessive fluctuation is significantly improved, and the signal strength of the second wireless communication connection changes from extremely strong to moderate, which can still meet the connection requirements.

[0087] For example, for the first wireless communication connection (such as a WiFi communication link), the calculated signal fluctuation value exceeds the first switching threshold; if the first signal strength of the current antenna is medium and the second signal strength is relatively strong, and the first signal strength of the alternative antenna is slightly better and the second signal strength is extremely poor (such as close to disconnection), then antenna switching is prohibited; although switching to the alternative antenna in this case can improve the communication quality of the first wireless communication connection, it will lead to the risk of disconnection of the second wireless communication connection; in order to avoid more serious problems caused by antenna switching, the currently working antenna is kept and the antenna switching operation is not performed.

[0088] For example, for a second wireless communication connection (such as a Bluetooth communication link), if the calculated signal fluctuation value exceeds a second handover threshold, and the current antenna has a strong first signal strength and a weak, highly fluctuating second signal strength, while the alternative antenna has a moderate first signal strength and a strong second signal strength, then the user switches to the alternative antenna. In other words, antenna handover is only performed when the first signal strength of the alternative antenna is confirmed to be above the minimum threshold for reliable communication and significantly improves the second wireless communication connection; if antenna handover would cause the first signal strength to drop from strong to a critical level, then antenna handover is not performed.

[0089] To ensure the stability of one wireless communication connection (such as the first wireless communication connection), the first fluctuation threshold corresponding to that wireless communication connection can be set relatively small to improve response sensitivity, while the second fluctuation threshold for the other wireless communication connection (such as the second wireless communication connection) can be set relatively large; for example... Figure 5The first fluctuation threshold (set to 35) shown can be less than the second fluctuation threshold (set to 50).

[0090] By comprehensively evaluating the signal fluctuations of two wireless communication connections, ping-pong switching caused by fluctuations in the two links can be avoided; by clearly defining priorities, the stable operation of core services can be guaranteed; when resource conflicts are unavoidable, after complex trade-offs, the optimal strategy that minimizes damage to the overall system and ensures the overall stability of the system can be adopted, thus solving the problem of communication instability in multi-protocol coexistence scenarios.

[0091] In some embodiments, when the first signal fluctuation value is greater than a preset first fluctuation threshold, an antenna selection operation is performed on each antenna based on the first signal strength and the second signal strength corresponding to each antenna, including: When the first signal strength corresponding to the currently operating antenna is lower than the first signal threshold, or when the second signal strength corresponding to the currently operating antenna is lower than the second signal threshold, the antenna with the highest first signal strength is selected from the antennas with a second signal strength greater than the third signal threshold for operation; when the first signal strength corresponding to the currently operating antenna is higher than or equal to the first signal threshold, and the second signal strength corresponding to the currently operating antenna is higher than or equal to the second signal threshold, the currently operating antenna is maintained.

[0092] For example, such as Figure 5 As shown, taking WiFi as the first wireless communication protocol and Bluetooth as the second wireless communication protocol as examples, a more specific division of signal strength ranges is made for different situations.

[0093] Wherein, when the first signal fluctuation value is greater than the preset first fluctuation threshold, the corresponding Figure 5 In case 4.2, the first signal strength is further divided into more refined signal strength ranges. For example, the first signal strength corresponding to the current antenna is divided into three ranges: (0, -50dBm), [-50dBm, -70dBm] and (-70dBm, -∞), and the second signal strength corresponding to the current antenna is divided into three ranges: (0, -60dBm), [-60dBm, -80dBm] and (-80dBm, -∞).

[0094] Accordingly, when the first signal fluctuation value exceeds a preset first fluctuation threshold, an antenna switching attempt needs to be made. The switching logic is further subdivided into cases 4.2.1 to 4.2.9. For cases 4.2.1 and 4.2.2, if both the first and second signal strengths of the current antenna are strong, no switching is performed. For cases 4.2.3 to 4.2.9, if one of the first and second signal strengths is weaker, the corresponding switching condition is that the first signal strength of the alternative antenna must be higher than the signal strength of the current antenna, and the second signal strength of the alternative antenna cannot be too weak, that is, at least the connection of the second wireless communication connection can be guaranteed.

[0095] For example, regarding case 4.2.3, when the first signal strength of the current antenna is detected to be in the range of (0, -50dBm) and the second signal strength is detected to be in the range of (-80dBm, -∞), if the first signal strength of the alternative antenna is better (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -80dBm, then antenna switching is performed; regarding case 4.2.4, when the first signal strength of the current antenna is detected to be in the range of [-50dBm, -70dBm] and the second signal strength is in the range of (0, -60dBm)... When the signal strength of the candidate antenna is within the range of [-50dBm, -70dBm] and the signal strength of the candidate antenna is within the range of [-60dBm, -80dBm], antenna switching is performed if the first signal strength of the candidate antenna is better (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -60dBm. For case 4.2.5, when the first signal strength of the current antenna is detected to be within the range of [-50dBm, -70dBm] and the second signal strength is within the range of [-60dBm, -80dBm], antenna switching is performed if the first signal strength of the candidate antenna is better (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -80dBm. For case 4.2.6, when the first signal strength of the current antenna is detected to be in the range of [-50dBm, -70dBm] and the second signal strength is detected to be in the range of (-80dBm, -∞), if the first signal strength of the alternative antenna is better (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -80dBm, then antenna switching is performed; for case 4.2.7, when the first signal strength of the current antenna is detected to be in the range of (-70dBm, -∞) and the second signal strength is detected to be in the range of (0, -60dBm), If the first signal strength of the candidate antenna is good (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -80dBm, then antenna switching is performed. For cases 4.2.8 and 4.2.9, when the first signal strength of the current antenna is detected to be in the range of (-70dBm, -∞) and the second signal strength is detected to be in the range of [-60dBm, -80dBm], if the first signal strength of the candidate antenna is good (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -90dBm, then antenna switching is performed.

[0096] In some embodiments, when the second signal fluctuation value is greater than the second fluctuation threshold, based on the first signal strength and the second signal strength corresponding to each antenna, a corresponding antenna selection operation is performed on each antenna, including: When the first signal strength corresponding to the currently operating antenna is lower than the fourth signal threshold, or the second signal strength corresponding to the currently operating antenna is lower than the fifth signal threshold, the antenna with the highest first signal strength is selected from the antennas with a second signal strength greater than the sixth signal threshold for operation; when the first signal strength corresponding to the currently operating antenna is higher than or equal to the fourth signal threshold, and the second signal strength corresponding to the currently operating antenna is higher than or equal to the fifth signal threshold, the currently operating antenna is maintained.

[0097] For example, such as Figure 5 As shown, when the second signal fluctuation value exceeds the preset second fluctuation threshold, it is necessary to attempt to switch antennas while ensuring the stability of the first link state. The switching logic is further subdivided into cases 4.3.1 to 4.3.9. For cases 4.3.1, 4.3.2, 4.3.4, and 4.3.5, if both the first and second signal strengths of the current antenna are strong, no switching is performed. For other cases, antenna switching is only performed when both the first and second signal strengths of the current antenna are poor, the first and second signal strengths of the alternative antenna are relatively good (and the first link has a higher priority than the second link).

[0098] For example, regarding case 4.3.3, when the first signal strength of the current antenna is detected to be in the range of (0, -50dBm) and the second signal strength is detected to be in the range of (-80dBm, -∞), if the first signal strength of the candidate antenna is better (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -60dBm, then antenna switching is performed; regarding case 4.3.6, when the first signal strength of the current antenna is detected to be in the range of [-50dBm, -70dBm] and the second signal strength is detected to be in the range of (-80dBm, -∞), if the first signal strength of the candidate antenna is better (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -80dBm, then antenna switching is performed; regarding case 4.3.7, when the first signal strength of the current antenna is detected to be in the range of (-70dBm, -∞) and the second signal strength is detected to be in the range of (0, -60dBm), then antenna switching is performed. When the signal strength of the candidate antenna is within the range of (-70dBm, -∞) and the signal strength of the candidate antenna is within the range of (-60dBm, -80dBm), antenna switching is performed if the first signal strength of the candidate antenna is better (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -60dBm. For case 4.3.8, when the first signal strength of the current antenna is detected to be within the range of (-70dBm, -∞) and the second signal strength is detected to be within the range of (-60dBm, -80dBm), antenna switching is performed if the first signal strength of the candidate antenna is better (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -80dBm. For case 4.3.9, when the first signal strength of the current antenna is detected to be within the range of (-70dBm, -∞) and the second signal strength is detected to be within the range of (-80dBm, -∞), antenna switching is performed if the first signal strength of the candidate antenna is better (e.g., greater than or equal to -70dBm) and the second signal strength is greater than -90dBm.

[0099] In some embodiments, the method further includes: maintaining the currently operating antenna when the first signal fluctuation value is less than a first fluctuation threshold and the second signal fluctuation value is less than a second fluctuation threshold.

[0100] For example, such as Figure 5 As shown in scenario 4.1, when the first signal fluctuation value is less than the first fluctuation threshold and the second signal fluctuation value is less than the second fluctuation threshold, it is determined that the signal fluctuations of the first wireless communication connection and the second wireless communication connection are within a reasonable range. Therefore, the antenna switching logic is not triggered, and the signal strength of the first wireless communication protocol and the second wireless communication protocol continues to be monitored.

[0101] The switching thresholds and switching cycles mentioned above are only illustrative examples and can be dynamically set based on actual application scenarios.

[0102] In this embodiment, before a second wireless communication connection (such as a Bluetooth communication link) is established with other devices, the electronic device periodically switches antennas to ensure that when other devices move within the signal coverage area of ​​the electronic device, they can scan the Bluetooth broadcast of the electronic device and establish a connection. Simultaneously, the stability of the first wireless communication connection (such as a Wi-Fi communication link) is considered, and antenna switching is not frequent or arbitrary when the Wi-Fi communication link is already connected to avoid Wi-Fi link disconnection. After the electronic device establishes a Bluetooth communication link with other devices, it can attempt to switch to an antenna with a better signal when Bluetooth signal fluctuations exceed a threshold. Similarly, after establishing a Wi-Fi communication link, it can attempt to switch to an antenna with a better signal when Wi-Fi communication link signal fluctuations exceed a threshold. After the electronic device establishes both a Wi-Fi communication link and a Bluetooth communication link with other devices, when the signal fluctuations of either the Wi-Fi or Bluetooth communication link exceed a threshold, the optimal antenna switching strategy can be determined based on a comprehensive evaluation of the signal strength of the current antenna and alternative antennas.

[0103] This application's embodiment provides an antenna selection strategy for sharing an antenna across multiple wireless communication protocols. By periodically detecting the connection status of each link in the electronic device, antenna switching is achieved through output level when the connection status changes. In a multi-link state, the working antenna is selected, while also taking into account the connection stability of each communication protocol under different link states.

[0104] It should be understood that the sequence number of each step in the above embodiments does not imply 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 this application.

[0105] Corresponding to the antenna selection method provided in the above embodiments, such as Figure 6 The diagram shown is a schematic representation of the antenna selection device provided in this application embodiment. For ease of explanation, only the parts related to this application embodiment are shown.

[0106] The device for selecting the antenna includes: The acquisition unit 61 is used to acquire a first link state corresponding to the first wireless communication protocol and a second link state corresponding to the second wireless communication protocol. Processing unit 62 is used to determine the connection state mode of the electronic device based on the first link state and the second link state; The control unit 63 is used to perform corresponding antenna selection operations on each of the antennas based on the antenna switching strategy corresponding to the connection state mode.

[0107] In one possible implementation, the above-mentioned units and modules are used to implement the steps in the above-described method embodiments.

[0108] Figure 7 A schematic diagram of the hardware structure of electronic device 7 is shown.

[0109] like Figure 7 As shown, the electronic device 7 of this embodiment includes: at least one processor 71 ( Figure 7 Only one is shown in the diagram), and a memory 72 stores a computer program 73 that can run on the processor 71. When the processor 71 executes the computer program 73, it implements the steps in the above method embodiments, for example... Figure 2 S201 to S203 are shown. Alternatively, when the processor 71 executes the computer program 73, it implements the functions of each module / unit in the above-described device embodiments.

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

[0111] The electronic device 7 may include, but is not limited to, a processor 71 and a memory 72. Those skilled in the art will understand that... Figure 7 This is merely an example of electronic device 7 and does not constitute a limitation on electronic device 7. It may include more or fewer components than shown, or combine certain components, or different components. For example, the server may also include input sending devices, network access devices, buses, etc.

[0112] The processor 71 mentioned above can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

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

[0114] In some embodiments, the aforementioned memory 72 may be an internal storage unit of the electronic device 7, such as a hard disk or memory of the electronic device 7. The memory 72 may also be an external storage device of the electronic device 7, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the electronic device 7. Furthermore, the memory 72 may include both internal and external storage units of the electronic device 7. The memory 72 is used to store operating systems, applications, bootloaders, data, and other programs, such as program code for computer programs. The memory 72 can also be used to temporarily store data that has been sent or will be sent.

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

[0116] It should be noted that the structure of the above-mentioned electronic device is only illustrative and may include other physical structures depending on the application scenario. The physical structure of the electronic device is not limited here.

[0117] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0118] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the various method embodiments above.

[0119] This application provides a computer program product that, when run on a server, enables the server to execute the steps described in the various method embodiments above.

[0120] If the integrated modules / units are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.

[0121] The electronic devices, computer storage media, and computer program products provided in the embodiments of this application are all used to execute the methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects corresponding to the methods provided above, and will not be repeated here.

[0122] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification. It should be understood that the above description is merely to help those skilled in the art better understand the embodiments of this application, and is not intended to limit the scope of the embodiments of this application. Based on the examples given above, those skilled in the art can obviously make various equivalent modifications or changes. For example, some steps in the various embodiments of the above detection method may be unnecessary, or new steps may be added. Alternatively, any combination of two or more of the above embodiments may be used. Such modifications, changes, or combinations also fall within the scope of the embodiments of this application.

[0123] It should also be understood that the methods, situations, categories, and classifications of embodiments in this application are for the convenience of description only and should not constitute a special limitation. Various methods, categories, situations, and features in embodiments can be combined without contradiction.

[0124] It should also be understood that, in the various embodiments of this application, unless otherwise specified or in case of logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced by each other, and the technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships.

[0125] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

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

[0127] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0128] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

[0129] Finally, it should be noted that the above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for selecting an antenna, characterized in that, The method is applied to an electronic device having at least two antennas, supporting a first wireless communication protocol and a second wireless communication protocol, wherein the transmission distance of the first wireless communication protocol is greater than the transmission distance of the second wireless communication protocol; the method includes: Obtain the first link state corresponding to the first wireless communication protocol and the second link state corresponding to the second wireless communication protocol; Based on the first link state and the second link state, the connection state mode of the electronic device is determined; Based on the antenna switching strategy corresponding to the connection state mode, the corresponding antenna selection operation is performed on each of the antennas.

2. The method according to claim 1, characterized in that, Determining the connection state mode of the electronic device based on the first link state and the second link state includes at least one of the following: When the first link state is disconnected and the second link state is disconnected, the connection state mode is determined to be the first mode; When the first link state is connected and the second link state is disconnected, the connection state mode is determined to be the second mode; When the first link state is disconnected and the second link state is connected, the connection state mode is determined to be the third mode; When both the first link state and the second link state are connected, the connection state mode is determined to be the fourth mode.

3. The method according to claim 2, characterized in that, The antenna selection operation performed on each antenna based on the antenna switching strategy corresponding to the connection state mode includes: When the connection state mode is the first mode, the antennas that are working are periodically switched among the antennas.

4. The method according to claim 2, characterized in that, The antenna selection operation performed on each antenna based on the antenna switching strategy corresponding to the connection state mode includes: When the connection state mode is the second mode, the first signal strength detected by each antenna corresponding to the first wireless communication protocol is obtained; Based on the strength of each of the first signals, each of the antennas operates by switching at different periods.

5. The method according to claim 2, characterized in that, The antenna selection operation performed on each antenna based on the antenna switching strategy corresponding to the connection state mode includes: When the connection state mode is the third mode, the signal fluctuation value of the currently working antenna is obtained; When the signal fluctuation value exceeds a preset switching threshold, the system switches to the antenna with the highest signal strength based on the second signal strength detected by each antenna corresponding to the second wireless communication protocol.

6. The method according to claim 2, characterized in that, The antenna selection operation performed on each antenna based on the antenna switching strategy corresponding to the connection state mode includes: When the connection state mode is the fourth mode, the first signal fluctuation value corresponding to the first link state and the second signal fluctuation value corresponding to the second link state are obtained; When the first signal fluctuation value is greater than a preset first fluctuation threshold, or the second signal fluctuation value is greater than a second fluctuation threshold, the first signal strength corresponding to the first wireless communication protocol and the second signal strength corresponding to the second wireless communication protocol detected by each antenna are obtained. Based on the first signal strength and the second signal strength corresponding to each antenna, a corresponding antenna selection operation is performed on each antenna.

7. The method according to claim 6, characterized in that, When the first signal fluctuation value is greater than a preset first fluctuation threshold, the step of performing a corresponding antenna selection operation on each antenna based on the first signal strength and the second signal strength corresponding to each antenna includes: When the first signal strength corresponding to the currently operating antenna is lower than the first signal threshold, or when the second signal strength corresponding to the currently operating antenna is lower than the second signal threshold, the antenna with the highest first signal strength is selected from the antennas with the second signal strength greater than the third signal threshold for operation. When the first signal strength corresponding to the currently operating antenna is higher than or equal to the first signal threshold, and the second signal strength corresponding to the currently operating antenna is higher than or equal to the second signal threshold, the currently operating antenna remains in operation.

8. The method according to claim 6, characterized in that, When the second signal fluctuation value is greater than the second fluctuation threshold, the step of performing a corresponding antenna selection operation on each antenna based on the first signal strength and the second signal strength corresponding to each antenna includes: When the first signal strength corresponding to the currently operating antenna is lower than the fourth signal threshold, or when the second signal strength corresponding to the currently operating antenna is lower than the fifth signal threshold, the antenna with the highest first signal strength is selected from the antennas with the second signal strength greater than the sixth signal threshold for operation. When the first signal strength corresponding to the currently operating antenna is higher than or equal to the fourth signal threshold, and the second signal strength corresponding to the currently operating antenna is higher than or equal to the fifth signal threshold, the currently operating antenna remains in operation.

9. The method according to claim 6, characterized in that, The method further includes: The antenna remains in operation when the first signal fluctuation value is less than the first fluctuation threshold and the second signal fluctuation value is less than the second fluctuation threshold.

10. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method of any one of claims 1 to 9.