Channel switching method and apparatus, and computer device
By acquiring state change broadcasts to identify channel conflicts and perform channel switching, the problem of channel interference between network modules is solved, improving the user experience of network functions.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2025-09-17
- Publication Date
- 2026-04-02
AI Technical Summary
Different network modules may cause channel interference during channel switching, affecting the user experience.
By acquiring the state change broadcast of the network function, it is determined whether there is a channel conflict between the first network function and the second network function, and if a conflict exists, the second channel is switched to avoid channel interference.
It effectively mitigates channel interference between different network modules and improves the user experience of network functions.
Smart Images

Figure CN2025122006_02042026_PF_FP_ABST
Abstract
Description
Channel switching method, device and computer equipment
[0001] The present application claims priority to the Chinese patent application No. 202411340898.7, filed on September 24, 2024, and entitled "Channel switching method, device, computer equipment and computer readable storage medium", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the field of communication technology, in particular to a channel switching method, device and computer equipment. BACKGROUND
[0003] A terminal device can implement different network functions through different network modules. For example, the terminal device is equipped with two wifi chips, one wifi chip can implement station (sta) function and / or peer-to-peer (p2p) function, and the other wifi chip can implement access point (ap) function. TECHNICAL PROBLEM
[0004] Generally, different network functions corresponding to different network modules work in different channels, and there is no channel interference between different network functions corresponding to different network modules. However, during the use of the network functions, different network functions corresponding to different network modules may work in the same channel due to channel switching, resulting in channel interference between different network functions corresponding to different network modules. TECHNICAL SOLUTION
[0005] The embodiments of the present application provide a channel switching method, device and computer equipment, which can effectively alleviate the channel interference between different network functions corresponding to different network modules.
[0006] In a first aspect, the present application provides a channel switching method applied to a terminal device, the terminal device comprising a first network module and a second network module, the terminal device implementing a first network function through the first network module, and the terminal device implementing a second network function through the second network module, the channel switching method comprising:
[0007] obtaining a state change broadcast of the first network function;
[0008] determining whether a first channel corresponding to the first network function and a second channel corresponding to the second network function exist channel conflict based on the state change broadcast;
[0009] if the first channel and the second channel exist channel conflict, performing channel switching on the second channel.
[0010] In some embodiments of the present application, determining whether the first channel corresponding to the first network function and the second channel corresponding to the second network function have channel conflict based on the state change broadcast comprises:
[0011] obtaining a first channel identifier of the first channel from the state change broadcast;
[0012] determining whether the first channel has changed based on the first channel identifier;
[0013] if the first channel has changed, determining whether the first channel and the second channel have channel conflict based on the first channel identifier and a second channel identifier of the second channel.
[0014] In some embodiments of the present application, determining whether the first channel and the second channel have channel conflict based on the first channel identifier and the second channel identifier of the second channel comprises:
[0015] matching the first channel identifier and the second channel identifier of the second channel;
[0016] if the first channel identifier and the second channel identifier match, determining that the first channel and the second channel have channel conflict;
[0017] if the first channel identifier and the second channel identifier do not match, determining that the first channel and the second channel do not have channel conflict.
[0018] In some embodiments of the present application, determining whether the first channel has changed based on the first channel identifier comprises:
[0019] obtaining a third channel identifier of the first channel; the third channel identifier is a channel identifier of the first channel obtained from the state change broadcast last time;
[0020] if the first channel identifier and the third channel identifier match, determining that the first channel has not changed;
[0021] if the first channel identifier and the third channel identifier do not match, determining that the first channel has changed.
[0022] In some embodiments of the present application, obtaining the state change broadcast of the first network function comprises:
[0023] registering a broadcast listening object;
[0024] obtaining the state change broadcast of the first network function through the broadcast listening object.
[0025] In some embodiments of the present application, performing channel switching on the second channel comprises:
[0026] determining a fourth channel based on the first channel identifier of the first channel; the fourth channel is a channel different from the first channel.
[0027] generating a channel switching instruction based on the fourth channel identification of the fourth channel;
[0028] channel switching the second channel based on the channel switching instruction.
[0029] In some embodiments of the present application, the terminal device further comprises a first driving module, and the channel switching the second channel based on the channel switching instruction comprises:
[0030] sending the channel switching instruction to the first driving module through a preset channel switching interface;
[0031] channel switching the second channel based on the channel switching instruction through the first driving module.
[0032] In some embodiments of the present application, the first network function is a station function, and the second network function is an access point function.
[0033] In some embodiments of the present application, the first network function is a station function, and the second network function is a point-to-point function.
[0034] In some embodiments of the present application, the priority of the first network function is higher than the priority of the second network function.
[0035] In some embodiments of the present application, the terminal device further comprises a first network management module and a second network management module, the first network management module is used for managing the first network function, and the second network management module is used for managing the second network function.
[0036] In some embodiments of the present application, the terminal device further comprises a first function operation module and a second function operation module, the first function operation module is a bottom software for operating the first network function, and the second function operation module is a bottom software for operating the second network function.
[0037] In some embodiments of the present application, the terminal device further comprises a first driving module and a second driving module, the first driving module is a driver of the second network module, and the second driving module is a driver of the first network module.
[0038] In some embodiments of the present application, when the first network module and the second network module are wifi chips, the first drive module and the second drive module are wifi drivers, the first network function is a station function, the second network function is an access point function, the first network management module is WifiManager, the second network management module is SoftApManeger, the first function operation module is wpa_supplicant, the second function operation module is hostapd, the first drive module is used to control the access point function of the second network module, and the second drive module is used to control the station function of the first network module.
[0039] In some embodiments of the present application, the first network management module and the second network management module are arranged in a system service layer of the terminal device, and the first function operation module and the second function operation module are arranged in a hardware abstraction layer of the terminal device. The terminal device further comprises a first interface module and a second interface module, and the first interface module and the second interface module are used for function docking between the system service layer and the hardware abstraction layer.
[0040] In some embodiments of the present application, the channel conflict between the first channel and the second channel means that the first channel and the second channel are the same channel or the channel frequency of the first channel and the channel frequency of the second channel intersect.
[0041] In some embodiments of the present application, the registering of the broadcast listener object comprises: creating the broadcast listener object and registering the broadcast listener object in the application program, and the registering of the broadcast listener object in the application program comprises static registration and dynamic registration.
[0042] In the second aspect, the embodiments of the present application further provide a channel switching device applied to a terminal device, the terminal device comprising a first network module and a second network module, the terminal device realizing a first network function through the first network module, and the terminal device realizing a second network function through the second network module. The channel switching device comprises:
[0043] a broadcast obtaining module, configured to obtain a state change broadcast of the first network function;
[0044] a channel determining module, configured to determine, based on the state change broadcast, whether a first channel corresponding to the first network function and a second channel corresponding to the second network function exist a channel conflict;
[0045] a channel switching module, configured to perform channel switching on the second channel if the first channel and the second channel exist the channel conflict.
[0046] In the third aspect, the present application further provides a computer device, which comprises:
[0047] one or more processors;
[0048] a memory; and
[0049] one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the channel switching method of any one of the first aspect.
[0050] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is loaded by a processor to execute the steps in the channel switching method of any one of the first aspect. Advantages
[0051] By determining whether the first channel corresponding to the first network function and the second channel corresponding to the second network function exist channel conflict through the state change broadcast, if the first channel and the second channel exist channel conflict, the channel switching is performed on the second channel, in the case that the first network function and the second network function exist channel conflict, the second channel can be switched to a channel different from the first channel, thereby effectively relieving the channel interference between the network functions corresponding to different network modules. BRIEF DESCRIPTION OF DRAWINGS
[0052] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments described in the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.
[0053] Fig. 1 is a schematic structural diagram of one embodiment of a terminal device provided by an embodiment of the present application;
[0054] Fig. 2 is a schematic flow diagram of one embodiment of a channel switching method provided by an embodiment of the present application;
[0055] Fig. 3 is a schematic flow diagram of a specific embodiment of obtaining a state change broadcast provided by an embodiment of the present application;
[0056] Fig. 4 is a schematic flow diagram of a specific embodiment of determining whether the first channel and the second channel exist channel conflict provided by an embodiment of the present application;
[0057] Fig. 5 is a schematic flow diagram of a specific embodiment of performing channel switching on the second channel provided by an embodiment of the present application;
[0058] Fig. 6 is a principle block diagram of a channel switching device provided by an embodiment of the present application;
[0059] Fig. 7 is a schematic structural diagram of one embodiment of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0060] The technical solutions in the embodiments of the present application will be described clearly and completely in the following description of the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person skilled in the art without creative work fall within the scope of protection of the present application.
[0061] In the description of the present application, the terms "first", "second", "third", etc. are only used for the purpose of description, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second", "third", etc. can be explicitly or implicitly included one or more of the features.
[0062] In the present application, the word "exemplary" is used to mean "serving as an example, instance, or illustration". Any implementation described as "exemplary" in the present application is not necessarily to be construed as preferred or advantageous over other implementations. The following description is presented to enable any person skilled in the art to make and use the present application. In the following description, for the purpose of explanation, details are set forth. It is apparent to those skilled in the art that the present application can be practiced without using these specific details. In other instances, well-known structures and processes are not described in detail in order to avoid obscuring the description of the present application. Therefore, the present application is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein.
[0063] It should be noted that the method of the embodiments of the present application is executed in the computer device, and the processing object of each computer device exists in the form of data or information, such as time, which is actually time information. It can be understood that if the size, quantity, position, etc. are mentioned in the subsequent embodiments, they all exist in the corresponding data for processing by the computer device, and the specific details are not described here.
[0064] The present application provides a channel switching method, device and computer device, which are described in detail below.
[0065] The channel switching method provided by the embodiments of the present application is applied to a terminal device. Please refer to FIG. 1, which is a schematic diagram of a scenario of a terminal device provided by the embodiments of the present application. The terminal device can include a first network module and a second network module. The terminal device implements a first network function through the first network module, and implements a second network function through the second network module. The first network module or the second network module in the embodiments of the present application can implement one or more network functions, which include but are not limited to one or more of a station (sta) function, an access point (ap) function, and a Peer-to-Peer (p2p) function. The first network function or the second network function belongs to one or more of the above network functions. It should be noted that the first network function implemented through the first network module and the second network function implemented through the second network module are different network functions. For example, the first network function can be a station (sta) function, and the second network function can be an access point (ap) function; for another example, the first network function can be a station (sta) function, and the second network function can be a Peer-to-Peer (p2p) function; for another example, the first network function can be an access point (ap) function, and the second network function can be a Peer-to-Peer (p2p) function, and the embodiments are not limited in this regard. The sta function is a daily used wifi scanning and connection function, the ap function represents a hotspot function, and the p2p function represents a point-to-point communication or wifi direct function.
[0066] Optionally, continuing to refer to FIG. 1, the terminal device can further include a first network management module, a second network management module, a first function operation module, a second function operation module, a first driver module, and a second driver module. The first network management module and the second network management module are used to manage the first network function and the second network function respectively. The first function operation module and the second function operation module are bottom-layer software for operating the first network function and the second network function respectively. The first function operation module and the second function operation module can be programmed by using C language. The first driver module and the second driver module are drivers of the second network module and the first network module respectively. The first driver module and the second driver module can directly control various functions of the corresponding network module.
[0067] For example, when the first network module and the second network module are wifi chips, the first drive module and the second drive module are wifi drivers, the first network function is a sta function, and the second network function is an ap function, the first network management module is WifiManager, the second network management module is SoftApManeger, the first function operation module is wpa_supplicant, the second function operation module is hostapd, and the first drive module can directly control the ap function of the second network module, and the second drive module can directly control the sta function of the first network module.
[0068] With continuous reference to FIG. 1, the first network management module and the second network management module are arranged in a system service layer (System Service) of the terminal device, the first function operation module and the second function operation module are arranged in a hardware abstraction layer (Hardware Abstraction Layer, Hal) of the terminal device, and the terminal device further includes a first interface module and a second interface module. The first interface module and the second interface module are used for function docking between the System Service and the Hal layer, for example, the first interface module is HostapdHal, the second interface module is android.hardware.wifi.hostapd@1.2.so, and HostapdHal and android.hardware.wifi.hostapd@1.2.so are used for ap function docking between the System Service and the Hal layer.
[0069] The terminal device in the embodiment of the present application is integrated with a channel switching device, which is mainly used for acquiring a state change broadcast of a first network function, determining whether a first channel corresponding to the first network function and a second channel corresponding to a second network function exist channel conflict based on the state change broadcast, and performing channel switching on the second channel if the first channel and the second channel exist channel conflict, so as to effectively alleviate channel interference between network functions corresponding to different network modules.
[0070] The terminal device used in the embodiment of the present application can be a device including receiving and transmitting hardware, i.e., a device having receiving and transmitting hardware capable of performing bidirectional communication on a bidirectional communication link. Such a device can include a cellular or other communication device having a single-line display or a multi-line display or a cellular or other communication device without a multi-line display. The terminal device can be specifically a desktop terminal or a mobile terminal, and the terminal device can be specifically one of a mobile phone, a tablet computer, a notebook computer, and the like.
[0071] It should be noted that the scenario of the terminal device shown in FIG. 1 is only an example, and the terminal device and the scenario described in the embodiments of the present application are used to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of terminal devices and the emergence of new service scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0072] First, a channel switching method, device and computer equipment are provided in the embodiments of the present application. The execution subject of the channel switching method is a channel switching device. The channel switching device is applied to a terminal device. The terminal device includes a first network module and a second network module. The terminal device realizes a first network function through the first network module. The terminal device realizes a second network function through the second network module. The channel switching method includes the following steps: acquiring a state change broadcast of the first network function; determining whether a first channel corresponding to the first network function and a second channel corresponding to the second network function exist channel conflict based on the state change broadcast; and performing channel switching on the second channel if the first channel and the second channel exist channel conflict.
[0073] As shown in FIG. 2, it is a flowchart of one embodiment of the channel switching method in the embodiments of the present application. The channel switching method can include the following steps S201-S203, which are as follows:
[0074] Step S201, acquiring a state change broadcast of the first network function.
[0075] In the embodiments, the first network function can be a station (sta) function, the first network function can also be an access point (ap) function, and the first network function can also be a Peer-to-Peer (p2p) function. The embodiments are not limited. When the first network function changes, the channel of the first network function can be switched. In order to avoid channel conflict between the first network function and the second network function, the first network management module will issue a state change broadcast when the first network function changes. For example, the first network function is a sta function. When the terminal device successfully connects to a hotspot in the environment, the terminal device is disconnected from the hotspot in the environment, or the terminal device successfully reconnects to the hotspot in the environment, it indicates that the sta function changes, and the WifiManager issues a state change broadcast.
[0076] Further, the state change broadcast refers to a data transmission or information transmission mechanism in the computer and communication fields, especially in computer networks and Android systems. This mechanism allows information to be sent from one or more sources to multiple recipients, usually used to notify or update the state of the system when a specific event occurs. In this embodiment, the state change broadcast refers to the state change information sent when the first network function changes state. The state change broadcast includes the channel identifier of the current working channel of the first network function. Based on the channel identifier of the current working channel corresponding to the first network function, it can be determined whether the working channel of the first network function has changed, and in the case of a change in the working channel of the first network function, it is determined whether there is a channel conflict between the working channel of the first network function and the working channel of the second network function.
[0077] Step S202, based on the state change broadcast, determine whether the first channel corresponding to the first network function and the second channel corresponding to the second network function exist channel conflict.
[0078] In this embodiment, the first channel refers to the current working channel of the first network function, and the second channel refers to the current working channel of the second network function. The first channel and the second channel exist channel conflict means that the first channel and the second channel are the same channel or the channel frequency of the first channel and the channel frequency of the second channel exist intersection. When the first channel and the second channel are the same channel or the channel frequency of the first channel and the channel frequency of the second channel exist intersection, since the first network function and the second network function are in different network modules, the first channel and the second channel will interfere with each other. Therefore, channel switching needs to be performed on the first channel or the second channel to avoid mutual interference between the first channel and the second channel.
[0079] Step S203, if the first channel and the second channel exist channel conflict, perform channel switching on the second channel.
[0080] In a specific embodiment, the priority of the first network function is higher than the priority of the second network function, for example, the first network function is a sta function and the second network function is an ap function. Since the channel of the first network function is determined by the environment hotspot connected by the terminal device, the priority of the sta function is higher than the priority of the ap function. After determining that the first channel and the second channel exist channel conflict in this embodiment, channel switching is performed on the second channel with lower priority, which can effectively avoid mutual interference between the first channel and the second channel.
[0081] For example, the first network function is a sta function, the second network function is an ap function, the terminal device starts the sta function and selects a channel 44 of an environment hotspot for connection, and the ap function is started by selecting a channel 149. At this time, the sta function and the ap function work in different channels and do not interfere with each other. Subsequently, the user switches the sta function to another hotspot located in the channel 149. At this time, because the sta function and the ap function work in the same channel, the channel of the sta function and the channel of the ap function interfere with each other, and the use experience of the related functions is affected. The channel switching method provided in the embodiment can effectively avoid the interference between the channel of the sta function and the channel of the ap function by switching the channel of the ap function to another channel different from the channel 149 after the channel of the sta function is switched to the channel 149.
[0082] In a specific implementation, with reference to FIG. 3, the step S201 of obtaining the state change broadcast of the first network function can include steps S301-S302, and the steps are specifically as follows.
[0083] The step S301 includes registering a broadcast listening object.
[0084] In a specific embodiment, the registration of the broadcast listening object includes creating the broadcast listening object and registering the broadcast listening object in an application. The registration of the broadcast listening object in the application includes static registration and dynamic registration. The static registration is suitable for a listening task that needs to be run when the application is started or a listener that does not need to be frequently registered and unregistered. The dynamic registration is suitable for a scenario that needs to be listened to only under specific conditions or a listener that can be conveniently unregistered when the listening condition is no longer met. The broadcast listening object of the dynamic registration is only created when the broadcast is received and is destroyed immediately after the broadcast is processed. Therefore, the dynamic registration is more lightweight and does not increase the long-term burden of the application.
[0085] The step S302 includes obtaining the state change broadcast of the first network function through the broadcast listening object.
[0086] In a specific embodiment, in combination with FIG. 1, the channel switching method is executed through a second network management module. After the second network management module registers a broadcast listening object, the state change broadcast sent by a first network management module can be obtained through the broadcast listening object. For example, the first network management module is a WifiManager, and the second network management module is a SoftapManager. After the SoftapManager registers a broadcast listening object, the state change broadcast sent by the WifiManager can be obtained through the broadcast listening object.
[0087] In a specific implementation, with reference to FIG. 4, the step of determining, in step S202, whether the first channel corresponding to the first network function and the second channel corresponding to the second network function have a channel conflict based on the state change broadcast can include steps S401-S403, which are as follows:
[0088] In step S401, a first channel identifier of the first channel is obtained from the state change broadcast.
[0089] In this embodiment, the first channel identifier is used to indicate the channel in which the first network function is currently operating. In an optional implementation, the first channel identifier can be a channel number of the first channel or a channel ID of the first channel, or other indication information used to indicate the channel in which the first network function is currently operating, which is not limited in this embodiment. For example, if the first channel is channel 149, the first channel identifier can be “149”.
[0090] In step S402, it is determined whether the first channel has changed based on the first channel identifier.
[0091] During use of the first network function, the first channel can change. For example, the first network function is a sta function, a terminal device starts the sta function and selects an environment hotspot at channel 44 for connection, and then a user switches the sta function to another hotspot at channel 149, so the first channel changes.
[0092] It is considered that the working channels of the first network function and the second network function do not have a conflict at the beginning, and the first channel and the second channel have a conflict only because of channel switching during use of the first network function. Therefore, if the first channel has not changed, the first channel and the second channel do not have a conflict at all, and only when the first channel changes, it is necessary to further determine whether the first channel and the second channel have a conflict.
[0093] In a specific embodiment, the step of determining whether the first channel has changed based on the first channel identifier specifically includes: obtaining a third channel identifier of the first channel; if the first channel identifier and the third channel identifier match, it is determined that the first channel has not changed; and if the first channel identifier and the third channel identifier do not match, it is determined that the first channel has changed.
[0094] The third channel identifier is the channel identifier of the first channel obtained from the last state change broadcast. After obtaining the third channel identifier, the third channel identifier and the first channel identifier are matched. If the first channel identifier and the third channel identifier match, it is determined that the first channel has not changed. If the first channel identifier and the third channel identifier do not match, it is determined that the first channel has changed. For example, if the first channel identifier and the third channel identifier are both 44, the first channel identifier and the third channel identifier match, and the first channel has not changed. If the first channel identifier is 44 and the third channel identifier is 149, the first channel identifier and the third channel identifier do not match, and the first channel has changed.
[0095] In step S403, if the first channel has changed, whether the first channel and the second channel have channel conflict is determined based on the first channel identifier and the second channel identifier of the second channel.
[0096] In this embodiment, the second channel identifier is used to indicate the channel currently worked by the second network function. In an optional implementation, the second channel identifier can be a channel number of the second channel or a channel ID of the second channel, and can also be other indication information used to indicate the channel currently worked by the first network function, which is not limited in this embodiment. For example, if the second channel is channel 149, the second channel identifier can be "149".
[0097] After determining whether the first channel has changed based on the first channel identifier, if the first channel has changed, whether the first channel and the second channel have channel conflict is determined based on the first channel identifier and the second channel identifier of the second channel. If the first channel has not changed, the step of obtaining the state change broadcast of the first network function is continued.
[0098] In a specific embodiment, the step of determining whether the first channel and the second channel have channel conflict based on the first channel identifier and the second channel identifier of the second channel specifically includes: matching the first channel identifier and the second channel identifier of the second channel; if the first channel identifier and the second channel identifier match, it is determined that the first channel and the second channel have channel conflict; if the first channel identifier and the second channel identifier do not match, it is determined that the first channel and the second channel do not have channel conflict.
[0099] For example, if the first channel identifier is 44 and the second channel identifier is 149, the first channel identifier and the second channel identifier do not match, and the first channel and the second channel do not have channel conflict. If the first channel identifier and the second channel identifier are both 149, the first channel identifier and the second channel identifier match, and the first channel and the second channel have channel conflict.
[0100] In a specific implementation, referring to FIG. 5, the channel switching of the second channel in step S203 can include steps S501-S503, which are specifically as follows:
[0101] Step S501, determining the fourth channel based on the first channel identifier of the first channel.
[0102] In a specific embodiment, the fourth channel is a channel different from the first channel. The step of determining the fourth channel based on the first channel identifier of the first channel specifically includes: determining a target channel identifier from the preset channel identifiers based on the first channel identifier of the first channel; the target channel identifier is a channel identifier different from the first channel identifier in the preset channel identifiers; and determining the channel corresponding to the target channel identifier as the fourth channel. For example, the commonly used wifi channels currently have 2.4G and 5G frequency bands, the commonly used channels of the 2.4G frequency band channels have channel identifiers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, and the commonly used channels of the 5G frequency band channels have channel identifiers 36, 40, 44, 48, 149, 153, 157, 161, 165; if the first channel identifier is 44, the target channel identifier is determined as 149 from the channel identifiers of the commonly used 5G frequency band channels, and the channel corresponding to 149 is determined as the fourth channel.
[0103] Step S502, generating a channel switching instruction based on the fourth channel identifier of the fourth channel.
[0104] In this embodiment, the channel switching instruction is a channel switching command for switching the second channel to the fourth channel, and the second channel can be switched to the fourth channel based on the channel switching instruction, thereby avoiding the problem of channel conflict caused by the working channel of the first network function being the same as the working channel of the second network function. For example, the fourth channel identifier is 149, the second channel is channel 44, and the channel switching instruction can be "switch channel 44 to channel 149".
[0105] Step S503, channel switching of the second channel based on the channel switching instruction.
[0106] In a specific embodiment, the terminal device further includes a first driving module for controlling various functions of the second network module, and the step of channel switching of the second channel based on the channel switching instruction specifically includes: sending the channel switching instruction to the first driving module through a preset channel switching interface; and channel switching of the second channel based on the channel switching instruction through the first driving module.
[0107] The existing terminal device needs to restart the second network function to realize channel switching of the second channel. In order to realize channel switching of the second channel without restarting the second network function, referring to FIG. 1, the embodiment adds a channel switching interface in the first interface module, the second interface module and the second function operation module. The second network management module sends a channel switching instruction to the first driving module through the channel switching interface, and the first driving module performs channel switching on the second channel based on the channel switching instruction. For example, the second network management module is SoftManager, the first interface module is HostapdHal, the second interface module is android.hardware.wifi.hostapd@1.2.so, the second function operation module is hostapd, and the first driving module is wifi driver. The channel switching interface is added in HostapdHal, android.hardware.wifi.hostapd@1.2.so and hostapd. SoftManager sends a channel switching instruction to wifi driver through the channel switching interface, and wifi driver performs channel switching on the second channel based on the channel switching instruction.
[0108] In order to better realize the channel switching method in the embodiment of the application, on the basis of the channel switching method, the embodiment of the application further provides a channel switching device. The channel switching device is applied to a terminal device. The terminal device includes a first network module and a second network module. The terminal device realizes a first network function through the first network module, and realizes a second network function through the second network module. As shown in FIG. 6, the channel switching device 700 includes:
[0109] The broadcast acquisition module 710 is configured to acquire a state change broadcast of the first network function.
[0110] The channel determination module 720 is configured to determine whether a first channel corresponding to the first network function and a second channel corresponding to the second network function exist channel conflict based on the state change broadcast.
[0111] The channel switching module 730 is configured to perform channel switching on the second channel if the first channel and the second channel exist channel conflict.
[0112] In the embodiment of the application, whether the first channel corresponding to the first network function and the second channel corresponding to the second network function exist channel conflict is determined based on the state change broadcast. Channel switching is performed on the second channel if the first channel and the second channel exist channel conflict. In the case that the first network function and the second network function exist channel conflict, the second channel can be switched to a channel different from the first channel, thereby effectively alleviating channel interference between network functions corresponding to different network modules.
[0113] In some embodiments of the present application, the broadcast obtaining module 710 obtains the state change broadcast of the first network function, including:
[0114] Registering a broadcast listening object;
[0115] Obtaining the state change broadcast of the first network function through the broadcast listening object.
[0116] In some embodiments of the present application, the channel determination module 720 determines whether the first channel corresponding to the first network function and the second channel corresponding to the second network function exist channel conflict based on the state change broadcast, including:
[0117] Obtaining a first channel identifier of the first channel from the state change broadcast;
[0118] Determining whether the first channel changes based on the first channel identifier;
[0119] If the first channel changes, determining whether the first channel and the second channel exist channel conflict based on the first channel identifier and a second channel identifier of the second channel.
[0120] In some embodiments of the present application, the channel determination module 720 determines whether the first channel and the second channel exist channel conflict based on the first channel identifier and the second channel identifier of the second channel, including:
[0121] Matching the first channel identifier and the second channel identifier of the second channel;
[0122] If the first channel identifier and the second channel identifier match, determining that the first channel and the second channel exist channel conflict;
[0123] If the first channel identifier and the second channel identifier do not match, determining that the first channel and the second channel do not exist channel conflict.
[0124] In some embodiments of the present application, the channel determination module 720 determines whether the first channel changes based on the first channel identifier, including:
[0125] Obtaining a third channel identifier of the first channel; the third channel identifier is the channel identifier of the first channel obtained from the state change broadcast last time;
[0126] If the first channel identifier and the third channel identifier match, determining that the first channel does not change;
[0127] If the first channel identifier and the third channel identifier do not match, determining that the first channel changes.
[0128] In some embodiments of the present application, the channel switching module 730 performs channel switching on the second channel, including:
[0129] determine a fourth channel based on the first channel identification of the first channel, the fourth channel being a channel different from the first channel;
[0130] generate a channel switching instruction based on the fourth channel identification of the fourth channel;
[0131] switch the second channel based on the channel switching instruction.
[0132] In some embodiments of the present application, the terminal device further comprises a first driving module, and the channel switching module 730 switches the second channel based on the channel switching instruction, including:
[0133] sending the channel switching instruction to the first driving module through a preset channel switching interface;
[0134] switching the second channel based on the channel switching instruction through the first driving module.
[0135] Embodiments of the present application also provide a computer device integrating any of the channel switching devices provided by the embodiments of the present application. The computer device comprises:
[0136] one or more processors;
[0137] a memory; and
[0138] one or more application programs, wherein the one or more application programs are stored in the memory and configured to execute, by the processor, the steps in the channel switching method in any of the channel switching method embodiments.
[0139] Embodiments of the present application also provide a computer device integrating any of the channel switching devices provided by the embodiments of the present application. As shown in FIG. 7, it shows the structural schematic diagram of the computer device related to the embodiments of the present application, specifically:
[0140] The computer device can include a processor 801 with one or more processing cores, a memory 802 with one or more computer readable storage media, a power supply 803, and an input unit 804, etc. Those skilled in the art can understand that the computer device structure shown in FIG. 7 does not constitute a limitation on the computer device, and can include more or fewer components than the illustration, or combine certain components, or different component arrangements. Among them:
[0141] The processor 801 is the control center of the computer device, connects the various parts of the computer device through various interfaces and lines, and performs various functions and processes data of the computer device by running or executing software programs and / or modules stored in the memory 802 and calling data stored in the memory 802, thereby overall monitoring the computer device. Optionally, the processor 801 can include one or more processing cores; preferably, the processor 801 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 801.
[0142] The memory 802 can be used to store software programs and modules, and the processor 801 executes various functions and data processing by running the software programs and modules stored in the memory 802. The memory 802 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), etc.; the data storage area can store data created according to the use of the computer device, etc. In addition, the memory 802 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. Accordingly, the memory 802 can also include a memory controller to provide access for the processor 801 to the memory 802.
[0143] The computer device further includes a power supply 803 for powering various components, and preferably the power supply 803 can be logically connected to the processor 801 through a power management system, so as to realize functions such as management of charging, discharging and power consumption management through the power management system. The power supply 803 can also include one or more than one direct current or alternating current power supply, a recharging system, a power failure detection circuit, a power converter or inverter, a power state indicator, etc. Any component.
[0144] The computer device can also include an input unit 804, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0145] Although not shown, the computer device can also include a display unit, etc., which will not be described here. Specifically, in the present embodiment, the processor 801 in the computer device will load the executable file corresponding to the process of one or more than one application program into the memory 802 according to the following instructions, and run the application program stored in the memory 802 by the processor 801, thereby realizing various functions, as follows:
[0146] obtaining a state change broadcast of the first network function;
[0147] determining, based on the state change broadcast, whether a first channel corresponding to the first network function and a second channel corresponding to the second network function exist channel conflict;
[0148] if the first channel and the second channel exist channel conflict, performing channel switching on the second channel.
[0149] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling relevant hardware by the instructions, which can be stored in a computer readable storage medium and loaded and executed by a processor.
[0150] To this end, the embodiments of the present application provide a computer readable storage medium, which can include a read only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc. A computer program is stored on the storage medium, and the computer program is loaded by a processor to execute the steps in any of the channel switching methods provided by the embodiments of the present application. For example, the computer program loaded by the processor can execute the following steps:
[0151] obtaining a state change broadcast of the first network function;
[0152] determining, based on the state change broadcast, whether a first channel corresponding to the first network function and a second channel corresponding to the second network function exist channel conflict;
[0153] if the first channel and the second channel exist channel conflict, performing channel switching on the second channel.
[0154] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the detailed description of other embodiments above, which will not be repeated here.
[0155] In specific implementation, each unit or structure above can be implemented as an independent entity, or can be combined as the same or several entities, and the specific implementation of each unit or structure can be referred to the method embodiments above, which will not be repeated here.
[0156] The specific implementation of each operation above can be referred to the embodiments above, which will not be repeated here.
[0157] The above describes in detail the channel switching method, device and computer equipment provided by the embodiments of the present application. The principles and implementation manners of the present application are described by using specific examples. The above description of the embodiments is only used to help understand the method of the present application and its core idea. Meanwhile, for those skilled in the art, the specific implementation manners and application ranges will be changed according to the idea of the present application. In conclusion, the content of the specification should not be understood as a limitation of the present application.
Claims
A channel switching method, wherein, The channel switching method is applied to a terminal device, the terminal device comprising a first network module and a second network module, the terminal device realizing a first network function through the first network module, and the terminal device realizing a second network function through the second network module, and the channel switching method comprising: acquiring a state change broadcast of the first network function; determining, based on the state change broadcast, whether a first channel corresponding to the first network function and a second channel corresponding to the second network function exist channel conflict; if the first channel and the second channel exist channel conflict, performing channel switching on the second channel. The channel switching method of claim 1, wherein, The determining, based on the state change broadcast, whether the first channel and the second channel exist channel conflict comprises: acquiring a first channel identifier of the first channel from the state change broadcast; determining, based on the first channel identifier, whether the first channel changes; if the first channel changes, determining, based on the first channel identifier and a second channel identifier of the second channel, whether the first channel and the second channel exist channel conflict. The channel switching method according to claim 2, wherein The determining, based on the first channel identifier and the second channel identifier, whether the first channel and the second channel exist channel conflict comprises: matching the first channel identifier and the second channel identifier; if the first channel identifier and the second channel identifier match, determining that the first channel and the second channel exist channel conflict; if the first channel identifier and the second channel identifier do not match, determining that the first channel and the second channel do not exist channel conflict. The channel switching method according to claim 2, wherein The determining, based on the first channel identifier, whether the first channel changes comprises: acquiring a third channel identifier of the first channel; the third channel identifier being a channel identifier of the first channel acquired from the state change broadcast last time; if the first channel identifier and the third channel identifier match, determining that the first channel does not change; if the first channel identifier and the third channel identifier do not match, determining that the first channel changes. The channel switching method of claim 1, wherein, The acquiring the state change broadcast of the first network function comprises: registering a broadcast listening object; acquiring the state change broadcast of the first network function through the broadcast listening object. The channel switching method of claim 1, wherein, The performing channel switching on the second channel comprises: determining a fourth channel based on a first channel identifier of the first channel; the fourth channel being a channel different from the first channel; generating a channel switching instruction based on a fourth channel identifier of the fourth channel; performing channel switching on the second channel based on the channel switching instruction. The channel switching method according to claim 6, wherein The terminal device further comprises a first driving module, and the performing channel switching on the second channel based on the channel switching instruction comprises: sending the channel switching instruction to the first driving module through a preset channel switching interface; performing channel switching on the second channel based on the channel switching instruction through the first driving module. The channel switching method of claim 1, wherein, The first network function is a station function, and the second network function is an access point function. The channel switching method of claim 1, wherein, The first network function is a station function, and the second network function is a point-to-point function. The channel switching method of claim 1, wherein, The first network function is an access point function, and the second network function is a point-to-point function. The channel switching method of claim 1, wherein, The priority of the first network function is higher than the priority of the second network function. The channel switching method of claim 1, wherein, The terminal device further comprises a first network management module and a second network management module, the first network management module is used for managing the first network function, and the second network management module is used for managing the second network function. The channel switching method of claim 12, wherein, The terminal device further comprises a first function operation module and a second function operation module, the first function operation module is a bottom software for operating the first network function, and the second function operation module is a bottom software for operating the second network function. The channel switching method of claim 13, wherein, The terminal device further comprises a first drive module and a second drive module, the first drive module is a drive of the second network module, and the second drive module is a drive of the first network module. The channel switching method of claim 14, wherein, When the first network module and the second network module are wifi chips, the first drive module and the second drive module are wifi drivers, the first network function is a station function, and the second network function is an access point function, the first network management module is WifiManager, the second network management module is SoftApManeger, the first function operation module is wpa_supplicant, the second function operation module is hostapd, the first drive module is used for controlling the access point function of the second network module, and the second drive module is used for controlling the station function of the first network module. The channel switching method of claim 14, wherein, The first network management module and the second network management module are arranged in a system service layer of the terminal device, the first function operation module and the second function operation module are arranged in a hardware abstraction layer of the terminal device, and the terminal device further comprises a first interface module and a second interface module, the first interface module and the second interface module are used for function docking between the system service layer and the hardware abstraction layer. The channel switching method according to claim 3, wherein The channel conflict between the first channel and the second channel means that the first channel and the second channel are the same channel, or the channel frequency of the first channel and the channel frequency of the second channel intersect. The channel switching method according to claim 5, wherein The registering of the broadcast listening object comprises creating the broadcast listening object and registering the broadcast listening object in an application program, and the way of registering the broadcast listening object in the application program comprises static registration and dynamic registration. A channel switching apparatus, wherein, The terminal device comprises a first network module and a second network module, the terminal device realizes a first network function through the first network module, the terminal device realizes a second network function through the second network module, and the channel switching device comprises: A broadcast acquisition module is configured to acquire a state change broadcast of the first network function. A broadcast acquisition module is configured to acquire a state change broadcast of the first network function. A channel determination module is configured to determine, based on the state change broadcast, whether a first channel corresponding to the first network function and a second channel corresponding to the second network function have a channel conflict. A channel switching module is configured to perform channel switching on the second channel if the first channel and the second channel have a channel conflict. A computer device, wherein, The computer device includes: one or more processors; a memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the channel switching method of any one of claims 1 to 18.
Citation Information
Patent Citations
Wifi chip and control method during coexistence of station (STA) mode and access point (AP) mode
CN104185224A
Channel selection method and intelligent terminal
CN106572510A
Channel switching method and device, computer equipment and computer readable storage medium
CN119212018A
Communication method, terminal device, and storage medium
US20230370920A1