WiFi state switching method and system, terminal equipment and storage medium

Through the automated WiFi device mode switching method, the problem of low switching efficiency of WiFi device mode in the prior art is solved, and automatic switching between STA mode and AP mode is realized, which improves switching efficiency and reduces user operations.

CN119584245APending Publication Date: 2025-03-07深圳开鸿数字产业发展有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411447239.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-16
Publication Date
2025-03-07

Smart Images

  • Figure CN119584245A_ABST
    Figure CN119584245A_ABST
Patent Text Reader

Abstract

The invention discloses a WiFi state switching method and system, terminal equipment and a storage medium, and the method comprises the steps: firstly, initializing a starting STA mode; then, acquiring a device broadcast of a second terminal device, and determining whether to perform mode switching based on the device broadcast of the second terminal device; and finally, if the equipment broadcast of the second terminal equipment is the STA equipment mode, switching the STA mode into the AP mode, and performing response connection on the second terminal equipment, and if the device broadcast of the second terminal device is in the AP device mode, sending a connection request to the second terminal device. According to the method, the STA mode is initialized and started by default, then how to perform mode switching is determined according to the received broadcast characteristics, automatic switching is performed in the whole process, manual operation is not needed, and the WiFi switching efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a WiFi state switching method, system, terminal equipment and storage medium. Background Art

[0002] The WiFi chip includes STA (Station) mode and AP (Access Point) mode. When in use, the STA mode and AP mode are mutually exclusive, that is, when the STA mode is started, the AP mode cannot be started, and vice versa, when the AP mode is started, the STA mode cannot be started. As a result, when switching between the hotspot device and the terminal connection device, the user needs to manually select the switch, and automatic switching cannot be achieved, which places high demands on the user.

[0003] Therefore, the prior art needs to be improved. Summary of the invention

[0004] The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a WiFi state switching method, system, terminal device and storage medium are provided to solve the problem of low efficiency of WiFi device mode switching in the prior art.

[0005] The technical solution adopted by the present invention to solve the problem is as follows:

[0006] In a first aspect, an embodiment of the present invention provides a WiFi state switching method, which is applied to a first terminal device, wherein the method includes:

[0007] The device initializes and starts STA mode;

[0008] Acquire a device broadcast of a second terminal device, and determine whether to perform a mode switch based on the device broadcast of the second terminal device;

[0009] If the device broadcast of the second terminal device is in STA device mode, switching the STA mode to AP mode, and responding to the connection of the second terminal device;

[0010] If the device broadcast of the second terminal device is in AP device mode, a connection request is sent to the second terminal device.

[0011] In one implementation, the method further includes:

[0012] In the AP mode, if no transmission data is acquired within a first preset time, the AP mode is switched to the STA mode.

[0013] In one implementation, the method further includes:

[0014] In the AP mode, if the connection is interrupted, it automatically switches to the STA mode.

[0015] In one implementation, the method further includes:

[0016] In the AP mode, if no transmission data is obtained within the second preset time, the energy saving mode is started.

[0017] In one implementation, the method further includes:

[0018] In the energy-saving mode, if no transmission data is obtained within a third preset time, the mode is switched to the STA mode.

[0019] In one implementation, the method further includes:

[0020] Acquire historical connection data, and determine a connection probability based on the historical connection data;

[0021] If the connection probability is lower than a preset value, the receiving frequency is increased or the buffer is increased.

[0022] In a second aspect, an embodiment of the present invention provides a WiFi state switching method, which is applied to a second terminal device, wherein the method includes:

[0023] The sending device broadcasts to the first terminal device, where the device broadcast is used to identify whether the device is in STA device mode or AP device mode.

[0024] In a third aspect, an embodiment of the present invention further provides a WiFi state switching system, wherein the system includes:

[0025] Initialization module, used to initialize the device and start STA mode;

[0026] A device broadcast acquisition module, used to acquire the device broadcast of the second terminal device, and determine whether to perform mode switching based on the device broadcast of the second terminal device;

[0027] A first switching module, configured to switch the STA mode to the AP mode if the device broadcast of the second terminal device is in the STA device mode, and to respond to the connection with the second terminal device;

[0028] The second switching module is used to send a connection request to the second terminal device if the device broadcast of the second terminal device is in AP device mode.

[0029] In one implementation, the system further includes:

[0030] The third switching module is used to switch the AP mode to the STA mode if no transmission data is obtained within a first preset time in the AP mode.

[0031] The fourth switching module is used to automatically switch to the STA mode if the connection is interrupted in the AP mode.

[0032] The fifth switching module is used to start the energy saving mode if no transmission data is obtained within a second preset time in the AP mode.

[0033] The sixth switching module is used to switch to the STA mode in the energy-saving mode if no transmission data is obtained within a third preset time.

[0034] A historical data acquisition module, used to acquire historical connection data and determine a connection probability based on the historical connection data;

[0035] The adjustment module is used to increase the receiving frequency or increase the buffer if the connection probability is lower than a preset value.

[0036] In a fourth aspect, an embodiment of the present invention further provides a terminal device, wherein the terminal device is a commercial display terminal, and the terminal device includes a memory, a processor, and a program of a WiFi state switching method stored in the memory and executable on the processor, and when the processor executes the program of the WiFi state switching method, the steps of the WiFi state switching method of any one of the above-mentioned schemes are implemented.

[0037] In a fifth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein a program of a WiFi state switching method is stored on the computer-readable storage medium, and when the program of the WiFi state switching method is executed by a processor, the steps of the WiFi state switching method described in any one of the above schemes are implemented.

[0038] Beneficial effects of the present invention: Compared with the prior art, the present invention provides a WiFi state switching method, system, terminal device and storage medium. Specifically, the present invention first initializes and starts the STA mode by default; then, obtains the device broadcast of the second terminal device, and determines whether to switch the mode based on the device broadcast of the second terminal device; finally, if the device broadcast of the second terminal device is the STA device mode, the STA mode is switched to the AP mode, and a response connection is made to the second terminal device; if the device broadcast of the second terminal device is the AP device mode, a connection request is sent to the second terminal device. In this application, the STA mode is initialized and started by default, and then how to switch the mode is determined according to the received broadcast characteristics. The whole process is automatically switched without manual operation, which greatly improves the WiFi switching efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 It is a flowchart of a WiFi state switching method provided by an embodiment of the present invention.

[0041] Figure 2 It is a schematic diagram of WiFi status switching provided by an embodiment of the present invention.

[0042] Figure 3 It is a principle block diagram of a WiFi state switching system provided by an embodiment of the present invention.

[0043] Figure 4 It is a block diagram of the internal structure principle of the WiFi state switching device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0044] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

[0045] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0046] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0047] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0048] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0049] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0050] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0051] In the prior art, log data is stored in real time, the storage efficiency is low, and the transfer quality is not ideal. If the log data transmission is unsuccessful, it is easy to cause data loss and data security cannot be guaranteed.

[0052] In order to solve the problems in the prior art, this embodiment provides a WiFi state switching method, through which the automatic switching of the STA mode and the AP mode of the WiFi device can be realized. In the specific implementation, first, the STA mode is initialized and started by default; then, the device broadcast of the second terminal device is obtained, and whether to switch the mode is determined based on the device broadcast of the second terminal device; finally, if the device broadcast of the second terminal device is the STA device mode, the STA mode is switched to the AP mode, and the second terminal device is responded to and connected; if the device broadcast of the second terminal device is the AP device mode, a connection request is sent to the second terminal device. In this application, the STA mode is initialized and started by default, and then how to switch the mode is determined according to the received broadcast characteristics. The whole process is automatically switched without manual operation, which greatly improves the efficiency of WiFi switching.

[0053] For example, the first terminal device sets the STA mode by default when it is pre-started, and then receives the device broadcast sent by other devices in real time. It determines whether it is a STA device or an AP device through the device broadcast of other devices, and then determines whether to switch the mode. If it is parsed that the second terminal device is in STA mode, it is determined that the mode of this device needs to be switched to AP mode, that is, switched to hotspot mode. If it is parsed that the second terminal device is in AP mode, that is, the second terminal device is a hotspot device, then the local device can connect to the hotspot for communication, that is, the mode of this device does not switch. In this application, the STA mode is initialized and started by default, and then how to switch the mode is determined according to the received broadcast characteristics. The whole process is automatically switched without manual operation, which greatly improves the efficiency of WiFi switching.

[0054] Exemplary Methods

[0055] This embodiment provides a WiFi state switching method, which can be applied to a WiFi device. Figure 1 As shown, the method includes:

[0056] Step S100: The device is initialized to start STA mode.

[0057] In this embodiment, the first terminal device has built-in STA mode and AP mode. STA (Station) mode, also known as Infrastructure mode, is a common device working mode in Wi-Fi networks. In STA mode, the device will connect to an access point (AP) in the Wi-Fi network as a terminal receiving data to obtain a network connection. STA mode is the working mode of a terminal station device in a wireless network, which is usually regarded as a client. In STA mode, the device itself does not accept any wireless access, but connects to the AP node for network access. In STA mode, the device can provide a stable network connection by connecting to a stable AP node. When the device is in STA mode, it can quickly and conveniently connect to the WiFi network to achieve fast Internet access. The WiFi network usually has an encryption function. The STA mode can ensure communication security and is one of the basic modes for users to use the Wi-Fi network in daily life. Therefore, when initializing, the device is automatically set to STA mode, which can quickly achieve a safe and convenient network connection. The application scenarios of STA mode include: Home network: In a home environment, devices such as smart phones, laptops, and smart TVs are usually connected to the home Wi-Fi network in STA mode to access Internet and LAN resources. Enterprise network: In an enterprise environment, the devices used by employees (such as laptops and tablets) are also usually connected to the company's Wi-Fi network in STA mode to access internal resources and the Internet. Public places: In public places such as cafes, libraries, and airports, customers and visitors can use the STA mode of their devices to connect to the provided Wi-Fi network to enjoy free or paid Internet access services. AP mode, or "Access Point mode", is a specific working mode of a wireless router or wireless access point, which is mainly responsible for forwarding wireless signals and extending wireless networks. AP mode allows wireless routers or wireless access points to forward wireless signals to other devices so that they can access the network. The functions of AP mode include: Signal forwarding: Extending the coverage of a wireless network through wireless signal forwarding. Wireless bridging: Connecting two or more wireless networks to achieve wireless interconnection and resource sharing. In AP mode, a wireless router or wireless access point is configured as a central node to provide network connections to surrounding devices through wireless signals. Devices can connect to routers or access points in AP mode via Wi-Fi to achieve wireless network access and data transmission. The application scenarios of AP mode include: AP mode is suitable for various scenarios that require wireless network coverage, especially those places that already provide wired network but lack wireless coverage, such as offices, guesthouses, and hotels. Wireless network services can be provided in these places by plugging the network cable into the mini router and setting it to AP mode.The advantages of setting up AP mode are:Flexibility: AP mode can be flexibly deployed anywhere that requires wireless network coverage without complicated wiring:Scalability: By increasing the number of APs, the coverage of the wireless network can be easily expanded. Compared with the traditional wired network expansion method, AP mode has lower costs and higher efficiency. When configuring AP mode, it is usually necessary to connect a wireless router or wireless access point to a router or switch that is connected to the Internet. Then, configure the device to AP mode through the corresponding settings, so that it can forward wireless signals and provide wireless network services. AP mode is a flexible, efficient and cost-effective way to expand wireless networks, suitable for various scenarios that require wireless network coverage. Through reasonable configuration and optimization, users can be provided with stable and reliable wireless network services.

[0058] Step S200: Acquire a device broadcast of a second terminal device, and determine whether to perform a mode switch based on the device broadcast of the second terminal device.

[0059] In this embodiment, if Figure 2 As shown, the device broadcast sent by the second terminal device is obtained, the device broadcast is parsed, the mode of the second terminal device is obtained, and the second terminal device is identified as a STA terminal or an AP hotspot. By identifying the mode of the second terminal device, it is determined whether the device mode needs to be switched.

[0060] Step S300: If the device broadcast of the second terminal device is in STA device mode, the STA mode is switched to AP mode, and a response connection is made to the second terminal device.

[0061] In this embodiment, if the device mode of the second terminal device is analyzed to be STA mode in step S200, it is necessary to switch the mode of the first terminal device from STA to AP mode, that is, automatically switch the mode from terminal mode to hotspot mode to provide a hotspot for the second terminal device. By automatically switching the mode, a hotspot can be quickly provided to other devices for connection and communication, which facilitates user connection. AP mode is a flexible, efficient and cost-effective wireless network expansion method suitable for various scenarios requiring wireless network coverage. Through reasonable configuration and optimization, stable and reliable wireless network services can be provided to users.

[0062] Step S400, if the device broadcast of the second terminal device is AP device mode, a connection request is sent to the second terminal device.

[0063] In this embodiment, if in step S200, it is analyzed that the second terminal device is in AP device mode, it means that the second terminal device can directly provide a hotspot to the first terminal for connection, and the first terminal device can directly send a connection request to the second terminal device for network connection. The AP mode allows a wireless router or wireless access point to forward wireless signals to other devices so that they can access the network. Therefore, the first terminal device can directly send a connection request to the second terminal device for network connection.

[0064] In one implementation, in the AP mode, if no transmission data is obtained within the first preset time, the AP mode is switched to the STA mode. In a specific implementation, after the first terminal device switches to the AP mode, if no transmission data is obtained within the first preset time, it will automatically switch from the AP mode back to the STA mode. For example, if no transmission data is received within twenty minutes, it will automatically switch from the AP mode back to the STA mode. By switching in a timely manner to adapt to different needs, for example, the AP mode is suitable for scenarios where network access needs to be provided for multiple wireless devices, such as homes, offices, public places, etc. As a central node, the AP device can easily manage and control devices accessing the network while providing stable wireless signal coverage. The STA mode is suitable for mobile devices or devices that need to be connected to an existing wireless network. For example, when mobile phones, laptops and other devices are connected to a home or office WiFi network, they work in STA mode. They access the Internet or communicate with other devices through wireless networks.

[0065] In one implementation, in the AP mode, if the connection is interrupted, it automatically switches to the STA mode. In a specific implementation, in the AP mode, if the connection is interrupted, the first terminal device automatically switches back to the STA mode. The automatic switching avoids the tedious manual operation, which greatly reduces the burden on the user device and improves the switching efficiency, bringing great convenience to the user's use.

[0066] In one implementation, in the AP mode, if no transmission data is obtained within the second preset time, the energy-saving mode is started. In specific real time, in the AP mode, when the data transmission is stopped last time, the timing starts, and when no transmission data is received within the second preset time, the energy-saving mode is started. For example, if no transmission data is received within fifteen minutes, it will switch to the energy-saving mode, and the energy-saving mode helps to effectively reduce energy consumption. The second preset time is less than the first preset mode, that is, in the AP mode, if no transmission data is received for a long time, it will switch to the energy-saving mode first, and if no transmission data is received within a period of time, it will switch from the AP mode back to the STA mode. By switching to the energy-saving mode for a transition first, and then switching back to the STA mode, the energy-saving mode can effectively reduce energy consumption. For example, when the first terminal device is a mobile phone, the AP mode will consume more energy, which will cause heating and the like. By switching to the energy-saving mode in a timely manner, energy consumption can be effectively reduced, and if there is still no data transmission in the energy-saving mode, the device will be switched from the AP mode to the STA mode in a timely manner. It is also convenient to receive the AP mode signal sent by other devices, and the first terminal device can connect to the hotspot device. In STA mode, you can connect to a stable AP node to provide a stable network connection. When the device is in STA mode, you can quickly and conveniently connect to the WiFi network to access the Internet quickly. WiFi networks usually have encryption functions, which can ensure communication security in STA mode.

[0067] In one implementation, in the energy-saving mode, if the transmission data is not obtained within the third preset time, it switches to the STA mode. In a specific implementation, if in the energy-saving mode, if the transmission data is not obtained within the third preset time, the first terminal device will switch from the energy-saving mode to the STA mode. Timely switch the device from the energy-saving mode to the STA mode. It is also convenient to receive AP mode signals sent by other devices, and the first terminal device can connect to the hotspot device. In the STA mode, a stable network connection can be provided by connecting to a stable AP node. When the device is in the STA mode, it can quickly and conveniently connect to the WiFi network to achieve fast Internet access. The WiFi network usually has an encryption function, and the communication security can be ensured in the STA mode.

[0068] In one implementation, historical connection data is obtained, and a connection probability is determined based on the historical connection data; if the connection probability is lower than a preset value, the receiving frequency is increased or the cache is increased. In a specific implementation, the historical connection data of the first terminal device is obtained, analyzed, and the connection probability is calculated. If the connection probability is lower than a preset connection probability, the receiving frequency is adjusted, and the receiving frequency is appropriately increased so that it can connect to other devices as much as possible; or the cache amount is increased to increase the connection probability. For example, if the preset connection probability is less than 70%, the receiving frequency is increased so that it can connect to more devices.

[0069] In one implementation, the method further includes: sending a device broadcast to the first terminal device, the device broadcast is used to identify whether the device is in STA device mode or AP device mode. In a specific implementation, the second terminal device sends a device broadcast, broadcasts the device broadcast, and when the first terminal device receives the device broadcast sent by the second terminal device, it can determine the mode of the second terminal device after parsing it, and then determine whether to switch the mode.

[0070] In one implementation, in the energy-saving mode, the following parameters can be set for state switching, such as influencing parameters, user usage data, external environment, signaling judgment, sensor data, power data, external device interference, etc. Specifically, for example, when a request signal from an external device is received, adaptive switching is performed. If the external signal is a request to connect to a hotspot, the device is switched to AP mode in time; sensor data can also be received, and how to perform adaptive switching is determined according to the sensor data; or power data, when it is detected that the power of the first terminal device is lower than a preset value, the first terminal device is automatically switched from AP mode to STA mode, such as switching the mode when the power is lower than 20%; mode switching can also be performed according to the interference of the surrounding devices. If many unstable devices are detected to attempt to access, that is, an unsafe environment is detected, the mode is automatically switched from AP mode to STA mode to ensure the safety of the device and the data security of the communication. By adaptively switching between ST mode and AP mode for different special situations, it greatly facilitates the use of users.

[0071] In one implementation, the method further includes: sending a device broadcast to the first terminal device, wherein the device broadcast is used to identify whether the device is in STA device mode or AP device mode. In a specific implementation, the second terminal device sends a device broadcast, and broadcasts the device broadcast. When the first terminal device receives the device broadcast sent by the second terminal device, it can determine the mode of the second terminal device after parsing it, and then determine whether to switch the mode. In STA mode, the device itself does not accept any wireless access, but connects to the AP node for network access. In STA mode, the device can provide a stable network connection by connecting to a stable AP node. When the device is in STA mode, it can quickly and conveniently connect to the WiFi network to achieve fast Internet access. The WiFi network usually has an encryption function. The STA mode can ensure communication security, which is one of the basic modes for users to use Wi-Fi networks in daily life. The AP mode is a specific working mode of a wireless router or a wireless access point, which is mainly responsible for forwarding wireless signals and expanding wireless networks. AP mode allows wireless routers or wireless access points to forward wireless signals to other devices, enabling them to access the network. The advantages of setting AP mode are: Flexibility: AP mode can be flexibly deployed anywhere where wireless network coverage is required without complicated wiring: Scalability: By increasing the number of APs, the coverage of the wireless network can be easily expanded. Compared with traditional wired network expansion methods, AP mode has lower costs and higher efficiency.

[0072] Exemplary Systems

[0073] Based on the above embodiments, the present invention also provides a WiFi status switching system. Figure 3 As shown, the system in this embodiment includes an initialization module 10, a device broadcast acquisition module 20, a first switching module 30, and a second switching module 40. Specifically, the initialization module 10 is used for initializing the device to start the STA mode; the device broadcast acquisition module 20 is used for acquiring the device broadcast of the second terminal device, and determining whether to switch the mode based on the device broadcast of the second terminal device; the first switching module 30 is used for switching the STA mode to the AP mode if the device broadcast of the second terminal device is the STA device mode, and responding to the connection of the second terminal device; the second switching module 40 is used for sending a connection request to the second terminal device if the device broadcast of the second terminal device is the AP device mode.

[0074] In one implementation, the system further includes:

[0075] The third switching module is used to switch the AP mode to the STA mode if no transmission data is obtained within a first preset time in the AP mode.

[0076] The fourth switching module is used to automatically switch to the STA mode if the connection is interrupted in the AP mode.

[0077] The fifth switching module is used to start the energy saving mode if no transmission data is obtained within a second preset time in the AP mode.

[0078] The sixth switching module is used to switch to the STA mode in the energy-saving mode if no transmission data is obtained within a third preset time.

[0079] A historical data acquisition module, used to acquire historical connection data and determine a connection probability based on the historical connection data;

[0080] The adjustment module is used to increase the receiving frequency or increase the buffer if the connection probability is lower than a preset value.

[0081] The working principles of each module in the WiFi state switching system of this embodiment are the same as the principles of each step in the above method embodiment, and will not be repeated here.

[0082] Based on the above embodiments, the present invention further provides a terminal device, the principle block diagram of the terminal device can be as follows: Figure 4 The terminal device may include one or more processors 100 ( Figure 4 Only one is shown in the figure), a memory 101 and a computer program 102 stored in the memory 101 and executable on one or more processors 100, for example, a program of a WiFi state switching method. When one or more processors 100 execute the computer program 102, the various steps in the method embodiment of the WiFi state switching method can be implemented. Alternatively, when one or more processors 100 execute the computer program 102, the functions of various modules / units in the device embodiment of the WiFi state switching method can be implemented, which is not limited here.

[0083] In one embodiment, the processor 100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0084] In one embodiment, the memory 101 may be an internal storage unit of an electronic device, such as a hard disk or memory of the electronic device. The memory 101 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 101 may also include both an internal storage unit of the electronic device and an external storage device. The memory 101 is used to store computer programs and other programs and data required by the terminal device. The memory 101 may also be used to temporarily store data that has been output or is to be output.

[0085] Those skilled in the art will understand that Figure 4 The principle block diagram shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the terminal device to which the solution of the present invention is applied. The specific terminal device includes Figure 3 More or fewer components may be shown, or certain components may be combined, or may have a different arrangement of components.

[0086] An embodiment of the present invention further provides a computer-readable storage medium, on which a WiFi state switching program is stored. When the WiFi state switching program is executed by a processor, the steps of any one of the WiFi state switching methods provided in the embodiments of the present invention are implemented.

[0087] It should be understood that the serial numbers of the steps in the above embodiments do not imply a sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0088] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0089] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

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

[0091] In the embodiments provided by the present invention, it should be understood that the disclosed apparatus / terminal equipment and method can be implemented in other ways. For example, the apparatus / terminal equipment embodiments described above are only illustrative, for example, the division of the above modules or units is only a logical function division, and in actual implementation, other division methods can be used, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0092] If the above-mentioned integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The above-mentioned computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the above-mentioned computer program includes computer program code, and the above-mentioned computer program code can be in source code form, object code form, executable file or some intermediate form. The above-mentioned computer-readable medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the above-mentioned computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.

[0093] In summary, the present invention discloses a WiFi state switching method, system, terminal device and storage medium, the method comprising: first, initializing and starting the STA mode; then, obtaining the device broadcast of the second terminal device, and determining whether to switch the mode based on the device broadcast of the second terminal device; finally, if the device broadcast of the second terminal device is the STA device mode, then switching the STA mode to the AP mode, and responding to the second terminal device to connect; if the device broadcast of the second terminal device is the AP device mode, then sending a connection request to the second terminal device. In this application, the STA mode is initialized and started by default, and then how to switch the mode is determined according to the received broadcast characteristics, and the whole process is automatically switched without manual operation, which greatly improves the switching efficiency between the STA mode and the AP mode of WiFi.

[0094] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A WiFi state switching method, characterized in that: Applied to a first terminal device, the method includes: The device initializes and starts STA mode; Acquire a device broadcast of a second terminal device, and determine whether to perform a mode switch based on the device broadcast of the second terminal device; If the device broadcast of the second terminal device is in STA device mode, switching the STA mode to AP mode, and responding to the connection of the second terminal device; If the device broadcast of the second terminal device is in AP device mode, a connection request is sent to the second terminal device.

2. The WiFi state switching method according to claim 1, characterized in that: The method further comprises: In the AP mode, if no transmission data is acquired within a first preset time, the AP mode is switched to the STA mode.

3. The WiFi state switching method according to claim 2, characterized in that: The method further comprises: In the AP mode, if the connection is interrupted, it automatically switches to the STA mode.

4. The WiFi state switching method according to claim 3, characterized in that: The method further comprises: In the AP mode, if no transmission data is obtained within the second preset time, the energy saving mode is started.

5. The WiFi state switching method according to claim 4, characterized in that: The method further comprises: In the energy-saving mode, if no transmission data is obtained within a third preset time, the mode is switched to the STA mode.

6. The WiFi state switching method according to claim 1, characterized in that: The method further comprises: Acquire historical connection data, and determine a connection probability based on the historical connection data; If the connection probability is lower than a preset value, the receiving frequency is increased or the buffer is increased.

7. A WiFi state switching method, characterized in that: Applied to a second terminal device, the method includes: The sending device broadcasts to the first terminal device, where the device broadcast is used to identify whether the device is in STA device mode or AP device mode.

8. A WiFi state switching system, characterized in that: The system comprises: Initialization module, used to initialize the device and start STA mode; A device broadcast acquisition module, used to acquire the device broadcast of the second terminal device, and determine whether to perform mode switching based on the device broadcast of the second terminal device; A first switching module, configured to switch the STA mode to the AP mode if the device broadcast of the second terminal device is in the STA device mode, and to respond to the connection with the second terminal device; The second switching module is used to send a connection request to the second terminal device if the device broadcast of the second terminal device is in AP device mode.

9. A terminal device, characterized in that: The terminal device includes a memory, a processor, and a WiFi state switching method program stored in the memory and executable on the processor. When the processor executes the WiFi state switching method program, the steps of the WiFi state switching method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a WiFi state switching method program, and when the WiFi state switching method program is executed by the processor, the steps of the WiFi state switching method according to any one of claims 1 to 6 are implemented.