Network connection method and device, electronic equipment and computer readable storage medium
By responding to connection instructions in the terminal device and determining the target network based on the network name, the problem of not being able to identify and select the optimal network in the prior art is solved, and a network with better communication quality is achieved to improve the stability and user satisfaction of the wireless network.
Patent Information
- Application Number
- CN202510112441.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-05-02
Smart Images

Figure CN119922656A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of communication technology, and specifically to a network connection method, device, electronic device, and computer-readable storage medium. Background Art
[0002] With the rapid development of WiFi network technology, various types of networks are flooding our daily environment. Wireless network connection (WiFi connection) has become a wireless connection technology that is widely used and relied on in life. Many devices and applications support the use of WiFi connection and rely on WiFi connection to further realize their own functions and technologies.
[0003] In the prior art, there are situations where terminal devices are connected to the same router but with different WiFi names, or networks with the same WiFi name but different routers. In this case, the WiFi native logic may not be able to identify the optimal network, or may not be able to select the optimal network.
[0004] Therefore, after receiving the connection instruction, the terminal device cannot select and connect to the optimal network. Summary of the invention
[0005] The embodiments of the present application provide a network connection method, device, electronic device and computer-readable storage medium, which can enable a terminal device to preferentially connect to a 5G network with the same router but a different network name, or a 5G network with the same network name but a different router, with better communication quality, according to the user's network selection.
[0006] In a first aspect, an embodiment of the present application provides a network connection method, which is applied to a terminal device, and the method includes:
[0007] In response to the connection instruction, determining a first network to which the connection instruction instructs the terminal device to connect, and a network name corresponding to the first network;
[0008] Determining a second network from the network scanning results according to the network name;
[0009] A target network is determined from the first network and the second network for connection.
[0010] Optionally, in some embodiments of the present application, determining the second network from the network scanning result according to the network name includes:
[0011] Determining a first address of the first network according to the network name;
[0012] The second network is determined from the network scanning results according to the first address.
[0013] Optionally, in some embodiments of the present application, determining the second network from the network scanning result according to the network name further includes:
[0014] Determining a first encryption method for the first network according to the network name;
[0015] The second network is determined from the network scanning result according to the first encryption method.
[0016] Optionally, in some embodiments of the present application, determining the second network from the network scanning result according to the first address includes:
[0017] Determine a second address according to the first address, wherein the first address and the second address have multiple bytes in common and at least one byte in difference;
[0018] The second network is determined according to the second address.
[0019] Optionally, in some embodiments of the present application, determining the second address according to the first address includes:
[0020] Convert the first address into a first character string, wherein the first character string includes a first byte, a second byte, and a third byte;
[0021] Converting a network address of at least one network in the network scanning result into a second character string, wherein the second character string includes a fourth byte, a fifth byte, and a sixth byte;
[0022] When the second byte is the same as the fifth byte and the third byte is the same as the sixth byte, a first difference between the first byte and the fourth byte is calculated;
[0023] When the second byte is identical to the fifth byte and the first byte is identical to the fourth byte, a second difference between the third byte and the sixth byte is calculated;
[0024] When the first difference is smaller than a preset value, or when the second difference is smaller than the preset value, it is determined that the network address of at least one network in the network scanning result is the second address.
[0025] Optionally, in some embodiments of the present application, determining the second network from the network scanning result according to the first encryption method includes:
[0026] Determine a second encryption method for at least one network in the network scanning result;
[0027] When the second encryption method is the same as the first encryption method, the network using the second encryption method is determined to be the second network.
[0028] Optionally, in some embodiments of the present application, determining a target network from the first network and the second network for connection includes:
[0029] Determine a first signal strength and a first network type of the first network, where the first network type includes at least one of the following: a 2.4G network, or a 5G network;
[0030] Determine a second signal strength and a second network type of the second network, where the second network type includes at least one of the following: a 2.4G network, or a 5G network;
[0031] The target network is determined for connection according to the first signal strength, the first network type, the second signal strength, and the second network type.
[0032] Optionally, in some embodiments of the present application, determining the target network to connect to according to the first signal strength, the first network type, the second signal strength, and the second network type includes:
[0033] Determining a first initial score of the first network according to the first network type;
[0034] Determining a first score of the first network according to the first signal strength and the first initial score;
[0035] determining a second initial score of the second network according to the second network type;
[0036] determining a second score of the second network according to the second signal strength and the second initial score;
[0037] The target network is selected from the first network and the second network for connection according to the first score and the second score.
[0038] In a second aspect, an embodiment of the present application further provides a network connection device, which is applied to a terminal device, and the device includes:
[0039] a processing module, configured to determine, in response to a connection instruction, a first network to which the terminal device is instructed by the connection instruction to connect, and a network name corresponding to the first network;
[0040] The processing module is further used to determine the second network from the network scanning result according to the network name;
[0041] The processing module is further configured to determine a target network from the first network and the second network for connection.
[0042] Optionally, in some embodiments of the present application, the processing module is further used to:
[0043] Determining a first address of the first network according to the network name;
[0044] The second network is determined from the network scanning results according to the first address.
[0045] Optionally, in some embodiments of the present application, the processing module is further used to:
[0046] Determining a first encryption method for the first network according to the network name;
[0047] The second network is determined from the network scanning result according to the first encryption method.
[0048] Optionally, in some embodiments of the present application, the processing module is further used to:
[0049] Determine a second address according to the first address, wherein the first address and the second address have multiple bytes in common and at least one byte in difference;
[0050] The second network is determined according to the second address.
[0051] Optionally, in some embodiments of the present application, the processing module is further used to:
[0052] Convert the first address into a first character string, wherein the first character string includes a first byte, a second byte, and a third byte;
[0053] Converting a network address of at least one network in the network scanning result into a second character string, wherein the second character string includes a fourth byte, a fifth byte, and a sixth byte;
[0054] When the second byte is the same as the fifth byte and the third byte is the same as the sixth byte, a first difference between the first byte and the fourth byte is calculated;
[0055] When the second byte is identical to the fifth byte and the first byte is identical to the fourth byte, a second difference between the third byte and the sixth byte is calculated;
[0056] When the first difference is smaller than a preset value, or when the second difference is smaller than the preset value, it is determined that the network address of at least one network in the network scanning result is the second address.
[0057] Optionally, in some embodiments of the present application, the processing module is further used to:
[0058] Determine a second encryption method for at least one network in the network scanning result;
[0059] When the second encryption method is the same as the first encryption method, the network using the second encryption method is determined to be the second network.
[0060] Optionally, in some embodiments of the present application, the processing module is further used to:
[0061] Determine a first signal strength and a first network type of the first network, where the first network type includes at least one of the following: a 2.4G network, or a 5G network;
[0062] Determine a second signal strength and a second network type of the second network, where the second network type includes at least one of the following: a 2.4G network, or a 5G network;
[0063] The target network is determined for connection according to the first signal strength, the first network type, the second signal strength, and the second network type.
[0064] Optionally, in some embodiments of the present application, the processing module is further used to:
[0065] Determining a first initial score of the first network according to the first network type;
[0066] Determining a first score of the first network according to the first signal strength and the first initial score;
[0067] determining a second initial score of the second network according to the second network type;
[0068] determining a second score of the second network according to the second signal strength and the second initial score;
[0069] The target network is selected from the first network and the second network for connection according to the first score and the second score.
[0070] In a third aspect, an embodiment of the present application further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and which implements the steps in the above-mentioned network connection method when the computer program is executed by the processor.
[0071] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above-mentioned network connection method are implemented.
[0072] In a fifth aspect, the embodiments of the present application further provide a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in various optional implementations described in the embodiments of the present application.
[0073] In summary, the embodiments of the present application determine the first network that the connection instruction instructs the terminal device to connect to, and the network name corresponding to the first network, in response to a connection instruction; determine the second network from the network scanning results according to the network name; and determine the target network from the first network and the second network to connect to a technical solution, so that the terminal device can, according to the user's network selection, give priority to connecting to networks with different network names of the same router with better communication quality, or networks with the same network name but different routers, thereby achieving the technical effect of improving the stability of the wireless network and enhancing the user's satisfaction with the wireless network when using smart terminal devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the technical solutions in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0075] Figure 1 A schematic diagram of a scenario of a network connection method provided in an embodiment of the present application;
[0076] Figure 2 It is a schematic diagram of a scenario in which a terminal device according to an embodiment of the present application executes the network connection method;
[0077] Figure 3 It is a schematic diagram of a second address determination process corresponding to the network connection method provided in an embodiment of the present application;
[0078] Figure 4 It is a schematic diagram of address determination rules corresponding to the network connection method provided in an embodiment of the present application;
[0079] Figure 5 is a schematic diagram of a scoring calculation process corresponding to the network connection method provided in an embodiment of the present application;
[0080] Figure 6 is a schematic diagram of the structure of a network connection device provided in an embodiment of the present application;
[0081] Figure 7 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0082] The following will be combined with the drawings in this application to clearly and completely describe the technical solutions in this application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments in the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0083] In the description of the present invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first" and "second" may explicitly or implicitly include one or more of the above features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0084] In this application, the word "exemplary" is used to mean "serving as an example, illustration, or illustration." Any embodiment described in this application as "exemplary" is not necessarily to be construed as being preferred or advantageous over other embodiments. The following description is given to enable any person skilled in the art to implement and use the invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the invention can be implemented without using these specific details. In other instances, well-known structures and processes are not elaborated in detail to avoid obscuring the description of the invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in this application.
[0085] First, the terms involved in this application are explained:
[0086] Dual-band router: refers to a router that supports wireless network connections on both 2.4GHz and 5GHz bands. This type of router can provide wireless network services on both bands at the same time, allowing users to choose to connect to the band that suits their devices and needs as needed.
[0087] 2.4G / 5G: 2.4G and 5G are commonly used frequency bands in wireless networks, which refer to the wireless signal frequencies of 2.4GHz and 5GHz respectively. These two frequency bands have different characteristics and uses in wireless communications. The maximum transmission speed of the 2.4G frequency band is usually lower than that of 5G, and many wireless devices work on the 2.4G frequency band, which is often interfered by other wireless signals, resulting in channel congestion. In addition, only the 5G frequency band can play its advantages in the new wireless technology, and most 2.4G cannot support all the functions of the new technology.
[0088] The embodiments of the present application provide a network connection method, device, terminal device, and computer-readable storage medium. Specifically, the embodiments of the present application provide a network connection device applicable to the network connection method, the network connection device includes a terminal device and a processor of the terminal device, and the terminal device can be a laptop, a smart phone, a tablet computer, or other device capable of wireless network communication.
[0089] In the prior art, when there is a dual-band router with 2.4G / 5G networks turned on respectively, and the WiFi names of the 2.4G network and the 5G network are different, the native logic (wireless network connection logic) of the terminal device cannot automatically identify the 2.4G network and the 5G network as hotspots of the same router, and cannot assist the user in switching to connect to the optimal network (for example: 5G network).
[0090] For example, when there are multiple networks with the same name on the same router, the native logic will select the optimal network based on multiple factors such as encryption, signal strength, bandwidth, rate, frequency band, etc.
[0091] However, the existing network selection logic considers too many factors, which results in the signal strength, frequency band and other important factors not being given enough weight in the network selection logic, resulting in the terminal device being unable to truly select the best network. Moreover, after completing the network selection, if the selected network cannot be connected, the existing network selection logic does not have any retry or avoidance measures, resulting in the selection of the unconnectable network in subsequent connections, thus affecting the user experience.
[0092] Therefore, the network connection method in the prior art has a technical problem that it is unable to determine the optimal network corresponding to the same router but different network name, or the same network name but different router, according to the network selected by the user.
[0093] The embodiment of the present application provides a network connection method, device, electronic device and computer-readable storage medium. A technical solution is adopted in which, in response to a connection instruction, a first network to which a terminal device is instructed by the connection instruction to connect and a network name corresponding to the first network are determined; a second network is determined from a network scanning result according to the network name; and a target network is determined from the first network and the second network for connection.
[0094] In summary, the network connection method in the embodiment of the present application can enable the terminal device to preferentially connect to the same router with a different network name with better communication quality, or the network with the same network name but a different router, according to the user's network selection, thereby achieving the technical effect of improving the stability of the wireless network and enhancing the user's satisfaction with the wireless network when using the smart terminal device.
[0095] It should be noted that the order of description of the following embodiments is not intended to limit the priority order of the embodiments.
[0096] See also Figure 1 , Figure 1 The schematic diagram of the scenario of the network connection method provided in the embodiment of the present application, the network connection system may include a terminal device 100 and a processor 701, and the terminal device 100 and the processor 701 may be connected to each other in any manner, including but not limited to signal communication through electronic circuits, communication through wireless signals, and the wireless signals may be computer network communications of the TCP / IP Protocol Suite (TCP / IP) and the User Datagram Protocol (UDP), etc. The terminal device 100 may receive control signals from a remote control or a control panel, and the terminal device 100 may also receive instruction information sent by the processor 701, and the terminal device 100 may perform corresponding operations according to the corresponding instruction information.
[0097] In the embodiment of the present application, the terminal device 100 includes but is not limited to a notebook, a smart phone, a tablet computer and other devices that can be connected to a wired network through a wireless access point.
[0098] Those skilled in the art will understand that Figure 1 The application environment shown in the figure is only one application scenario of the present application solution and does not constitute a limitation on the application scenario of the present application solution. Other application environments may also include Figure 1 More or fewer terminal devices as shown in, for example Figure 1 Only one terminal device is shown, and no specific limitation is given here.
[0099] In addition, if Figure 1 As shown, the processor 701 may include any hardware device capable of performing data processing and instruction sending, such as a CPU or a single-chip microcomputer embedded in the terminal device, and the specific details are not limited here.
[0100] It should be noted that Figure 1The scenario diagram of the network connection system shown is merely an example. The network connection system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. A person of ordinary skill in the art will appreciate that with the evolution of the network connection system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is equally applicable to similar technical problems.
[0101] For details, please refer to Figure 2 , Figure 2 : is a schematic diagram of a scenario in which a terminal device according to an embodiment of the present application executes the network connection method, wherein the specific execution process of the terminal device executing the network connection method is as follows:
[0102] S201: In response to a connection instruction, determining a first network to which the connection instruction instructs the terminal device to connect, and a network name corresponding to the first network;
[0103] In an embodiment of the present application, the connection instruction may be an instruction triggered by a user in a selection interface of a terminal device, used to select a network (a first network, the selected network may be one or more) for connection; based on the first network selected by the user, the network name of the first network is determined.
[0104] It should be noted that the connection instruction may also be automatically triggered by the terminal device when conditions permit. For example, within the coverage of a wireless network with connection records, the terminal device may trigger the connection instruction by itself.
[0105] In an optional embodiment, when the user issues a connection instruction, the terminal device responds to the connection instruction and determines the first network corresponding to the connection instruction and the network name corresponding to the first network.
[0106] Optionally, after the first network is determined, the first network may be preferentially connected, and if it is subsequently determined that a second network with better network quality exists, the user may be reminded to connect to the second network.
[0107] S202: Determine a second network from the network scanning result according to the network name;
[0108] In the embodiment of the present application, after the user issues a connection instruction, the second network is determined from the network scanning result according to the network name of the first network indicated by the connection instruction.
[0109] It should be noted that the terminal device can obtain multiple wireless networks in the surrounding environment through periodic scanning.
[0110] Optionally, the network connection method provided in the embodiment of the present application further includes: determining a first address of the first network according to the network name; and determining a second network from the network scanning result according to the first address.
[0111] In an embodiment of the present application, under the preferred strategy of networks with the same router but different names, when a user issues a connection instruction, the terminal device will use the network name of the network to be connected (the first network) to find the MAC address of the first network, that is, the first address, in the scan results of the most recent periodic scan; after obtaining the MAC address, the same router MAC judgment rule is used to filter out other networks with the same router as this network in the scan results.
[0112] Optionally, the network connection method provided in the embodiment of the present application further includes: determining the second address according to the first address; and determining the second network according to the second address.
[0113] In the present application embodiment, Figure 3 As shown in the second address determination flow chart, the terminal device determines a second address that matches the format or content of the first address based on the first address and the network addresses of each network in the scanned network, and further determines the second network based on the second address.
[0114] Specifically, the terminal device can input the MAC addresses of two networks (the first network and the scanned network) into the processor, convert the MAC addresses into bit strings and split them into bytes, and compare the middle four bytes, as well as the first byte and the last byte, to determine whether the difference between the relevant bits (the first byte and the last byte) is less than a preset value.
[0115] It should be noted that there are multiple bytes in common between the first address and the second address, and at least one byte is different.
[0116] Optionally, the network connection method provided by the embodiment of the present application also includes: converting the first address into a first string; converting the network address of at least one network in the network scanning result into a second string; when the second byte and the fifth byte are the same, and the third byte and the sixth byte are the same, calculating the first difference between the first byte and the fourth byte; when the second byte and the fifth byte are the same, and the first byte and the fourth byte are the same, calculating the second difference between the third byte and the sixth byte; when the first difference is less than a preset value, or when the second difference is less than a preset value, determining that the network address of at least one network in the network scanning result is the second address.
[0117] It should be noted that the first character string includes a first byte, a second byte and a third byte, and the second character string includes a fourth byte, a fifth byte and a sixth byte.
[0118] In the present application embodiment, Figure 4As shown in the address judgment rule diagram, the WiFi MAC address usually has 48 bits (6 bytes), such as FF:FF:FF:FF:FF:FF. Generally speaking, the first 3 bytes are called OUI, the organizational unique identifier, which is assigned by IEEE and represents the manufacturer. The last three bytes are assigned by the manufacturer and are used to uniquely identify a specific device produced by that manufacturer. However, due to the large number of router manufacturers nowadays, the naming of MAC addresses no longer fully complies with the above rules. Therefore, the embodiment of the present application re-summarizes the relevant rules of MAC addresses and designs a method for same-router judgment. Most of the same-router MAC address combinations meet the requirements. Figure 4 Among the four rules shown, the difference value no more than 8 is summarized as the rule.
[0119] Specifically, the first rule: if the other bytes are the same, the second bit of the last byte differs by 7. The second rule: if the other bytes are the same, the first bit of the last byte differs by 7. The third rule: if the other bytes are the same, the first bit of the first byte differs by 7. The fourth rule: if the other bytes are the same, the second bit of the first byte differs by 7.
[0120] It should also be noted that in the embodiment of the present application, the preset value can be set to 8 or other values, and can be modified or adjusted according to actual conditions.
[0121] In the embodiments of the present application, Figure 4 Of the six bytes shown, the first byte ( Figure 4 11, 10, 01, 17, 71) is the first byte of the first string and the fourth byte of the second string; the second byte ( Figure 4 22 in), the third byte ( Figure 4 33 in), the fourth byte ( Figure 4 44) and the fifth byte ( Figure 4 55) is the second byte of the first string, and the fifth byte of the second string; the sixth byte ( Figure 4 60, 67, 06, 76, 66) in the first character string are the third byte of the first character string, and the sixth byte of the second character string. That is, in the embodiment of the present application, the first byte is regarded as the first byte and the fourth byte; the second byte, the third byte, the fourth byte and the fifth byte are regarded as the second byte and the fifth byte; the sixth byte is regarded as the third byte and the sixth byte.
[0122] As an optional embodiment, when a user wants to connect to a 2.4G network, the user can use the MAC address of the 2.4G network and find the 5G network of the same router through the relevant rules of the MAC address (address judgment rules) in the most recent scan results.
[0123] Optionally, if a 5G network with the same router is found, it can be determined whether the relevant signal strength is greater than -70db (if the channel strength is greater than this value, it can be considered that the current network is good), and the 5G network SSID with the same route will be saved; if it is less than or equal to -70db, it will not be saved. When the WiFi connection is completed, the setting function (Setting) part can obtain whether there is a 5G network with the same router and a good signal through the system-related interface. If it exists, it will help the user switch to the 5G network with the same router. If it is already connected to the 5G network, when the user manually switches to the 2.4G network, the system will determine whether the 2.4G network to be switched belongs to the same router network as the connected 5G network. If they belong to the same network, before switching, the system will pop up a retention prompt to the user through the setting function.
[0124] Specifically, if the current WiFi is not connected and the network to be connected is a 2.4G network, determine whether there is a 5G network among other networks on the same router and whether the signal strength is greater than -70db. If so, after the current network connection is completed, upload the name / connection password of this network to the settings function, and the settings function will push the user to switch to the 5G network in the form of a pop-up window. If the user chooses to allow, the system will automatically switch to the 5G network on the same router.
[0125] Specifically, if the current WiFi is connected and the network to be connected is a 2.4G network, it will be determined that if the currently connected network is a 5G network and belongs to the same router network as the 2.4G network to be connected, a retention pop-up window will be immediately reported to the user through the setting function, suggesting that the user stay in the current network connection.
[0126] Optionally, the network connection method provided in the embodiment of the present application also includes: determining a first encryption method of the first network according to the network name; and determining the second network from the network scanning result according to the first encryption method.
[0127] Optionally, the network connection method provided in the embodiment of the present application also includes: determining a second encryption method of at least one network in the network scanning results; when the second encryption method is the same as the first encryption method, determining that the network using the second encryption method is the second network.
[0128] In an embodiment of the present application, under the preferred strategy of multiple networks with the same name but on different routers, when a user sends a connection request or WiFi reconnects, the terminal device will find other networks with the same encryption method as the network name by using the network name and encryption method of the network to be connected from the scan results, and save them to the preferred list of networks with the same name.
[0129] As an optional embodiment, when a user sends a connection request or WiFi reconnects, the system will obtain the WiFi name and encryption method to be connected to filter out networks with the same name from the scanning results, and save them in the preferred network list, and score and sort the preferred list through a new scoring mechanism.
[0130] Optionally, traverse the preferred list after scoring, take the network with the highest current score to determine whether it is in the preferred blacklist or the number of failures has exceeded the threshold (the failure threshold is 2). If it is not in the blacklist or the failure threshold has not been reached, send the MAC address and WiFi name of this network to the bottom layer to connect directly; if it is in the blacklist and the threshold is reached, delete this network from the preferred list and continue to select the network with the highest score for judgment. A blacklist of preferred networks is maintained in the system, which contains different failure reasons and connection failure times. The preferred networks will be retried and avoided according to different failure reasons and failure times to better manage the preferred network list.
[0131] S203: Determine a target network from the first network and the second network for connection.
[0132] In the embodiment of the present application, a scoring mechanism can be used to score and sort the networks in the preferred list of networks with the same name, and then the network with the highest score can be selected for priority. It can also be combined with the blacklist judgment. If it is not in the blacklist or the number of failures does not reach the threshold, the name and MAC address of this network will be sent to the bottom layer for connection. If it is in the blacklist and the number of failures has reached the threshold, the network will be deleted from the preferred list and the network with the highest score will be reselected for judgment.
[0133] As an optional embodiment, if the connection fails, the relevant failure reasons and failure times are recorded; if the connection is successful, the network is removed from the preferred blacklist.
[0134] Optionally, the network connection method provided in an embodiment of the present application also includes: determining a first signal strength and a first network type of the first network; determining a second signal strength and a second network type of the second network; and determining a target network for connection based on the first signal strength, the first network type, the second signal strength and the second network type.
[0135] In an embodiment of the present application, networks with the same name can be scored by RSSI and network frequency band, and the noise floor of 2.4G and 5G signal strengths can be adjusted to make it easier to select the 5G frequency band.
[0136] It should be noted that the first network type includes at least one of the following: 2.4G network, or 5G network, and the second network type includes at least one of the following: 2.4G network, or 5G network.
[0137] Optionally, the network connection method provided in an embodiment of the present application also includes: determining a first initial score of the first network based on the first network type; determining a first score of the first network based on the first signal strength and the first initial score; determining a second initial score of the second network based on the second network type; determining a second score of the second network based on the second signal strength and the second initial score; and selecting a target network from the first network and the second network for connection based on the first score and the second score.
[0138] In the present application embodiment, Figure 5 As shown in the scoring calculation process diagram, the terminal device inputs the signal strength and network frequency band (i.e., network type) to the processor, and the processor determines whether it is the 5G frequency band. If it is the 2.4G frequency band, the score of the 2.4G frequency band is calculated based on the initial score and signal strength of the 2.4G frequency band. If it is the 5G frequency band, the score of the 5G frequency band is calculated based on the initial score and signal strength of the 5G frequency band.
[0139] Optionally, the same-name network scoring mechanism includes: scoring the same-name networks by RSSI and network frequency band and adjusting the noise floor of 2.4G and 5G signal strength to make it easier to select the 5G frequency band. The specific method is as follows:
[0140] Adjust the noise floor of 2.4G and 5G signal strength. The original noise floor defined by Android is:
[0141] defaultNoiseFloor2GHz -89
[0142] defaultNoiseFloor5GHz -92
[0143] It can be seen that the default noise floor difference between 2.4G and 5G is only 3db, that is, if the value of the 2.4G network signal strength minus the noise floor is greater than the value of the 5G network signal strength minus the noise floor plus 3db, the 2.4G band will be preferred. Therefore, it is not conducive to selecting the 5G band for connection, and the noise floor of the 5G band is adjusted to (the following data is obtained after multiple tests):
[0144] defaultNoiseFloor2GHz -85
[0145] defaultNoiseFloor5GHz -96
[0146] At this time, the default noise floor difference between 2.4G and 5G is expanded to 11db. The 2.4G frequency band can only be selected when the 2.4G network is strong enough and the 5G network is poor. Otherwise, the 5G frequency band will be prioritized for connection.
[0147] Optionally, the weight score of the strong signal in the 5G frequency band can also be increased, that is, when it is a 5G channel and the signal strength is greater than -70db, the weight score of this network will be increased by 100 points, while the weight score of the 2.4G network will not be increased.
[0148] It should be noted that the calculation formula for network score is: Socre = signal strength - default noise floor + weight score.
[0149] In the embodiment of the present application, a first score of the first network and a second score of the second network are calculated based on different preset noise floor values of different network types and the signal strengths corresponding to the networks, so that a target network is selected for connection based on the scores.
[0150] In order to better implement the network connection method of the present application, the present application also provides a network connection device based on the above network connection method. The meanings of the terms are the same as those in the above network connection method, and the specific implementation details can refer to the description in the method embodiment.
[0151] See also Figure 6 , Figure 6 6 is a schematic diagram of the structure of a network connection device provided in an embodiment of the present application, wherein the network connection device 600 is applied to a terminal device, and specifically can be as follows:
[0152] The processing module 601 is used to determine, in response to the connection instruction, a first network to which the connection instruction instructs the terminal device to connect, and a network name corresponding to the first network;
[0153] The processing module 601 is further configured to determine a second network from the network scanning result according to the network name;
[0154] The processing module 601 is further configured to determine a target network from the first network and the second network for connection.
[0155] Optionally, in some embodiments of the present application, the processing module 601 is further configured to:
[0156] Determine a first address of the first network according to the network name;
[0157] A second network is determined from the network scan results according to the first address.
[0158] Optionally, in some embodiments of the present application, the processing module 601 is further configured to:
[0159] Determine a first encryption method for the first network according to the network name;
[0160] The second network is determined from the network scanning result according to the first encryption method.
[0161] Optionally, in some embodiments of the present application, the processing module 601 is further configured to:
[0162] Determine a second address according to the first address, wherein the first address and the second address have multiple bytes in common and at least one byte in difference;
[0163] A second network is determined based on the second address.
[0164] Optionally, in some embodiments of the present application, the processing module 601 is further configured to:
[0165] Convert the first address into a first character string, where the first character string includes a first byte, a second byte, and a third byte;
[0166] Converting a network address of at least one network in the network scanning result into a second character string, where the second character string includes a fourth byte, a fifth byte, and a sixth byte;
[0167] When the second byte is the same as the fifth byte and the third byte is the same as the sixth byte, a first difference between the first byte and the fourth byte is calculated;
[0168] When the second byte is the same as the fifth byte and the first byte is the same as the fourth byte, a second difference between the third byte and the sixth byte is calculated;
[0169] When the first difference is smaller than the preset value, or when the second difference is smaller than the preset value, it is determined that the network address of at least one network in the network scanning result is the second address.
[0170] Optionally, in some embodiments of the present application, the processing module 601 is further configured to:
[0171] Determine a second encryption method for at least one network in the network scan results;
[0172] When the second encryption method is the same as the first encryption method, the network using the second encryption method is determined to be the second network.
[0173] Optionally, in some embodiments of the present application, the processing module 601 is further configured to:
[0174] Determine a first signal strength and a first network type of a first network, where the first network type includes at least one of the following: a 2.4G network, or a 5G network;
[0175] Determine a second signal strength and a second network type of a second network, where the second network type includes at least one of the following: a 2.4G network, or a 5G network;
[0176] A target network is determined for connection according to the first signal strength, the first network type, the second signal strength, and the second network type.
[0177] Optionally, in some embodiments of the present application, the processing module 601 is further configured to:
[0178] Determining a first initial score of the first network according to the first network type;
[0179] Determining a first score for the first network according to the first signal strength and the first initial score;
[0180] Determining a second initial score of the second network according to the second network type;
[0181] determining a second score for the second network based on the second signal strength and the second initial score;
[0182] A target network is selected from the first network and the second network for connection according to the first score and the second score.
[0183] In the embodiment of the present application, the processing module 601 first responds to the connection instruction, determines the first network to which the connection instruction indicates the terminal device to connect, and the network name corresponding to the first network, then, the processing module 601 determines the second network from the network scanning result according to the network name, and then, the processing module 601 determines the target network from the first network and the second network for connection.
[0184] Among them, the embodiment of the present application determines the first network that the connection instruction instructs the terminal device to connect to, and the network name corresponding to the first network by responding to the connection instruction; determines the second network from the network scanning results according to the network name; and determines the target network from the first network and the second network to connect to the technical scheme, so that the terminal device can, according to the user's network selection, give priority to connecting to the same router with a different network name with better communication quality, or the network with the same network name but a different router, thereby achieving the technical effect of improving the stability of the wireless network and enhancing the user's satisfaction with the wireless network when using the smart terminal device.
[0185] In addition, the present application also provides an electronic device, such as Figure 7 As shown, it shows a schematic diagram of the structure of the electronic device involved in this application, specifically:
[0186] The electronic device may include components such as a processor 701 with one or more processing cores, a memory 702 with one or more computer-readable storage media, a power supply 703, and an input unit 704. Those skilled in the art will appreciate that Figure 7The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0187] The processor 701 is the control center of the electronic device, which uses various interfaces and lines to connect various parts of the entire electronic device, and executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 702, and calling data stored in the memory 702, so as to monitor the electronic device as a whole. Optionally, the processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 701.
[0188] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.
[0189] The electronic device also includes a power supply 703 for supplying power to each component. Preferably, the power supply 703 can be logically connected to the processor 701 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 703 can also include any components such as one or more DC or AC power supplies, recharging systems, power supply device debugging circuits, power converters or inverters, and power status indicators.
[0190] The electronic device may further include an input unit 704, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0191] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 701 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 702 according to the following instructions, and the processor 701 will run the application programs stored in the memory 702, thereby implementing the steps in any one of the network connection methods provided in the embodiments of the present application.
[0192] The embodiment of the present application determines, in response to a connection instruction, the first network to which the connection instruction instructs the terminal device to connect, and the network name corresponding to the first network; determines the second network from the network scan result according to the network name; and determines the target network from the first network and the second network for connection. The technical solution enables the terminal device to preferentially connect to networks with different network names of the same router with better communication quality, or networks with the same network name but different routers, based on the user's network selection, thereby achieving the technical effect of improving the stability of the wireless network and enhancing the user's satisfaction with the wireless network when using the smart terminal device.
[0193] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0194] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0195] To this end, the present application provides a computer-readable storage medium, on which a computer program is stored. The computer program can be loaded by a processor to execute the steps in any network connection method provided in the present application.
[0196] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0197] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0198] Since the instructions stored in the computer-readable storage medium can execute the steps in any network connection method provided in the present application, the beneficial effects that can be achieved by any network connection method provided in the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0199] The network connection method, device, electronic device and computer-readable storage medium provided by the present application are introduced in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A network connection method, characterized in that: Applied to a terminal device, the method comprises: In response to the connection instruction, determining a first network to which the connection instruction instructs the terminal device to connect, and a network name corresponding to the first network; Determining a second network from the network scanning results according to the network name; A target network is determined from the first network and the second network for connection.
2. The method according to claim 1, characterized in that Determining the second network from the network scanning result according to the network name includes: Determining a first address of the first network according to the network name; The second network is determined from the network scanning results according to the first address.
3. The method according to claim 1, characterized in that The determining the second network from the network scanning result according to the network name further includes: Determining a first encryption method for the first network according to the network name; The second network is determined from the network scanning result according to the first encryption method.
4. The method according to claim 2, characterized in that: The determining the second network from the network scanning result according to the first address includes: Determine a second address according to the first address, wherein the first address and the second address have multiple bytes in common and at least one byte in difference; The second network is determined according to the second address.
5. The method according to claim 4, characterized in that Determining a second address according to the first address includes: Convert the first address into a first character string, wherein the first character string includes a first byte, a second byte, and a third byte; Converting a network address of at least one network in the network scanning result into a second character string, wherein the second character string includes a fourth byte, a fifth byte, and a sixth byte; When the second byte is the same as the fifth byte and the third byte is the same as the sixth byte, a first difference between the first byte and the fourth byte is calculated; When the second byte is identical to the fifth byte and the first byte is identical to the fourth byte, a second difference between the third byte and the sixth byte is calculated; When the first difference is smaller than a preset value, or when the second difference is smaller than the preset value, it is determined that the network address of at least one network in the network scanning result is the second address.
6. The method according to claim 3, characterized in that The determining the second network from the network scanning result according to the first encryption method includes: Determine a second encryption method for at least one network in the network scanning result; When the second encryption method is the same as the first encryption method, the network using the second encryption method is determined to be the second network.
7. The method according to claim 1, characterized in that The determining a target network from the first network and the second network for connection includes: Determine a first signal strength and a first network type of the first network, where the first network type includes at least one of the following: a 2.4G network, or a 5G network; Determine a second signal strength and a second network type of the second network, where the second network type includes at least one of the following: a 2.4G network, or a 5G network; The target network is determined for connection according to the first signal strength, the first network type, the second signal strength, and the second network type.
8. A network connection device, characterized in that: Applied to a terminal device, the device comprises: a processing module, configured to determine, in response to a connection instruction, a first network to which the terminal device is instructed by the connection instruction to connect, and a network name corresponding to the first network; The processing module is further used to determine the second network from the network scanning result according to the network name; The processing module is further configured to determine a target network from the first network and the second network for connection.
9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the network connection method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the network connection method according to any one of claims 1 to 7 are implemented.