Disclosure of Invention
The embodiment of the application provides a method and a device for establishing wireless connection, which can solve the problem in the prior art that the time for establishing wireless connection with an AP after restarting an STA is long. The technical scheme is as follows:
In a first aspect, an embodiment of the present application provides a method for establishing a wireless connection, where the method includes:
When the current DTIM interval arrives, the AP identifies whether an actual working channel is a preset first channel;
if yes, transmitting a beacon packet by using the first channel; if not, the AP sends a beacon packet by using the currently used channel and the first channel, wherein the beacon packet carries a channel identifier of an actual working channel;
The AP starts an RX window after completing the sending of the beacon packet, and monitors in the RX window;
After the STA executes the restarting operation, judging whether a quick connection mode is set, if so, sequentially sending connection requests in each channel in a preset channel list;
If a connection response based on the connection request is not received from the AP, the STA monitors in the first channel;
if the STA receives a beacon packet from the AP in a preset time period through the first channel, the STA analyzes a channel identifier carried in the beacon packet to obtain an actual working channel of the AP;
The STA sends a connection request on an actual working channel of the AP;
And when the AP receives a connection request from the STA in the opened RX window, returning a connection response to the STA to realize the establishment of wireless connection between the AP and the STA.
In a second aspect, an embodiment of the present application provides an AP, including:
The identification unit is used for identifying whether the actual working channel is a preset first channel or not when the current DTIM interval arrives;
The sending unit is used for sending the beacon packet by using the first channel if the current channel is used for sending the beacon packet, and sending the beacon packet by using the current channel and the first channel if the current channel is used for sending the beacon packet;
The system comprises a monitoring unit, a receiving unit, a judging unit and a judging unit, wherein the monitoring unit is used for starting an RX window after completing the transmission of a beacon packet and monitoring in the RX window, after the STA executes a restarting operation, judging whether a quick connection mode is set, if so, sequentially transmitting a connection request in each channel in a preset channel list, and if not, monitoring in a first channel by the STA, and if the STA receives the beacon packet from the AP in a preset time period through the first channel, analyzing a channel identifier carried in the beacon packet to obtain an actual working channel of the AP, and transmitting the connection request on the actual working channel of the AP by the STA;
And the receiving unit is used for returning a connection response to the STA when receiving the connection request from the STA in the opened RX window, so as to establish wireless connection between the AP and the STA.
In a third aspect, an embodiment of the present application provides an STA, including:
The determining unit is used for judging whether a quick connection mode is set after the restarting operation is executed, and if so, the determining unit sequentially sends connection requests in all channels in a preset channel list;
a monitoring unit, configured to monitor, if a connection response based on the connection request is not received from the AP, the STA in the first channel;
the analyzing unit is used for receiving the beacon packet from the AP in a preset time period through the first channel and analyzing the channel identifier carried in the beacon packet to obtain an actual working channel of the AP;
And the sending unit is used for sending a connection request on an actual working channel of the AP, wherein the AP returns a connection response to the STA when receiving the connection request from the STA in an opened RX window, so that wireless connection is established between the AP and the STA.
In a fourth aspect, an embodiment of the present application provides a wireless communication system, including:
The AP is used for identifying whether an actual working channel is a preset first channel when a current DTIM interval arrives, if so, utilizing the first channel to send a beacon packet, if not, utilizing the currently used channel and the first channel to send the beacon packet, wherein the beacon packet carries a channel identifier of the actual working channel;
the STA is used for judging whether a quick connection mode is set after restarting operation is executed, if yes, a connection request is sequentially sent in each channel in a preset channel list, if no connection response based on the connection request is received from the AP, the STA monitors in the first channel, if the STA receives a beacon packet from the AP in a preset time period through the first channel, the STA analyzes a channel identifier carried in the beacon packet to obtain an actual working channel of the AP, and the STA sends the connection request on the actual working channel of the AP;
And the AP is further used for returning a connection response to the STA when receiving the connection request from the STA in the opened RX window, so as to establish wireless connection between the AP and the STA.
In a fifth aspect, embodiments of the present application provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the above-described method steps.
The technical scheme provided by the embodiments of the application has the beneficial effects that at least:
The AP can recognize whether the actual working channel is a preset first channel and select a channel for transmitting the beacon packet according to the first channel. This intelligent selection ensures that the beacon packet can be sent on the channel that the STA is most likely to listen to, thereby increasing the probability that the STA receives the beacon packet. Each beacon packet carries the channel identifier of the actual working channel, so that the STA can immediately acquire the current working channel information of the AP after receiving the beacon packet, and no additional channel scanning is needed. After completing the beacon packet transmission, the AP opens an RX window to monitor, in preparation for receiving a connection request from the STA. The mechanism can reduce the waiting time of the AP and improve the response speed of the connection request. After restarting, for the AP in the low power mode, the STA will monitor on the first channel preferentially, which further shortens the time for the STA to find the actual working channel of the AP. Once the STA receives the beacon packet of the AP through the first channel and parses out the actual working channel, it can immediately send a connection request on the channel. After receiving the connection request in the RX window, the AP can quickly return a connection response, so that the quick wireless connection between the STA and the AP is realized.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the following detailed description of the embodiments of the present application will be given with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 is a network architecture diagram of a wireless communication system. The wireless communication system includes at least one STA station (station 11 to station 13) and an AP access point 21.
The website in the embodiment of the application can be a smart phone, a tablet computer, a game device, an AR (Augmented Reality ) device, an automobile, a data storage device, an audio playing device, a video playing device, a notebook, a desktop computing device, a wearable device such as an electronic watch, an electronic glasses, an electronic helmet, an electronic bracelet, an electronic necklace, an electronic garment and the like.
A method for establishing a wireless connection according to an embodiment of the present application will be described in detail with reference to fig. 2.
Referring to fig. 2, a flowchart of a method for establishing a wireless connection is provided in an embodiment of the present application. As shown in fig. 2, the method according to the embodiment of the present application may include the following steps:
S201, when the DTIM interval arrives, the AP identifies whether an actual working channel is a preset first channel.
The DTIM interval is periodically generated, and the length of the DTIM interval can be set according to actual requirements. The AP internally maintains a timer for tracking the remaining time of the DTIM interval. The DTIM interval is a period of time in the wireless network that is used to indicate when multicast and broadcast messages can be sent. When the DTIM interval arrives, the processor of the AP checks whether the channel currently being used is identical to the preset first channel (e.g., the sequence number of the first channel may be 1, 6 or 11, which have better communication performance in the 2.4GHz band).
S202, if yes, the beacon packet is sent by using the first channel, and if not, the beacon packet is sent by using the currently used channel and the first channel.
The AP judges whether the actual working channel is a first channel or not, and the processor of the AP generates one or more beacon packets. If the actual working channel is the first channel, only one beacon packet is sent on the channel, and if the actual working channel is not the first channel, the beacon packet is sent on both the actual working channel and the first channel. The beacon packet contains basic information of the AP (e.g., SSID, supported rates, security settings, etc.) and an identification of the actual operating channel. The wireless network interface of the AP transmits the generated beacon packet to the corresponding channel.
S203, the AP starts an RX window in the actual working channel and monitors in the RX window.
Wherein the processor of the AP sets an RX window on the actual operating channel, the window being a time period during which the wireless network interface of the AP will be in a receiving state ready to receive data packets from the STA. During the RX window, the wireless network interface of the AP continues to listen for data packets on the channel and prepares to process the received data packets.
S204, after the STA executes the restarting operation, judging whether a quick connection mode is set, if so, sequentially sending connection requests in each channel in a preset channel list.
The STA completes its restart process, where the restart reasons may include power failure, recovering network configuration, loading a driver, etc. The STA checks its configuration settings, in particular whether the fast connection mode is enabled. The fast connection mode is an optimized mechanism that allows STAs to reconnect to a known AP faster after a restart. If the fast connection mode is enabled, the STA will follow a specific connection procedure, including sequentially sending connection requests in a preset channel list.
S205, if a connection response based on the connection request is not received from the AP, the STA listens in the first channel.
If the STA is in the fast connection mode, it will attempt to send a connection request on each channel according to a preset channel list order. If a connection request is sent on a certain channel but no connection response is received from the AP, the STA will go on trying to go to the next channel. If the STA fails to connect successfully through any channel in the preset channel list, it goes to the preset first channel to listen. During the listening period, if the STA receives a beacon packet from the AP within a preset period of time, the packet is parsed to acquire an actual working channel of the AP.
And S206, if the beacon packet sent by the AP through the first channel is received within the preset time, the STA analyzes the channel identifier carried in the beacon packet to obtain an actual working channel of the AP.
And the wireless network interface of the STA receives the beacon packet sent by the AP on the first channel within the preset time length. The processor of the STA analyzes the received beacon packet and extracts key information, namely the identification of an actual working channel.
S207, the STA transmits a connection request on the actual working channel of the AP.
And switching the wireless network interface of the STA to a channel currently used by the AP according to the analyzed actual working channel identifier. The STA's processor generates a connection request packet containing the STA's MAC address, SSID requesting connection, and other necessary connection parameters. The wireless network interface of the STA transmits a connection request packet to the channel currently used by the AP.
And S208, when the AP receives a connection request from the STA in the opened RX window, returning a connection response to the STA, and realizing the establishment of wireless connection between the AP and the STA.
Wherein during the RX window, the wireless network interface of the AP receives a connection request packet from the STA. The processor of the AP verifies the validity of the connection request packet including checking if the requested SSID matches the SSID of the AP, verifying if the MAC address of the STA is in the allowed list, etc. If the connection request is valid, the processor of the AP generates a connection response packet containing an acknowledgement of the connection request and possibly connection parameters (e.g., encryption key, IP address, etc.). The wireless network interface of the AP then transmits the connection response packet to the STA. After receiving the connection response data packet, the STA configures a wireless network interface according to the parameters in the connection response data packet, so that wireless connection is established with the AP. At this point, the STA and AP may perform normal data transmission within the RX window.
See, for example, the timing diagram for interactions between STAs and APs shown in fig. 3.
Different colors in the figure represent the current operating frequency point. Assuming that the frequency point list has four frequency points, the AP operates in channel 2. In the AP low-power mode, after the AP end enables the quick connection parameters, a beacon packet is sent to the STA at an actual working channel interval for a period of time, a beacon packet carrying the current channel information of the AP is also sent in channel 1 of the current frequency point list, if the AP is in the channel 1, the beacon is not repeatedly sent, and after the AP sends the beacon packet, a receiving window is opened in the actual working channel. After enabling the quick connection parameters, the STA is restarted to wait for receiving a beacon packet in channel 1 of the current frequency point list, and after receiving the beacon packet carrying the current channel information of the AP, the STA locks the frequency point to the frequency point of the AP to send a connection request. The AP responds after receiving the connection request and establishes connection with the STA successfully.
In some embodiments of the application, further comprising:
And a step a, in a normal mode, when the AP detects that the battery power is smaller than a power threshold, sending a working state switching notification to an associated STA.
The AP is powered by a battery, and internally comprises a battery power monitoring module which acquires the current battery power in real time or periodically by reading data of a battery power sensor or a battery management system. The AP compares the monitored battery power to a preset power threshold. This threshold is typically set based on factors such as the power consumption characteristics of the AP, battery capacity, and desired run time. If the battery level is below the threshold, the processor of the AP generates an operating state switch notification, which may include the MAC address of the AP, a notification of the impending entry into a low power mode, and a percentage of the remaining battery level. The AP broadcasts the operating state switch notification to all STAs through the wireless network interface.
And b, receiving a working state switching notification by the associated STA, updating the working mode of the AP into a low-power consumption mode, and sending a working state switching confirmation by the AP.
The wireless network interface of the STA monitors the broadcast message from the AP and receives the working state switching notification. The processor of the STA analyzes the received working state switching notification, and extracts key information therein, such as the MAC address of the AP and notification about to enter a low power mode. And according to the analyzed information, the STA updates the record of the working mode of the AP in the STA, and marks the AP as a low-power consumption mode. The STA generates an active state switch acknowledgement containing an acknowledgement of the active state switch notification and an understanding that the AP is about to enter a low power mode. Then, the STA transmits an operation state switching acknowledgement to the AP through the wireless network interface.
And c, when the AP receives the working state switching confirmation generated by the associated STA based on the working state switching notification, switching to a low power consumption mode.
The wireless network interface of the AP receives the working state switching confirmation from the STA. The processor of the AP parses the active state handoff acknowledgement, verifies whether it is from a known STA, and confirms whether the message content is consistent with the previously sent active state handoff notification. If the active state switch acknowledgement is valid, the processor of the AP triggers a series of operations to switch to a low power mode, such as turning off unnecessary hardware components, reducing processor clock frequency, reducing transmit power of the wireless network interface, etc.
In some embodiments of the present application, when the STA does not receive the beacon packet from the AP for a preset period of time through the first channel, the STA sequentially transmits a connection request in a preset channel list.
The STA does not receive the beacon of the AP within the preset duration through the first channel, and the STA sequentially sends a connection request according to each channel in the preset channel list. The channel list may contain all channels that the AP may use, or a subset based on historical data, network configuration, or a set of standard channels. In each channel, the STA listens for a connection response from the AP after sending a connection request. The connection request contains necessary information such as identity information of the STA, connection parameters, etc., so that the AP can recognize and respond to the connection request. The AP, upon receiving the STA's connection request, performs a series of authentication and configuration operations and then returns a connection response to the STA. The connection response confirms the access rights of the STA and contains the necessary network configuration information. Once the STA receives this connection response, it is considered that the wireless connection with the AP has been successfully established.
In some embodiments of the present application, the AP remains in the normal mode when it detects that the current battery level is greater than the level threshold.
The AP may periodically or on demand detect its battery level. This is typically accomplished by reading a battery power sensor or querying the state of the battery management system. To determine when to switch from the normal mode to the low power mode, the AP presets a power threshold. This threshold is set in combination based on factors such as the battery capacity of the AP, expected lifetime, network requirements, and user preferences. When the AP detects that the current battery level is greater than the preset level threshold, it will continue to operate in the normal mode. In normal mode, the AP performs complete network functions including sending beacon packets, handling connection requests, forwarding data packets, etc. Conversely, if the AP detects that the battery level is below the battery level threshold, it may switch to a low power mode to extend battery life. In the low power mode, the AP may reduce the frequency of beacon packets sent, limit network functions, or take other power saving measures. Before the AP switches from normal mode to low power mode (or vice versa), it may notify other devices (e.g., STAs) in the network by sending certain network messages or updating its status information. This helps to ensure that devices in the network can timely learn about the current state of the AP and make adjustments accordingly. In addition, the STA allows the user to set power thresholds, monitor the AP's battery power and mode status through specific configuration interfaces or management tools, and adjust these settings as needed to optimize network performance and battery life.
In some embodiments of the present application, when the AP detects that the background noise of the actual working channel is greater than the noise threshold, re-queries the channel with the optimal channel instruction in the preset channel list, and sends a channel switching notification to the STA that establishes the wireless connection, where the channel switching notification carries the channel identifier of the channel with the optimal channel quality and a channel switching time point, and the channel switching notification is used to instruct the STA to switch the actual working channel to the channel indicated by the channel identifier at the channel switching time point.
Wherein the AP will periodically or on demand detect the background noise level of the actual operating channel. This is typically accomplished by measuring signal strength on the channel, analyzing spectrum usage, or using other noise detection techniques. To determine when a channel switch is required, the AP presets a noise threshold. This threshold is set comprehensively based on factors such as network requirements, channel quality criteria, and user preferences. When the AP detects that the background noise of the actual working channel is greater than the preset noise threshold, it will query and select the channel with the optimal channel quality from the preset channel list. Channel quality may be assessed based on a variety of factors, such as signal-to-interference ratio (SIR), signal-to-noise ratio (SNR), throughput, delay, etc. Once the optimal channel is selected, the AP may send a channel switch notification to the STA that has established the wireless connection. This notification contains the channel identification (e.g., channel number) and channel switch time point of the channel with the best channel quality. The channel switch time point refers to a specific time when both the AP and the STA agree to switch to a new channel. Upon receiving the channel switch notification, the STA switches its actual operating channel to the new channel indicated in the notification at the designated channel switch time point. This typically involves reconfiguring the wireless network interface of the STA to match the parameters of the new channel. After the channel switch is completed, the AP and STA need to ensure that they have successfully synchronized to the new channel and verify whether the connection is still valid. This may require sending additional synchronization messages or connection testing.
According to the embodiment of the application, the AP can identify whether the actual working channel is the preset first channel, and select the channel for transmitting the beacon packet according to the first channel. This intelligent selection ensures that the beacon packet can be sent on the channel that the STA is most likely to listen to, thereby increasing the probability that the STA receives the beacon packet. Each beacon packet carries the channel identifier of the actual working channel, so that the STA can immediately acquire the current working channel information of the AP after receiving the beacon packet, and no additional channel scanning is needed. After completing the beacon packet transmission, the AP opens an RX window to monitor, in preparation for receiving a connection request from the STA. The mechanism can reduce the waiting time of the AP and improve the response speed of the connection request. After restarting, for the AP in the low power mode, the STA will monitor on the first channel preferentially, which further shortens the time for the STA to find the actual working channel of the AP. Once the STA receives the beacon packet of the AP through the first channel and parses out the actual working channel, it can immediately send a connection request on the channel. After receiving the connection request in the RX window, the AP can quickly return a connection response, so that the quick wireless connection between the STA and the AP is realized.
The following are examples of the apparatus of the present application that may be used to perform the method embodiments of the present application. For details not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the method of the present application.
Referring to fig. 4, a schematic structural diagram of an access point according to an exemplary embodiment of the present application is shown, and hereinafter referred to as access point 4. The access point 4 comprises an identification unit 401, a transmission unit 402, a listening unit 403, and a receiving unit 404.
An identifying unit 401, configured to identify whether an actual working channel is a preset first channel when a current DTIM interval arrives;
A transmitting unit 402, configured to transmit a beacon packet using the first channel if the current channel is used, and transmit the beacon packet using the currently used channel and the first channel if the current channel is used is not used;
A monitoring unit 403, configured to open an RX window after completing transmission of a beacon packet and monitor in the RX window, where after performing a restart operation, the STA determines whether to set a fast connection mode, if so, sequentially sends connection requests in each channel in a preset channel list, and if not, receives a connection response from the AP based on the connection request, the STA monitors in the first channel, and if the STA receives the beacon packet from the AP in a preset time period through the first channel, the STA analyzes a channel identifier carried in the beacon packet to obtain an actual working channel of the AP;
and the receiving unit 404 is configured to, when receiving a connection request from the STA in the opened RX window, return a connection response to the STA, so as to establish a wireless connection between the AP and the STA.
Referring to fig. 5, a schematic structural diagram of a station according to an exemplary embodiment of the present application is shown, and hereinafter referred to as station 5. Station 5 comprises a determining unit 501, a listening unit 502, a parsing unit 503, and a transmitting unit 504.
A determining unit 501, configured to determine whether to set a fast connection mode after performing a restart operation, if so, sequentially sending connection requests in each channel in a preset channel list;
a listening unit 502, configured to, if a connection response based on the connection request is not received from the AP, listen in the first channel by the STA;
a parsing unit 503, configured to receive a beacon packet from the AP through the first channel within a preset duration, and parse a channel identifier carried in the beacon packet to obtain an actual working channel of the AP;
And a sending unit 504, configured to send a connection request on an actual working channel of the AP, where the AP returns a connection response to the STA when receiving the connection request from the STA in an opened RX window, so as to establish wireless connection between the AP and the STA.
It should be noted that, when the method for establishing wireless connection is performed by the access point 4 and the station 5 provided in the foregoing embodiments, only the division of the foregoing functional modules is used as an example, in practical application, the foregoing functional allocation may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the foregoing functions. In addition, the method embodiments for establishing wireless connection provided in the foregoing embodiments belong to the same concept, which embody the detailed implementation process of the method embodiments, and are not described herein again.
The foregoing embodiment numbers of the present application are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
The embodiment of the present application further provides a computer storage medium, where the computer storage medium may store a plurality of instructions, where the instructions are adapted to be loaded by a processor and execute the steps of the method shown in the embodiment of fig. 2, and the specific execution process may refer to the specific description of the embodiment shown in fig. 2, which is not repeated herein.
The application also provides a computer program product storing at least one instruction that is loaded and executed by the processor to implement the method of establishing a wireless connection as described in the various embodiments above.
Referring to fig. 6, a schematic structural diagram of a communication device is provided in an embodiment of the present application. As shown in fig. 6, the communication device 600, which is an access point or station of fig. 1, may include at least one processor 601, at least one wireless interface 604, a memory 603, and at least one communication bus 602.
Wherein the communication bus 602 is used to enable connected communications between these components.
The wireless interface 604 may optionally include a standard WI-FI interface, among other things, for communicating with external devices.
Wherein the processor 601 may include one or more processing cores. The processor 601 connects various portions of the overall communication device 600 using various interfaces and lines, performs various functions of the communication device 600 and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 603, and invoking data stored in the memory 603. Alternatively, the processor 601 may be implemented in at least one hardware form of digital signal Processing (DIGITAL SIGNAL Processing, DSP), field-Programmable gate array (Field-Programmable GATEARRAY, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 601 may integrate one or a combination of several of a central processing unit (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like, the GPU is used for rendering and drawing contents required to be displayed by the display screen, and the modem is used for processing wireless communication. It will be appreciated that the modem may not be integrated into the processor 601 and may be implemented by a single chip.
The Memory 603 may include a random access Memory (RandomAccess Memory, RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 603 includes a non-transitory computer readable medium (non-transitory computer-readable storage medium). The memory 603 may be used to store instructions, programs, code, a set of codes, or a set of instructions. The memory 603 may include a stored program area that may store instructions for implementing an operating system, instructions for at least one function (e.g., a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, etc., and a stored data area that may store data related to the various method embodiments described above, etc. The memory 603 may also optionally be at least one storage device located remotely from the processor 601. As shown in fig. 6, an operating system, a network communication module, a user interface module, and application programs may be included in the memory 603, which is one type of computer storage medium.
The processor 601 shown in fig. 6 may be configured to invoke an application program stored in the memory 603, and specifically perform the method shown in fig. 2, and the specific process may be shown in fig. 2, which is not described herein.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory, a random access memory, or the like.
The foregoing disclosure is illustrative of the present application and is not to be construed as limiting the scope of the application, which is defined by the appended claims.