Frequency Band Switching Method, Device and Computer Readable Storage Medium
By setting a dual-band switching method in the terminal device, using two sets of segment thresholds and frequency band switching conditions, the problem of frequent switching between 5G and 2.4G bands is solved, and stable and accurate frequency band switching is achieved, enhancing the user experience and communication continuity of the device.
Patent Information
- Application Number
- CN202310505264.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-06
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2043-05-06
AI Technical Summary
In the prior art, terminal devices frequently switch between 5G and 2.4G frequency bands are unstable, resulting in unstable communication or frequent disconnection.
The dual-band switching method is adopted. By setting two groups of segment thresholds, each group of segment thresholds has different threshold intervals and frequency band switching conditions. Combined with the signal strength and the preset threshold, the threshold interval to which the signal strength belongs, and stable and accurate frequency band switching is performed according to the frequency band switching conditions of the threshold interval.
The stability and accuracy of frequency band switching are achieved, frequent frequency band switching is avoided, the user experience of the device is enhanced, and the continuity of communication is ensured through IP anti-shake management strategies.
Smart Images

Figure CN116437410B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of wireless communication technologies, and particularly to a frequency band switching method, apparatus, and computer-readable storage medium. Background Art
[0002] As is well known, in the case of good signal quality, the bandwidth of the 5G channel is larger than that of the 2.4G channel. Therefore, theoretically, connecting to the 5G channel is a better strategy. However, the 2.4G signal has a larger coverage range than the 5G signal, and the 5G signal attenuates rapidly with distance and has poor wall-penetrating ability. Therefore, when passing through walls or over long distances, the 2.4G signal is more stable and less likely to disconnect than the 5G signal.
[0003] Most embedded devices on the market use the open-source software wpa_supplicant as the control program for wifi connection. It mainly determines whether to perform frequency band switching by evaluating the signal-to-noise ratio and predicting the throughput of the wifi. Through testing, it is found that the algorithm of wpa_supplicant tends to use the 5G frequency band, that is, it is difficult for the device to automatically switch to the 2.4G frequency band after being connected to the 5G frequency band. This results in unstable communication or even frequent disconnection of the device when the 5G signal is poor, such as when the device is far from the router or passing through walls. There are also some algorithms that simply set a signal strength threshold to determine whether to use the 2.4G frequency band or the 5G frequency band. However, due to the fluctuation of the wifi signal, the device will oscillate back and forth between the 2.4G frequency band and the 5G frequency band. Summary of the Invention
[0004] The object of the present invention is to provide a frequency band switching method, apparatus, and computer-readable storage medium to solve one or more of the above technical problems:
[0005] According to a first aspect of the present disclosure, a frequency band switching method is provided. The method includes the following steps:
[0006] Periodically scan for wifi to obtain the current wifi and candidate wifis. The current wifi corresponds to the current working frequency band, the candidate wifis correspond to candidate working frequency bands, and the current working frequency band and the candidate working frequency bands are respectively one of the first frequency band and the second frequency band supported by the terminal and the router;
[0007] Measure a first signal strength of communicating between the terminal and the router through the first frequency band and a second signal strength of communicating through the second frequency band;
[0008] According to the current operating frequency band, compare the first signal strength with a preset segmented threshold to determine the threshold interval to which the first signal strength belongs. The preset segmented threshold includes a first segmented threshold and a second segmented threshold. The first segmented threshold includes a first strong region, a first middle region, and a first weak region. The second segmented threshold includes a second strong region, a second middle region, and a second weak region. If the current operating frequency band is the first frequency band, then compare the first signal strength with the first segmented threshold; if the current operating frequency band is the second frequency band, then compare the first signal strength with the second segmented threshold;
[0009] Monitor whether the first signal strength and the second signal strength meet the frequency band switching conditions of the threshold interval;
[0010] If so, switch the current operating frequency band to the candidate operating frequency band;
[0011] If not, maintain the current operating frequency band.
[0012] Optionally, if the current operating frequency band is the first frequency band, the step of comparing the first signal strength with the first segmented threshold includes:
[0013] Compare the first signal strength with a first boundary value. The first boundary value includes a boundary value h and a boundary value l. The boundary value h is the boundary value between the first strong region and the first middle region, and the boundary value l is the boundary value between the first middle region and the first weak region;
[0014] If the first signal strength is greater than the boundary value h, then the first signal strength belongs to the first strong region;
[0015] If the first signal strength is less than the boundary value l, then the first signal strength belongs to the first weak region;
[0016] If the first signal strength is greater than or equal to the boundary value l and less than or equal to the boundary value h, then the first signal strength belongs to the first middle region.
[0017] Optionally, if the current operating frequency band is the second frequency band, the step of comparing the first signal strength with the second segmented threshold includes:
[0018] Compare the first signal strength with a second boundary value. The second boundary value includes a boundary value H and a boundary value L. The boundary value H is the boundary value between the second strong region and the second middle region, and the boundary value L is the boundary value between the second middle region and the second weak region;
[0019] If the first signal strength is greater than the boundary value H, then the first signal strength belongs to the second strong region;
[0020] If the first signal strength is less than the boundary value L, then the first signal strength belongs to the second weak area;
[0021] If the first signal strength is less than or equal to the boundary value H and greater than or equal to the boundary value L, then the first signal strength belongs to the second middle area.
[0022] Optionally, the frequency band switching condition of the threshold interval includes:
[0023] The first signal strength belongs to the first middle area, and the difference between the first signal strength and the second signal strength is less than the first preset value;
[0024] The first signal strength belongs to the first weak area, and the difference between the first signal strength and the second signal strength is less than zero;
[0025] The first signal strength belongs to the second strong area;
[0026] The first signal strength belongs to the second middle area, and the difference between the first signal strength and the second signal strength is greater than the second preset value;
[0027] The first signal strength belongs to the second weak area, and the difference between the first signal strength and the second signal strength is greater than the third preset value.
[0028] Optionally, the steps of switching the current working frequency band to the candidate working frequency band include:
[0029] Obtain a frequency band switching instruction;
[0030] Disconnect the connection of the current wifi and send a disconnection event to the wifi network management module. The disconnection event refers to the interruption of the connection of the current wifi;
[0031] The wifi network management module determines whether the network management status of the current working frequency band interface is: connected, with an IP. The network management status includes a connection status value and an IP status value. The connection status value represents connected or not connected, and the IP status value represents having an IP or not having an IP;
[0032] If so, start a timer. The timer is set with a timeout value. Within the timeout value, the wifi network management module does not process the disconnection event for the time being, that is, the network management status of the current working frequency band interface remains: connected, with an IP;
[0033] Switch the wifi connection to the candidate wifi and send a connected event to the wifi network management module and the automatic IP acquisition module. The connected event refers to the successful connection of the candidate wifi;
[0034] Monitor the network management status of the candidate working frequency band interface through the wifi network management module;
[0035] If the network management status of the candidate working frequency band interface is: connected and has an IP, determine whether the timer exists;
[0036] If it exists, cancel the timer;
[0037] Send an IP generation request to the automatic IP acquisition module to renew a new IP;
[0038] Determine whether the new IP is the same as the current IP;
[0039] If they are the same, there is no need to change the IP;
[0040] If they are not the same, reset the IP and reset the default route.
[0041] Optionally, after the step of monitoring the network management status of the candidate working frequency band interface through the wifi network management module, the following steps are further included:
[0042] If the network management status of the candidate working frequency band interface is: connected and has no IP, send an IP generation request to the automatic IP acquisition module to generate an IP;
[0043] If an IP is obtained, set the IP and update the default route, and change the network management status of the candidate working frequency band interface to: connected and has an IP;
[0044] Obtain the network management status of the candidate working frequency band interface when the timer times out;
[0045] If the network management status of the candidate working frequency band interface is: connected and has an IP, the frequency band switching is successful;
[0046] If the network management status of the candidate working frequency band interface is: connected and has no IP, send an IP generation request to the automatic IP acquisition module after a certain delay to re-obtain an IP.
[0047] Optionally, after the step of monitoring the network management status of the candidate working frequency band interface through the wifi network management module, the following steps are further included:
[0048] If the network management status of the candidate working frequency band interface is: not connected and has no IP, change the network management status to: not connected and has no IP, and clear the IP and reselect the default route.
[0049] Optionally, when the timer times out, if the network management status of the candidate working frequency band interface is: connected, without an IP, then after a certain delay, an IP generation request is sent to the automatic IP acquisition module. After the step of re-acquiring the IP, the following steps are further included:
[0050] Set the IP and update the default route;
[0051] Change the network management status of the candidate working frequency band interface to: connected, with an IP.
[0052] According to a second aspect of the present disclosure, there is provided a frequency band switching device, the device includes:
[0053] A scanning module, configured to periodically scan for wifi to obtain the current wifi and candidate wifis. The current wifi corresponds to the current working frequency band, the candidate wifi corresponds to the candidate working frequency band, and the current working frequency band and the candidate working frequency band are respectively one of the first frequency band and the second frequency band supported by the terminal and the router;
[0054] A measurement module, configured to measure a first signal strength of communicating between the terminal and the router through the first frequency band and a second signal strength of communicating through the second frequency band;
[0055] A comparison module, configured to compare the first signal strength with a preset segmented threshold according to the working frequency band to determine the threshold interval to which the first signal strength belongs. The preset segmented threshold includes a first segmented threshold and a second segmented threshold. The first segmented threshold includes a first strong region, a first middle region, and a first weak region. The second segmented threshold includes a second strong region, a second middle region, and a second weak region. If the working frequency band is the first frequency band, the first signal strength is compared with the first segmented threshold to determine the threshold interval to which the first signal strength belongs in the first segmented threshold; if the working frequency band is the second frequency band, the first signal strength is compared with the second segmented threshold to determine the threshold interval to which the first signal strength belongs in the second segmented threshold;
[0056] A judgment module, configured to judge whether the first signal strength and the second signal strength meet the frequency band switching condition according to the threshold interval to which the first signal strength belongs;
[0057] A switching module, configured to switch the working frequency band to another frequency band different from the working frequency band.
[0058] According to a third aspect of the present disclosure, there is provided a computer-readable storage medium, the computer-readable storage medium includes a computer program, and when the computer program runs on an electronic device, the electronic device is caused to execute the frequency band switching method.
[0059] The beneficial effects of the present disclosure are as follows:
[0060] Two sets of segmented thresholds are respectively set for different current working frequency bands. Each set of segmented thresholds is set with different threshold intervals, and each threshold interval is set with different frequency band switching conditions. On the one hand, the signal strength is compared with the corresponding segmented threshold to determine the threshold interval to which the signal strength belongs. Compared with the setting of a single threshold, it avoids the signal strength from switching back and forth near the threshold, making the switching of the frequency band more stable. On the other hand, different frequency band switching conditions are set for different threshold intervals, making the switching of the frequency band more accurate and further avoiding the terminal from switching back and forth between two frequency bands.
[0061] At the same time, it is also proposed that when switching the frequency band, through the IP anti-shake management strategy, it is possible to ensure that the communication is not disconnected and the device is not offline as much as possible, enhancing the user experience of the device. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 is an implementation environment diagram related to a frequency band switching method shown in some exemplary embodiments of the present disclosure;
[0063] Figure 2 and 3 Figure 4 is a flowchart of a frequency band switching method shown according to an exemplary embodiment;
[0064] Figure 5 is a block diagram of a frequency band switching device shown according to an exemplary embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0065] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0066] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0067] Figure 1 is a schematic diagram of the implementation environment related to the frequency band switching method shown in some exemplary embodiments of the present disclosure. The implementation environment includes: a terminal 100 and a router 200;
[0068] The terminal 100 can be an electronic device that supports dual - band wireless communication, such as a smart phone, a tablet computer, an IP camera, etc. It has the ability to switch frequency bands and can switch to other frequency bands of the router 200 for communication when the signal quality of a certain frequency band accessed by the router 200 does not meet the communication requirements.
[0069] The router 200 is a dual - band wireless router and can communicate with the terminal 100 through the first frequency band and the second frequency band. Among them, the channel of the first frequency band has a larger bandwidth than that of the second frequency band when the signal quality is good. Therefore, in theory, connecting to the first frequency band for communication is a better strategy. However, the signal of the first frequency band attenuates faster with distance and has poor wall - penetration ability compared to the signal of the second frequency band. The signal of the second frequency band has a larger coverage area. When passing through walls or at a long distance, the signal of the second frequency band is more stable than that of the first frequency band and is not easily disconnected. In this disclosure, the second frequency band is described by taking the 2.4G frequency band as an example, and the first frequency band is described by taking the 5G frequency band as an example.
[0070] For the router 200 and the terminal 100 that support dual - band integration, the terminal 100 can be connected to a certain frequency band of the router 200 according to the actual situation. However, due to the relatively simple setting of the threshold in the existing terminal 100, the terminal 100 switches back and forth between the two frequency bands, affecting the user experience. In this disclosure, two groups of segmented thresholds are preset in the terminal 100. Each group of segmented thresholds is set with different threshold intervals, and each threshold interval is set with different frequency - band switching conditions. On the one hand, the frequency - band switching of this disclosure is more stable. By comparing the 5G signal strength with the corresponding segmented threshold, first determine the threshold interval to which the 5G signal strength belongs, and then judge whether to perform frequency - band switching. Compared with a single threshold setting, it avoids the terminal 100 switching back and forth between the two frequency bands when the signal strength is near the threshold. On the other hand, the frequency - band switching of this application is more accurate. Different frequency - band switching conditions are set for different threshold intervals, further avoiding the terminal 100 switching back and forth between the two frequency bands. Specifically, when judging frequency - band switching, first obtain the working frequency band corresponding to the current connection between the terminal 100 and the router 200, as well as the 5G signal strength of the communication between the terminal 100 and the router 200 through the 5G frequency band and the 2.4G signal strength of the communication through the 2.4G frequency band. According to the working frequency band corresponding to the current connection, compare the 5G signal strength with the corresponding segmented threshold to determine the threshold interval to which the 5G signal strength belongs. Then, according to the frequency - band switching conditions of the corresponding threshold interval, judge whether the 5G signal strength and the 2.4G signal strength meet the frequency - band switching conditions. If so, switch the working frequency band to another frequency band different from the working frequency band.
[0071] In addition, the frequency - band switching method of this disclosure mainly involves three functional modules: the wifi network management module, the wifi connection management module, and the automatic IP acquisition module.
[0072] WiFi network management module: responsible for the management functions of the WiFi interface, specifically including functions such as starting and stopping the WiFi interface, IP address configuration, routing table setting, and interface status monitoring.
[0073] WiFi connection management module: This is an open-source WiFi connection management program commonly used in embedded devices on a general Linux platform. It is responsible for completing WiFi connection management work and sending connection status change events such as disconnect and connected to the WiFi network management module.
[0074] Automatic IP acquisition module: used to automatically obtain or renew an IP address after a successful WiFi connection.
[0075] Figure 2 、 3 is a flowchart of a frequency band switching method shown according to an exemplary embodiment. The frequency band switching method is used in the terminal 100 in the implementation environment as shown in Figure 1 wherein the first frequency band is the 5G frequency band and the second frequency band is the 2.4G frequency band. As shown in Figure 2 the frequency band switching method may include the following steps:
[0076] S1. Periodically scan for WiFi, obtain the current WiFi and candidate WiFi. The current WiFi corresponds to the current working frequency band, the candidate WiFi corresponds to the candidate working frequency band, and the current working frequency band and the candidate working frequency band are respectively one of the first frequency band and the second frequency band supported by the terminal and the router;
[0077] S2. Measure the first signal strength of communicating between the terminal and the router through the first frequency band and the second signal strength of communicating through the second frequency band;
[0078] S3. According to the working frequency band, compare the first signal strength with a preset segmented threshold to determine the threshold interval to which the first signal strength belongs. The preset segmented threshold includes a first segmented threshold and a second segmented threshold. The first segmented threshold includes a first strong area, a first middle area, and a first weak area. The second segmented threshold includes a second strong area, a second middle area, and a second weak area. If the working frequency band is the first frequency band, compare the first signal strength with the first segmented threshold; if the working frequency band is the second frequency band, compare the first signal strength with the second segmented threshold;
[0079] S4. According to the threshold interval to which the first signal strength belongs, monitor whether the first signal strength and the second signal strength meet the judgment conditions for frequency band switching;
[0080] If so, in S5, switch the current operating frequency band to the candidate operating frequency band.
[0081] In the above step S1, the terminal 100 periodically scans for Wi-Fi, filters out all Wi-Fi networks with the same SSID according to the configured SSID. In this disclosure, taking the 2.4G Wi-Fi network and the 5G Wi-Fi network as examples, the Wi-Fi network currently connected between the terminal 100 and the router 200 is the current Wi-Fi, and the corresponding frequency band is the current operating frequency band, and the other is the candidate Wi-Fi, and the corresponding frequency band is the candidate operating frequency band. If the Wi-Fi network currently connected between the terminal and the router is the 2.4G Wi-Fi network, the current operating frequency band of the terminal is the 2.4G frequency band, and the candidate operating frequency band is the 5G frequency band; if the Wi-Fi network currently connected between the terminal and the router is the 5G Wi-Fi network, the current operating frequency band of the terminal is the 5G frequency band, and the candidate operating frequency band is the 2.4G frequency band.
[0082] In the above step S2, the terminal 100 can monitor the signal strengths of the two frequency bands in real time to obtain the signal strengths of the two frequency bands. The signal strength of the 2.4G frequency band is the 2.4G signal strength, and the signal strength of the 5G frequency band is the 5G signal strength.
[0083] In the above steps S3 - S4, the frequency band switching involves two aspects. Switching strategy 1 is to switch from the 5G frequency band to the 2.4G frequency band, and switching strategy 2 is to switch from the 2.4G frequency band to the 5G frequency band. Among them, switching from the 2.4G frequency band to the 5G frequency band means that the current working frequency band corresponding to the current connection between the terminal 100 and the router 200 is the 2.4G frequency band, and the candidate working frequency band is the 5G frequency band; switching from the 5G frequency band to the 2.4G frequency band means that the current working frequency band corresponding to the current connection between the terminal 100 and the router 200 is the 5G frequency band, and the candidate working frequency band is the 2.4G frequency band. For switching strategy 1, a first segmentation threshold is preset in the terminal 100. The first segmentation threshold includes a first strong area [0, h), a first middle area [h, l], and a first weak area [-256, l), where h is the boundary value between the first strong area and the first middle area, and l is the boundary value between the first middle area and the first weak area. When judging whether the 5G signal strength meets the frequency band switching condition, first, the 5G signal strength is compared with the boundary values l and h respectively to determine the threshold interval to which the 5G signal strength belongs in the first segmentation threshold. If the 5G signal strength is greater than the boundary value h, then the 5G signal strength belongs to the first strong area; if the 5G signal strength is less than the boundary value l, then the 5G signal strength belongs to the first weak area; if the 5G signal strength is greater than or equal to the boundary value l and less than or equal to the boundary value h, then the 5G signal strength belongs to the first middle area. Then, it is judged whether to perform frequency band switching according to the frequency band switching conditions of the corresponding threshold interval. Among them, the 5G signal in the first strong area is better than the 2.4G signal and has a larger bandwidth. Therefore, when the 5G signal strength belongs to the first strong area, the current working frequency band is maintained without frequency band switching; the 5G signal strength in the first middle area is weak and not much different from the 2.4G signal strength. Therefore, the frequency band switching condition for the first middle area is that the difference between the 5G signal strength and the 2.4G signal strength is less than a first preset value, the first preset value is greater than 0, preferably half of the difference between the boundary value h and the boundary value l, that is, the first preset value = (h - l) / 2; the 5G signal strength in the first weak area is weak, and the terminal 100 adopts the principle of stable networking priority and preferentially uses the 2.4G network. This can ensure that devices such as network cameras or IOT embedded devices can be online for a long time to the greatest extent. The frequency band switching condition is that the difference between the 5G signal strength and the 2.4G signal strength is less than zero. When the frequency band switching condition of the corresponding threshold interval is met, the current working frequency band is switched to the candidate working frequency band. For strategy 2, a second segmentation threshold is preset in the terminal 100. The second segmentation threshold includes a second strong area [0, H), a second middle area [H, L], and a second weak area [-256, L), where H is the boundary value between the second strong area and the second middle area, L is the boundary value between the second middle area and the second weak area, and H > h, L > l.First, compare the 5G signal strength with the boundary value L and the boundary value H respectively to determine the threshold interval to which the 5G signal strength belongs in the second segmented threshold. If the 5G signal strength is greater than the boundary value H, the 5G signal strength belongs to the second strongest area; if the 5G signal strength is less than the boundary value L, the 5G signal strength belongs to the second weakest area; if the 5G signal strength is greater than or equal to the boundary value L and less than or equal to the boundary value H, the 5G signal strength belongs to the second middle area. Then, determine whether to perform frequency band switching according to the frequency band switching conditions of the corresponding threshold interval. Among them, the 5G signal in the second strongest area is better than the 2.4G signal and has a larger bandwidth. Therefore, when the 5G signal strength belongs to the second strongest area, the current working frequency band is switched to the candidate working frequency band; the 5G signal strength in the second middle area is weak and the difference from the 2.4G signal strength is not large. Therefore, the frequency band switching condition for the second middle area is that the difference between the 5G signal strength and the 2.4G signal strength is greater than the second preset value, and the second preset value is greater than 0, preferably the difference between the boundary value H and the boundary value L, that is, the second preset value = H - L; the 5G signal strength in the second weakest area is weak, and the terminal 100 adopts the principle of stable network connection priority and preferentially uses the 2.4G network, which can ensure that devices such as network cameras or IOT can be online for a long time to the greatest extent. The frequency band switching condition is that the difference between the 5G signal strength and the 2.4G signal strength is greater than the third preset value, and the third preset value is preferably twice the second preset value, that is, the third preset value = 2*(H - L). If the frequency band switching condition of the corresponding threshold interval is satisfied, the current working frequency band is switched to the candidate working frequency band.
[0084] In summary, for the frequency band switching method shown in the embodiments of the present disclosure, by obtaining the current working frequency band corresponding to the current connection between the terminal 100 and the router 200, comparing the 5G signal strength with the corresponding segmented thresholds, if the current working frequency band is the 5G frequency band, comparing the 5G signal strength with the first segmented threshold, if the current working frequency band is the 2.4G frequency band, comparing the 5G signal strength with the second segmented threshold, obtaining the threshold interval to which the 5G signal strength belongs, different segmented thresholds are respectively set with different frequency band switching conditions, and then judging whether to perform frequency band switching according to the frequency band switching conditions of the threshold interval, so that the present disclosure can, when the 5G signal strength is weak, adopt the principle of stable network connection first and preferentially use the 2.4G network, which maximally ensures that devices such as network cameras or IOT can be online for a long time; when the 5G signal strength is strong, adopt the principle of speed first and the principle of throughput first, and by evaluating the router signal quality and predicting the throughput, preferentially select the 5G network, ensuring that the transmission throughput is as large as possible when the network quality is good; when the 5G signal strength is weak and the difference from the 2.4G signal strength is not significant, by adopting different segmentation and switching threshold strategies when switching from the 2.4G frequency band to the 5G frequency band and from the 5G frequency band to the 2.4G frequency band, the problem of repeated switching between the 5G and 2.4G networks that may be caused by a single partition threshold strategy is solved.
[0085] In step S5 above, as Figure 3 shown, the steps of switching the current working frequency band to the candidate working frequency band include:
[0086] S51. Obtain a frequency band switching instruction;
[0087] S52. Disconnect the connection of the current wifi and send a disconnection event to the wifi network management module, where the disconnection event refers to the interruption of the connection of the current wifi;
[0088] S53. Determine whether the wifi network management status of the current working frequency band interface by the wifi network management module is: connected, with an IP;
[0089] S54. If so, start a timer, the timer is set with a timeout value, and within the timeout value, the wifi network management module does not process the disconnection event for the time being, that is, the wifi network management status of the current working frequency band interface remains: connected, with an IP;
[0090] S55. Switch the wifi connection to the candidate wifi and send a connected event to the wifi network management module and the automatic IP acquisition module, where the connected event refers to the successful connection of the candidate wifi;
[0091] S56. Monitor the Wi-Fi network management status of the candidate working frequency band interface through the Wi-Fi network management module;
[0092] S57. Obtain the Wi-Fi network management status of the candidate working frequency band interface when the timer times out;
[0093] If the Wi-Fi network management status of the candidate working frequency band interface is: connected, with an IP, then the frequency band switch is successful;
[0094] If the Wi-Fi network management status of the candidate working frequency band interface is: connected, without an IP, then after a certain delay, send an IP generation request to the automatic IP acquisition module to re-acquire the IP;
[0095] If the Wi-Fi network management status of the candidate working frequency band interface is: not connected, without an IP, then the frequency band switch fails, and the Wi-Fi network management module changes the Wi-Fi network management status to: not connected, without an IP.
[0096] In the above steps S51 - S57, when the judgment result of the terminal 100 is to switch the current working frequency band to the candidate working frequency band, the Wi-Fi network management module will first interrupt the current Wi-Fi connection and then switch to connect to the candidate Wi-Fi. During this period, the Wi-Fi will experience a communication interruption. To ensure that the upper-layer services can run without interruption as much as possible, this patent specifically proposes an IP anti-shake method, that is, after the current Wi-Fi is disconnected, send a disconnection event to the Wi-Fi network management module. The Wi-Fi network management module determines whether the Wi-Fi network management status of the current working frequency band interface is: connected, with an IP. If so, start the timer. If not, change the Wi-Fi network management status to: not connected, without an IP. Among them, the timer is set with a timeout value, preferably 2 seconds. Within the timeout value, the Wi-Fi network management module does not process the disconnection event for the time being, and the Wi-Fi network management status of the current working frequency band interface remains: connected, with an IP, and does not clear the IP configuration and routing configuration of the current frequency band interface. If the terminal completes the frequency band switch before the timer times out, the disconnection event will be ignored, thus ensuring that the upper-layer applications are unaware of the network reconnection or switch, the TCP connection remains uninterrupted, and the IP anti-shake function is realized; if the terminal does not complete the frequency band switch before the timer times out, change the Wi-Fi network management status to: not connected, without an IP, and clear the IP and re-select the default route.
[0097] Specifically, the frequency band switch performed by the terminal 100 after receiving the frequency band switch instruction can be divided into two stages. See Figure 4 :
[0098] Stage 1: The Wi-Fi connection management module disconnects the current Wi-Fi and sends a disconnection event to the Wi-Fi network management module:
[0099] Step 1: The wifi network management module receives a disconnection event and determines whether the wifi network management status of the current working frequency band interface is: connected and has an IP. If so, go to Step 2; if not, go to Step 3;
[0100] Step 2: Start a timer and do not process the disconnection event for the time being. The timer is set with a timeout value, preferably 2 seconds. Within 2 seconds, the wifi network management status of the current working frequency band port remains: connected and has an IP;
[0101] Step 3: Change the wifi network management status of the terminal to: not connected and has no IP, then clear the IP and reselect the default route;
[0102] In Stage 2, the wifi connection management module connects the wifi network to the candidate wifi and sends a connected event to the wifi network management module. There are two cases in Stage 2. One case is that the wifi quickly switches or is disconnected and reconnected successfully in a short time, and the timer has not timed out; the other case is that the wifi fails to reconnect successfully within a short time. Specifically:
[0103] Step 1: The wifi network management module monitors the wifi network management status of the candidate working frequency band interface;
[0104] If the wifi network management status of the candidate working frequency band interface is connected and has an IP, then determine whether there is a timer; if there is, cancel the timer; go to Step 3;
[0105] If the wifi network management status of the candidate working frequency band interface is: connected and has no IP, go to Step 4;
[0106] If the wifi network management status of the candidate working frequency band interface is: not connected and has no IP, then change the wifi network management status of the terminal to: not connected and has no IP, and clear the IP and reselect the default route;
[0107] Step 2: Obtain the wifi network management status of the candidate working frequency band interface when the timer times out;
[0108] If the wifi network management status of the candidate working frequency band interface is: connected and has an IP, then the frequency band switching is successful; go to Step 8;
[0109] If the wifi network management status of the candidate working frequency band interface is: connected and has no IP, then send an IP generation request to the automatic IP acquisition module after a certain delay to re-acquire the IP; go to Step 7;
[0110] Step 3: Send an IP generation request to the automatic IP acquisition module to renew the IP. If a new IP is obtained, go to Step 5;
[0111] Step 4: Send an IP generation request to the automatic IP acquisition module to obtain an IP again; if an IP is obtained, set the IP and update the default route, and change the wifi network management status of the candidate working frequency band to: connected, with an IP; go to Step 2;
[0112] Step 5: Determine whether the new IP is the same as the currently set IP. If it is the same, there is no need to update the IP; if it is different, go to Step 6;
[0113] Step 6: Reset the IP and update the default route;
[0114] Step 7: Set the IP and update the default route; go to Step 8;
[0115] Step 8: Update the wifi network management status of the terminal to: connected, with an IP;
[0116] In summary, during the switching between the terminal 100 and the router 200 or the short-term disconnection and then reconnection, the present disclosure adds an IP anti-jitter management strategy, delays the sending of disconnection events, does not clear the IP, does not update the default route. If the short-term reconnection is successful, the disconnection event is ignored, and an IP renewal message is immediately sent after reconnection to check whether the IP has changed; if the IP does not change after IP renewal after switching, there is no need to reset the IP, so as to ensure that the upper-layer application is unaware of the network reconnection or switching, and the TCP connection remains uninterrupted; if the IP changes, the IP is immediately updated to ensure that the communication can be immediately restored.
[0117] Figure 4 is a block diagram of a frequency band switching device shown according to an exemplary embodiment. The frequency band switching device can be used in the terminal 100 in the implementation environment as shown in Figure 1 and execute the method as shown in Figure 2 . As shown in Figure 3 , the frequency band switching device includes but is not limited to: a scanning module 601, a measurement module 602, a comparison module 603, a judgment module 604, and a switching module 605.
[0118] The frequency band acquisition module is configured to obtain the working frequency band corresponding to the current connection between the terminal and the router, and the working frequency band is one of the first frequency band and the second frequency band supported by the terminal and the router;
[0119] The measurement module is configured to measure the first signal strength of communicating between the terminal and the router through the first frequency band and the second signal strength of communicating through the second frequency band;
[0120] The comparison module is configured to compare the first signal strength with a preset segmented threshold according to the operating frequency band to determine the threshold interval to which the first signal strength belongs. The preset segmented threshold includes a first segmented threshold and a second segmented threshold. The first segmented threshold includes a first strong region, a first middle region, and a first weak region. The second segmented threshold includes a second strong region, a second middle region, and a second weak region. If the operating frequency band is the first frequency band, the first signal strength is compared with the first segmented threshold; if the operating frequency band is the second frequency band, the first signal strength is compared with the second segmented threshold.
[0121] The determination module is configured to determine whether the first signal strength and the second signal strength meet the frequency band switching condition according to the threshold interval to which the first signal strength belongs.
[0122] The switching module is configured to switch the operating frequency band to another frequency band different from the operating frequency band.
[0123] In summary, the frequency band switching device shown in the embodiments of the present disclosure obtains the operating frequency band corresponding to the current connection between the terminal and the router, measures the 5G signal strength of the communication between the terminal and the router through the 5G frequency band and the 2.4G signal strength of the communication through the 2.4G frequency band, and then determines whether to perform frequency band switching according to the operating frequency band corresponding to the current connection and the 5G signal strength and the 2.4G signal strength.
[0124] In the case where the 5G router signal is weak, following the principle of giving priority to stable network connection, the 2.4G network is preferentially used, which maximally ensures that devices such as network cameras or IOT can be online for a long time.
[0125] In the case where the 5G router signal is strong, following the principle of giving priority to speed and the principle of giving priority to throughput, by evaluating the router signal quality and predicting the throughput, the 5G network is preferentially selected. This ensures that the transmission throughput is as large as possible when the network quality is good.
[0126] In the case where the 5G router signal is weak and not much different from the 2.4G signal, by adopting different segmentation and switching threshold strategies when switching from 2.4G to 5G and from 5G to 2.4G, the problem of repeated switching between the 5G and 2.4G networks that may be caused by a single partition threshold strategy is solved.
[0127] During the process of switching between routers or reconnecting after a short disconnection, an IP anti-jitter management strategy is added to delay the sending of disconnection events, without clearing the IP and without updating the default route. If the short-term reconnection is successful, the disconnection event is ignored, and an IP renewal message is immediately sent after reconnection to check whether the IP has changed; if the IP remains unchanged after the IP renewal after switching, there is no need to reset the IP, thus ensuring that the upper-layer application is unaware of the network reconnection or switching and the TCP connection remains uninterrupted; if the IP changes, the IP is immediately updated to ensure that communication can be restored immediately.
[0128] It should be understood that the present invention is not limited to the exact structures that have been described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present invention is only limited by the appended claims.
Claims
1. A frequency band switching method, comprising the following steps: Periodically scan Wi-Fi to obtain a current Wi-Fi and a candidate Wi-Fi, where the current Wi-Fi corresponds to a current operating frequency band, and the candidate Wi-Fi corresponds to a candidate operating frequency band, and the current operating frequency band and the candidate operating frequency band are one of a first frequency band and a second frequency band supported by the terminal and the router, respectively; Measuring a first signal strength between the terminal and the router in communication via the first frequency band and a second signal strength between the terminal and the router in communication via the second frequency band; According to the current operating frequency band, the first signal strength is compared with a preset segmentation threshold to determine the threshold interval to which the first signal strength belongs, the preset segmentation threshold includes a first segmentation threshold and a second segmentation threshold, the first segmentation threshold includes a first strong area, a first medium area, and a first weak area, and the second segmentation threshold includes a second strong area, a second medium area, and a second weak area. If the current operating frequency band is the first frequency band, the first signal strength is compared with the first segmentation threshold; if the current operating frequency band is the second frequency band, the first signal strength is compared with the second segmentation threshold; monitoring whether the first signal strength and the second signal strength meet a frequency band switching condition within the threshold range; If yes, switching the current operating frequency band to a candidate operating frequency band; If not, maintain the current operating frequency band.
2. The frequency band switching method according to claim 1, wherein If the current operating frequency band is the first frequency band, the step of comparing the first signal strength with the first segmentation threshold includes: Comparing the first signal strength with a first boundary value, where the first boundary value includes a boundary value h and a boundary value l, where the boundary value h is the boundary value between the first strong area and the first medium area, and the boundary value l is the boundary value between the first medium area and the first weak area; If the first signal strength is greater than the boundary value h, the first signal strength belongs to the first strong area; If the first signal strength is less than the boundary value 1, the first signal strength belongs to the first weak area; If the first signal strength is greater than or equal to the boundary value 1 and less than or equal to the boundary value h, the first signal strength belongs to the first middle zone.
3. The frequency band switching method according to claim 1, wherein If the current operating frequency band is the second frequency band, the step of comparing the first signal strength with the second segmentation threshold includes: Comparing the first signal strength with a second boundary value, where the second boundary value includes a boundary value H and a boundary value L, the boundary value H being the boundary value between the second strong area and the second medium area, and the boundary value L being the boundary value between the second medium area and the second weak area; If the first signal strength is greater than the boundary value H, the first signal strength belongs to the second strong area; If the first signal strength is less than a boundary value L, the first signal strength belongs to the second weak area; If the first signal strength is less than or equal to the boundary value H and greater than or equal to the boundary value L, the first signal strength belongs to the second middle area.
4. The frequency band switching method according to claim 1, wherein The frequency band switching conditions in the threshold range include: The first signal strength belongs to the first middle zone, and the difference between the first signal strength and the second signal strength is less than a first preset value; The first signal strength belongs to the first weak zone, and the difference between the first signal strength and the second signal strength is less than zero; The first signal strength belongs to the second strong zone; The first signal strength belongs to the second middle zone, and the difference between the first signal strength and the second signal strength is greater than a second preset value; The first signal strength belongs to the second weak zone, and the difference between the first signal strength and the second signal strength is greater than a third preset value.
5. The frequency band switching method according to claim 1, wherein: The step of switching the current working frequency band to the candidate working frequency band includes: Obtaining a frequency band switching instruction; Disconnecting the connection of the current Wi-Fi and sending a disconnection event to the Wi-Fi network management module, where the disconnection event refers to the interruption of the connection of the current Wi-Fi; Judging whether the network management status of the current working frequency band interface by the Wi-Fi network management module is: connected, with an IP; If so, start a timer. The timer is set with a timeout value. Within the timeout value, the Wi-Fi network management module does not process the disconnection event for the time being, that is, the network management status of the current working frequency band interface remains: connected, with an IP; Switching the Wi-Fi connection to the candidate Wi-Fi and sending a connected event to the Wi-Fi network management module and the automatic IP acquisition module, where the connected event refers to the successful connection of the candidate Wi-Fi; Monitoring the network management status of the candidate working frequency band interface by the Wi-Fi network management module; If the network management status of the candidate working frequency band interface is: connected, with an IP, then judge whether the timer exists; If it exists, cancel the timer; Sending an IP generation request to the automatic IP acquisition module to renew a new IP; Judging whether the new IP is the same as the current IP; If they are the same, there is no need to change the IP; If they are different, reset the IP and reset the default route.
6. The frequency band switching method according to claim 5, wherein After the step of monitoring the network management status of the candidate working frequency band interface by the Wi-Fi network management module, it further includes: If the network management status of the candidate working frequency band interface is: connected, without an IP, then send an IP generation request to the automatic IP acquisition module; If an IP is obtained, set the IP and update the default route, and change the network management status of the candidate working frequency band interface to: connected, with an IP; Obtaining the network management status of the candidate working frequency band interface when the timer times out; If the network management status of the candidate working frequency band interface is: connected, with an IP, then the frequency band switching is successful; If the network management status of the candidate working frequency band interface is: connected, without an IP, then send an IP generation request to the automatic IP acquisition module after a certain delay to re-obtain the IP.
7. The frequency band switching method according to claim 5, wherein After the step of monitoring the network management status of the candidate working frequency band interface by the Wi-Fi network management module, it further includes: If the network management status of the candidate working frequency band interface is: no connection, no IP, then change the network management status of the terminal to: no connection, no IP, clear the IP, and reselect the default route.
8. The frequency band switching method according to claim 6, wherein When the timer times out, if the network management status of the candidate working frequency band interface is: connected, no IP, then send an IP generation request to the automatic IP acquisition module after a certain delay. After the step of re-acquiring the IP, it further includes: If an IP is obtained, set the IP and set the default route; Change the network management status of the terminal to: connected, with IP.
9. A frequency band switching device, characterized in that, It includes: A scanning module, used to periodically scan for wifi, obtain the current wifi and candidate wifi. The current wifi corresponds to the current working frequency band, the candidate wifi corresponds to the candidate working frequency band, and the current working frequency band and the candidate working frequency band are respectively one of the first frequency band and the second frequency band supported by the terminal and the router; A measurement module, used to measure the first signal strength of communication between the terminal and the router through the first frequency band and the second signal strength of communication through the second frequency band; A comparison module, used to compare the first signal strength with a preset segmented threshold according to the working frequency band, determine the threshold interval to which the first signal strength belongs. The preset segmented threshold includes a first segmented threshold and a second segmented threshold. The first segmented threshold includes a first strong area, a first middle area, and a first weak area. The second segmented threshold includes a second strong area, a second middle area, and a second weak area. If the working frequency band is the first frequency band, compare the first signal strength with the first segmented threshold; if the working frequency band is the second frequency band, compare the first signal strength with the second segmented threshold; A judgment module, used to judge whether the first signal strength and the second signal strength meet the frequency band switching condition according to the threshold interval to which the first signal strength belongs; A switching module, used to switch the working frequency band to another frequency band different from the working frequency band.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a computer program. When the computer program runs on an electronic device, the electronic device is caused to execute the method according to any one of claims 1-8.
Citation Information
Patent Citations
PTT (Push To Talk) cluster system
CN104202730A
Multi-frequency WiFi identification method and device
CN111970750A