Network connection method, electronic device and storage medium
By selecting different DHCP response messages in the LAN to generate static network configuration information, the network connection failure caused by multiple routers in the LAN is solved, and the connection success rate is improved.
Patent Information
- Application Number
- PCT/CN2025/071608
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-10
- Filing Date
- 2025-01-09
- Publication Date
- 2025-07-17
AI Technical Summary
In the case where multiple routers exist in the same LAN, the electronic device may obtain the wrong IP address and the MAC address, resulting in the network connection failure.
By receiving the DHCP response messages sent by multiple routers, selecting the first DHCP response message for network connection failure, selecting different second DHCP response messages to obtain dynamic network configuration information, and generating static network configuration information for static network connection.
This improves the success rate of network connections and solves the problem of connection failure caused by mismatch of dynamic network configuration information.
Smart Images

Figure CN2025071608_17072025_PF_FP_ABST
Abstract
Description
Network connection method, electronic device and storage medium
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on January 10, 2024, with application number 202410042474.6 and invention name “Network connection method, electronic device and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of terminal technology, and in particular to a network connection method, electronic device, and storage medium. Background Art
[0003] Network connection refers to establishing a communication link between electronic devices and routers in a computer network and ensuring that they can exchange data with each other.
[0004] Typically, when connecting to a network, an electronic device first needs to obtain the router's Media Access Control (MAC) address. After obtaining the MAC address, the electronic device obtains the Internet Protocol (IP) address assigned by the router and sets the IP address. Once the IP address is set, the electronic device can establish a connection with the router.
[0005] However, in the process of network connection, there are usually multiple routers in different network segments in the same local area network. This makes it easy for an electronic device to obtain the MAC address of a router and then set the IP address to the IP address assigned by another router. This way, the IP address and the MAC address do not match, resulting in the inability to perform network transmission after the IP address is set. Summary of the Invention
[0006] Embodiments of the present application provide a network connection method, an electronic device, and a storage medium, which can improve the success rate of network connection.
[0007] In order to achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0008] In a first aspect, a network connection method is provided, which is applied to an electronic device, wherein the electronic device establishes a connection with a router in a target local area network, where there are multiple routers in the target local area network. The method includes: receiving Dynamic Host Configuration Protocol (DHCP) response messages sent by multiple routers in the target local area network; selecting a first DHCP response message from the DHCP response messages sent by the multiple routers to establish a network connection; if the network connection fails through the first DHCP response message, selecting a second DHCP response message different from the first DHCP response message from the DHCP response messages sent by the multiple routers; obtaining dynamic network configuration information in the second DHCP response message; generating static network configuration information based on the dynamic network configuration information; and establishing a static network connection based on the static network configuration information.
[0009] Based on the technical solution provided by the embodiments of the present application, when there are multiple routers in a local area network and the electronic device has established a connection with one router, after broadcasting a DHCP request message, multiple DHCP response messages are obtained. At this time, the electronic device selects one of the multiple DHCP response messages as the first DHCP response message and uses the dynamic network configuration information in the first DHCP response message to connect to the network. In the event that the network connection fails using the dynamic network configuration information in the first DHCP response message, a second DHCP response message different from the first DHCP response message can be selected from the multiple DHCP response messages, the dynamic network configuration information in the second DHCP response message can be obtained, static network configuration information is generated based on the dynamic network configuration information in the second DHCP response message, and the network connection is established based on the static network configuration information. In this way, when there are multiple routers in a local area network, if the network connection fails through DHCP because the selected DHCP response message does not match the router, static network configuration information can be generated based on the dynamic network configuration information of the second DHCP response message received, which is different from the first DHCP response message, and then the network connection is established through a static network connection. Therefore, in order to solve the problem that after using DHCP to connect to the network, even if the network connection fails, the dynamic network configuration information cannot be changed and the only option is to disconnect the router and reconnect, a solution is provided to change the dynamic network connection to a static network connection, thereby improving the success rate of the network connection.
[0010] In a possible implementation of the first aspect, if historical Internet access configuration information of the dynamic network configuration information does not exist in the electronic device, generating static network configuration information based on the dynamic network configuration information includes: obtaining a dynamic Internet Protocol (IP) address and service information in the dynamic network configuration information; determining a static IP address based on the dynamic IP address, determining a primary Domain Name System (DNS) server address in the static network configuration information based on a primary DNS server address in the service information, and determining a backup DNS server address in the static network configuration information based on the backup DNS server address in the service information; and performing a static network connection based on the static network configuration information, including: performing a static network connection through the static IP address, the primary DNS server address in the static network configuration information, and the backup DNS server address in the static network configuration information.
[0011] Based on the above implementation, if the electronic device does not have historical Internet access configuration information for the dynamic network configuration information, the dynamic IP address in the dynamic network configuration information can be obtained, and the static IP address can be determined based on the dynamic IP address. The service information in the dynamic network configuration information is obtained, and the primary DNS server address in the static network configuration information is determined based on the primary DNS server address in the service information. The backup DNS server address in the static network configuration information is determined based on the backup DNS server address in the service information. A static network connection is established using the static IP address, the primary DNS server address in the static network configuration information, and the backup DNS server address in the static network configuration information, so that information can be transmitted with the router using the correct IP address through the static network connection.
[0012] In a possible implementation of the first aspect, if there is historical Internet access configuration information of dynamic network configuration information in the electronic device, generating static network configuration information based on the dynamic network configuration information includes: obtaining a dynamic Internet Protocol IP address in the dynamic network configuration information; determining a static IP address based on the dynamic IP address, determining a primary Domain Name System DNS server address in the static network configuration information based on a primary DNS server address in the historical Internet access configuration information, and determining a backup DNS server address in the static network configuration information based on a backup DNS server address in the historical Internet access configuration information; and making a static network connection based on the static network configuration information, including: making a static network connection through the static IP address, the primary DNS server address in the static network configuration information, and the backup DNS server address in the static network configuration information.
[0013] Based on the above implementation, when historical Internet access configuration information of dynamic network configuration information exists in the electronic device, the dynamic IP address in the dynamic network configuration information can be obtained, and the static IP address can be determined based on the dynamic IP address. The primary DNS server address in the static network configuration information is determined based on the primary DNS server address in the historical Internet access configuration information, and the backup DNS server address in the static network configuration information is determined based on the backup DNS server address in the historical Internet access configuration information. A static network connection is established by using the static IP address, the primary DNS server address in the static network configuration information, and the backup DNS server address in the static network configuration information, so that information can be transmitted with the router using the correct IP address through the static network connection.
[0014] In a possible implementation of the first aspect, when there is no historical Internet access configuration information of the dynamic network configuration information in the electronic device, the network connection method further includes: setting the subnet mask in the static network configuration information according to the default subnet mask; the static network connection through the static network configuration information includes: performing a static network connection through the static IP address, the primary DNS server address in the static network configuration information, the backup DNS server address in the static network configuration information, and the subnet mask in the static network configuration information.
[0015] Based on the above implementation, when there is no historical Internet access configuration information of the dynamic network configuration information in the electronic device, a static network connection can be performed through the default subnet mask.
[0016] In a possible implementation of the first aspect, if there are multiple second DHCP response messages, a static network connection step is performed one by one for the multiple second DHCP response messages until the static network connection is successful or all attempts to connect to the static network through the multiple second DHCP response messages fail. The static network connection step includes: obtaining dynamic network configuration information in the second DHCP response message; generating static network configuration information based on the dynamic network configuration information; and establishing a static network connection using the static network configuration information.
[0017] Based on the above implementation, when there are multiple second DHCP response messages, you can first select the dynamic network configuration information of a second DHCP response message, and use the dynamic network configuration information of this second DHCP response message to generate static network configuration information for static network connection. If the static network connection is unsuccessful, then select another second DHCP response message for static network connection until the static network connection is successful or the static network connection attempts using the dynamic network configuration information of multiple second DHCP response messages fail. In this way, when there are multiple second DHCP response messages, you can try to connect one by one to find a second DHCP response message that can successfully connect to the network using the method provided in this application.
[0018] In a possible implementation of the first aspect, if the plurality of second DHCP response messages include a third DHCP response message, performing a static network connection step based on the third DHCP response message;
[0019] The electronic device includes a network connection history corresponding to the IP address in the third DHCP response message.
[0020] Based on the above implementation, when the third DHCP response message is included in multiple second DHCP response messages, since the electronic device includes the network connection history corresponding to the IP address in the third DHCP response message, the probability that the IP address in the third DHCP response message is the correct IP address is relatively high. Therefore, in this case, the third DHCP response message is preferentially selected, and then the network connection is performed according to the static network connection steps, so that the network connection can be established more quickly.
[0021] In a possible implementation of the first aspect, determining that the third DHCP response message is included in the multiple second DHCP response messages is performed as follows: obtaining an IP address in the second DHCP response message; and if a network connection record corresponding to the IP address exists in the network connection history record, determining that the third DHCP response message is included in the multiple second DHCP response messages.
[0022] Based on the above implementation, it is possible to determine whether the second DHCP response message includes the third DHCP response message according to the network connection history stored in the electronic device, thereby quickly and accurately determining the third DHCP response message.
[0023] In a possible implementation of the first aspect, after establishing a network connection based on static network configuration information, it also includes: determining that the current state is that the Address Resolution Protocol ARP is reachable but network communication is not possible; setting the network connection mode to DHCP mode; and disconnecting the network connection and reconnecting the network.
[0024] Based on the above implementation method, after establishing a network connection based on static network configuration information, if the Address Resolution Protocol ARP is reachable but network communication is not possible, it may be that the static IP address is duplicated with the IP address of another electronic device. In this case, disconnecting the network connection and reconnecting can quickly resolve the network connection problem.
[0025] In a possible implementation of the first aspect, after performing a static network connection based on the static network configuration information, the method further includes: if the network connection fails, setting the network connection mode to DHCP mode; and not setting the network connection mode to static mode within a set time period.
[0026] Based on the above implementation, if the static network connection fails, the network connection mode will not be set to static mode within the set time, reducing the situation where the network connection is affected because the IP address used for the static network connection is an IP address that cannot be used for network connection.
[0027] In a second aspect, the present application provides an electronic device comprising a display screen, a memory, and one or more processors; the display screen, the memory, and the processor are coupled; wherein the memory stores computer program code, and the computer program code comprises computer instructions, which, when executed by the processor, enable the electronic device to execute the network connection method provided in the first aspect and any possible design thereof.
[0028] In a third aspect, the present application provides a computer-readable storage medium comprising computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the network connection method provided in the first aspect and any possible design thereof.
[0029] In a fourth aspect, the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the network connection method provided in the first aspect and any possible design thereof.
[0030] It can be understood that the beneficial effects that can be achieved by the technical solutions provided in the second to fourth aspects mentioned above can be referred to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] FIG1 is a schematic diagram of a network connection environment provided by an embodiment of the present application;
[0032] FIG2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0033] FIG3 is a schematic diagram of a layered architecture of a software system of an electronic device provided in an embodiment of the present application;
[0034] FIG4 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0035] FIG5 is a flow chart of a network connection method provided in an embodiment of the present application;
[0036] FIG6 is a flow chart of a network self-healing method provided in an embodiment of the present application;
[0037] FIG7 is a flowchart of another network self-healing method provided in an embodiment of the present application;
[0038] FIG8 is a flowchart of another network connection method provided in an embodiment of the present application;
[0039] FIG9 is a flowchart of another network connection method provided in an embodiment of the present application;
[0040] FIG10 is a schematic structural diagram of a multi-device collaboration apparatus provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to be limiting of the present application. As used in the specification and appended claims of the present application, the singular expressions "a", "an", "said", "above", "the" and "this" are intended to include plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that " / " means or, for example, A / B can mean A or B; "and / or" in the text is merely a description of an association relationship of associated objects, indicating that three relationships can exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0042] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments.
[0043] The terms "first" and "second" in the following embodiments of this application are used for descriptive purposes only and should not be understood as implying or suggesting relative importance or implicitly indicating the number of the technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.
[0044] To facilitate the technical solution of the application, some concepts involved in this application are first explained below.
[0045] Router: A router is a network device used to connect multiple computers, mobile devices, or other network devices and transfer data between them. It connects and forwards data within the network, allowing different devices to communicate and access the internet.
[0046] A router uses IP addresses to identify and locate different devices and determines the optimal path and destination for data packets based on network rules (such as routing tables). It can send data packets from one network to another and perform functions such as Network Address Translation (NAT) to achieve network connection sharing and security.
[0047] In addition to providing network connectivity and data forwarding, routers can also offer other functions, such as wireless LAN (Wi-Fi) access points, firewalls, and virtual private network (VPN) support. Different types of routers offer different functions and performance characteristics, so you can choose the right router based on your specific needs.
[0048] In summary, a router is a key device that connects multiple devices and forwards data within a network. It allows devices to communicate with each other and connect to the Internet, providing connectivity and functionality to the network.
[0049] IP Address (Internet Protocol Address): An IP address is a numerical address used to identify and locate a computer or other network device. It is fundamental to internet communications, allowing data exchange and communication between different devices.
[0050] An IP address is represented by a 32-bit (IPv4) or 128-bit (IPv6) binary number. To make it easier for people to use and remember, IP addresses are usually presented as four decimal numbers (IPv4) or eight hexadecimal numbers (IPv6), with each group separated by a period (IPv4) or a colon (IPv6). For example, a typical IPv4 address is similar to "192.168.0.1", while a typical IPv6 address is similar to "2001:0db8:85a3:0000:0000:8a2e:0370:7334".
[0051] IP addresses are categorized as public and private. Public IP addresses are globally unique and are used for communication on the internet. Private IP addresses are used within internal networks, such as home networks or corporate intranets, and are not directly visible on the internet.
[0052] IP addresses play a very important role in network communications. They are used to route data packets, address and locate devices, etc. Computers or other network devices can communicate on the Internet by sending data packets to the target IP address.
[0053] A router's MAC address (Media Access Control Address) is a unique hardware address that identifies the network interface card (NIC) on the router. A MAC address is a 48-bit binary number, typically represented as six hexadecimal digits separated by colons. For example, a typical MAC address might look like this: 00:11:22:33:44:55.
[0054] In a network, each device has its own MAC address, which is used to address and identify other devices within the local area network. When a data packet is sent from one device to another, the MAC address of the destination device is usually used to deliver the packet to the correct destination.
[0055] A router is a device that connects multiple computers or other network devices and connects them to the internet. A router typically has at least two network cards: one that connects to the internet and the other that connects to the local area network. Each network card has its own MAC address, which identifies the device it is connected to. Therefore, each network card on a router has its own unique MAC address, which is used to address and identify other devices on the network.
[0056] Subnet mask: A subnet mask is a bit mask that specifies which bits of an IP address identify the subnet to which a host belongs and which bits identify the host itself. A subnet mask cannot exist alone; it must be used in conjunction with an IP address. Its sole function is to divide an IP address into its network address and host address.
[0057] The Domain Name System (DNS), a distributed database on the Internet that maps domain names to IP addresses, allows users to access the internet more conveniently without having to memorize IP numbers that can be read directly by electronic devices. The process of obtaining the IP address corresponding to a host name is called domain name resolution (or host name resolution).
[0058] When a computer is configured with two DNS servers, it means that it can use two different DNS servers to resolve domain names at the same time. DNS is a system that converts domain names into IP addresses, which allows us to access websites through easy-to-remember domain names instead of remembering complex IP addresses.
[0059] Static Network Configuration: In static network configuration, network parameters (such as IP address, subnet mask, default gateway, DNS server, etc.) are configured by the electronic device.
[0060] The IP address of an electronic device is fixed and will not change automatically.
[0061] Dynamic Network Configuration: In dynamic network configuration, network parameters are dynamically assigned through Dynamic Host Configuration Protocol (DHCP).
[0062] When an electronic device connects to a network, it sends a request to the router for network configuration information. The router then assigns the electronic device an available IP address and other necessary network configuration information.
[0063] The technical solutions provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0064] In a traditional network connection, if there are multiple routers in the same local area network (LAN), as shown in Figure 1, an electronic device will first connect to the MAC address of one router. After the MAC address is connected, the electronic device will broadcast a DHCP request. After the DHCP request is received by multiple routers in the LAN, the multiple routers will send DHCP response messages to the electronic device. The electronic device then selects a DHCP response message to configure its network information. However, the DHCP response message selected by the electronic device may not be the DHCP response message sent by the router to which it is connected. This results in the IP address and the MAC address of the connected router not being able to correspond when the electronic device configures its network information based on the DHCP response message. Because the IP address and MAC address must correspond in order for the router to receive the information data sent by the electronic device, this results in the information data sent by the electronic device not being successfully transmitted to the router to which it is connected, and the electronic device will experience network connection failure. To address this problem, the present application provides a network connection method to improve the probability of successful network connection of an electronic device when there are multiple routers in the same local area network.
[0065] The technical solution provided in this application can be applied to electronic devices with image display functions. In some embodiments, the electronic device can be a mobile phone, a tablet computer, a handheld computer, a personal computer (PC), an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, an in-vehicle device, a smart home device, and / or a smart city device, etc. The embodiments of this application do not impose any special restrictions on the specific type of the electronic device.
[0066] FIG2 shows a schematic structural diagram of an electronic device provided in an embodiment of the present application.
[0067] 2 , the electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a display 193, a subscriber identification module (SIM) card interface 194, and a camera 195. The sensor module 180 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
[0068] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0069] The controller can be the nerve center and command center of the electronic device. The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0070] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0071] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.
[0072] The charging management module 140 is used to receive charging input from a power supply device (e.g., a charger, laptop charger, etc.). The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input through the wireless charging coil of the electronic device.
[0073] While charging the battery 142, the charging management module 140 can also power the electronic device through the power management module 141. Specifically, the battery 142 can be composed of multiple batteries connected in series. The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110.
[0074] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 and provides power to the processor 110, the internal memory 121, the display 193, the camera 195, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery voltage, current, battery cycle count, and battery health status (leakage, impedance). In other embodiments, the power management module 141 can also be provided in the processor 110.
[0075] The external memory interface 120 can be used to connect to an external non-volatile memory device to expand the storage capacity of the electronic device. The external non-volatile memory device communicates with the processor 110 via the external memory interface 120 to implement data storage. For example, files such as music and videos can be stored in the external non-volatile memory device.
[0076] The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM). The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data, etc. The non-volatile memory can also store executable programs and store user and application data, etc., and can be loaded into the random access memory in advance for direct reading and writing by the processor 110. In an embodiment of the present application, a diffusion model may be stored in the internal memory 121. The internal memory 121 may also store relevant models that can convert images into noise images and text identifiers, or may also store noise images and text identifiers corresponding to multiple images.
[0077] A touch sensor, also known as a "touch control device," can be provided on the display screen 193. The touch sensor and the display screen 193 form a touch screen, also known as a "touch screen." The touch sensor is used to detect touch operations applied thereto or in the vicinity thereof. The touch sensor can transmit the detected touch operations to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided via the display screen 193. In other embodiments, the touch sensor can also be provided on the surface of the electronic device, at a location different from that of the display screen 193.
[0078] The pressure sensor is used to sense pressure signals and can convert pressure signals into electrical signals. In some embodiments, the pressure sensor can be set on the display screen 193. There are many types of pressure sensors, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. When a touch operation is applied to the display screen 193, the electronic device monitors the touch operation intensity based on the pressure sensor. The electronic device can also calculate the position of the touch based on the monitoring signal of the pressure sensor. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, the instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, the instruction to create a new short message is executed.
[0079] In some embodiments, the electronic device may include 1 or N cameras 195, where N is a positive integer greater than 1. In an embodiment of the present application, the type of camera 195 can be distinguished based on the hardware configuration and physical location. For example, the camera provided on the side of the display screen 193 of the electronic device can be called a front camera, and the camera provided on the side of the back cover of the electronic device can be called a rear camera; for another example, a camera with a short focal length and a larger viewing angle can be called a wide-angle camera, and a camera with a long focal length and a small viewing angle can be called a normal camera. Among them, the length of the focal length and the size of the viewing angle are relative concepts, and there are no specific parameters to limit them. Therefore, wide-angle cameras and normal cameras are also relative concepts, and can be specifically distinguished based on physical parameters such as focal length and viewing angle.
[0080] The electronic device implements display functionality through a GPU, display screen 193, and an application processor. The GPU is a microprocessor for image processing that connects display screen 193 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0081] The electronic device can implement a shooting function through an ISP, a camera 195, a video codec, a GPU, a display screen 193, and an application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information. In the embodiment of the present application, the GPU function is used during the frame drawing process of each image frame to achieve better display effects and performance of the final displayed image.
[0082] The ISP processes data fed back by camera 195. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then passed to the ISP for processing and converted into a visible image. The ISP can also perform algorithmic optimization on image noise and brightness. It can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be incorporated into camera 195. Camera 195 is used to capture still images or video.
[0083] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when an electronic device selects a frequency, the DSP performs a Fourier transform on the frequency energy.
[0084] Display screen 193 is used to display images, videos, and the like. Display screen 193 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, or a quantum dot light-emitting diode (QLED). In some embodiments, the electronic device can include one or N display screens 193, where N is a positive integer greater than one.
[0085] In an embodiment of the present application, the display screen 193 can be used to display the interface of the electronic device (for example, the desktop, the lock screen interface, etc.), and display images stored in the electronic device (for example, wallpapers, photos, etc.), or images captured by any one or more cameras 195 in the interface.
[0086] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem and baseband processor.
[0087] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in an electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
[0088] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to electronic devices. The mobile communication module 150 can receive electromagnetic waves through the antenna 1, filter, amplify, and perform other processing on the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0089] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.) or displays an image or video through the display screen 193. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0090] The wireless communication module 160 can provide wireless communication solutions for electronic devices, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0091] SIM card interface 194 is used to connect a SIM card. A SIM card can be connected to and disconnected from the electronic device by inserting or removing it from the SIM card interface 194. An electronic device may support one or more SIM card interfaces. SIM card interface 194 can support Nano SIM cards, Micro SIM cards, and SIM cards. Multiple cards can be inserted into the same SIM card interface 194 simultaneously. SIM card interface 194 is also compatible with external memory cards. Electronic devices interact with the network through SIM cards to implement functions such as call and data communications. Each SIM card corresponds to one user number.
[0092] It is understood that the interface connection relationship between the modules illustrated in the embodiments of the present invention is only a schematic illustration and does not constitute a structural limitation of the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0093] Of course, it is understood that FIG2 is merely an example of an electronic device in the form of a mobile phone. If the electronic device is a tablet computer, handheld computer, PC, PDA, wearable device (such as a smart watch, smart bracelet), or other device form factors, the structure of the electronic device may include fewer or more structures than shown in FIG1, and this is not limited here.
[0094] It is understandable that, in general, the realization of electronic device functions requires not only hardware support but also software cooperation. The software system of the electronic device can adopt a layered architecture, event-driven architecture, micro-core architecture, micro-service architecture, or cloud architecture. Taking the system as an example, the software structure of the electronic device is illustrated.
[0095] Figure 3 is a schematic diagram of the layered architecture of the software system of the electronic device provided in an embodiment of the present application. The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces (e.g., APIs).
[0096] In some examples, as shown in FIG3 , in an embodiment of the present application, the software of an electronic device is divided into five layers, namely, from top to bottom, the application layer, the framework layer (or application framework layer), the system library and Android runtime (Android runtime), the HAL layer (hardware abstraction layer), and the driver layer (or kernel layer). Among them, the system library and Android runtime can also be called the local framework layer or native layer.
[0097] The application layer may include a series of applications. As shown in FIG3 , the application layer may include applications (APPs) such as camera, gallery, calendar, map, WLAN, Bluetooth, music, video, short message, call, navigation, instant messaging, wallpaper, etc.
[0098] The framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions or services. For example, the application framework layer may include an activity manager, a window manager, a content provider, an audio service, a view system, a telephony manager, a resource manager, a notification manager, a package manager, a data analysis module, a self-healing module, etc., but the embodiments of this application do not impose any restrictions on this.
[0099] The data analysis module is used to determine whether self-healing is currently required through the self-healing module based on the network connection status and the number of received DHCP response messages.
[0100] The self-healing module is used to execute the self-healing process and perform self-healing operations on the network connection when receiving the self-healing trigger instruction from the data analysis module.
[0101] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.
[0102] Content providers are used to store and retrieve data and make it accessible to applications. This data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0103] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.
[0104] The phone manager is used to provide communication functions for electronic devices. For example, the phone manager can manage the call status of the call application (including initiation, connection, and hang up).
[0105] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0106] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.
[0107] Package Manager in The system is used to manage application packages. It allows applications to obtain detailed information about installed applications and their services, permissions, etc. The package manager is also used to manage events such as application installation, uninstallation, and upgrades.
[0108] The system library can include multiple functional modules, such as the surface manager, media libraries, OpenGL ES, and SGL. The surface manager manages the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports a variety of audio and video codecs, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG. OpenGL ES is used for 3D graphics drawing, image rendering, compositing, and layer processing. SGL is a drawing engine for 2D drawing. The Android runtime consists of the core library and the ART virtual machine. The Android runtime is responsible for scheduling and management of the Android system. The core library consists of two parts: one for Java language functions and the other for the Android core library. The application layer and application framework layer run in the ART virtual machine. The ART virtual machine executes Java files from the application layer and application framework layer as binary files. The ART virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0109] The HAL layer is an interface layer located between the operating system kernel and the hardware circuit. Its purpose is to abstract the hardware. It hides the hardware interface details of a specific platform and provides a virtual hardware platform for the operating system, making it hardware-independent and portable across multiple platforms. The HAL layer provides a standard interface to display device hardware capabilities to the higher-level Java API framework (i.e., the framework layer). The HAL layer contains multiple library modules, each of which implements an interface for a specific type of hardware component, such as the audio HAL audio module, the bluetooth HAL Bluetooth module, the camera HAL camera module (also known as the camera HAL or camera hardware abstraction module), and the sensors HAL sensor module (or sensor service).
[0110] The kernel layer is the layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, an audio driver, a sensor driver, a battery driver, a WiFi driver, etc., which are not limited in this application. Among them, the sensor driver can specifically include the driver of each sensor included in the electronic device, such as the ambient light sensor driver. Exemplarily, the ambient light sensor driver can respond to the sensor module's indication or instruction to obtain detection data and promptly send the detection data of the ambient light sensor to the sensing module. The WiFi driver includes a monitoring module and a network connection module.
[0111] The monitoring module is used to monitor DHCP response messages.
[0112] The network connection module is used to perform dynamic network connection or static network connection.
[0113] The technical solutions provided in the embodiments of this application can be implemented in electronic devices having the above-mentioned hardware architecture or software architecture.
[0114] In the embodiments of this application, the WiFi driver and framework layer in the electronic device are primarily used. As shown in Figure 4, the WiFi driver includes a monitoring module and a network connection module. The framework layer includes a data analysis module and a self-healing module. The monitoring module sends data to the network connection module and the data analysis module. The data analysis module sends data to the self-healing module. The self-healing module sends data to the network connection module.
[0115] For the case where there are two routers in the target LAN, the method flow of the embodiment of the present application is shown in FIG5 , and the method flow mainly includes the following steps:
[0116] S501: The monitoring module monitors a DHCP response message.
[0117] DHCP network connection is also called dynamic network connection. During the DHCP network connection process, you need to perform the following operations:
[0118] DHCP Discovery: When an electronic device wants to connect to a network, it sends a DHCP Discovery broadcast message to find available routers within the target LAN.
[0119] DHCP Offer: Multiple available routers in the target LAN, upon receiving the DHCP Discover message, will send a DHCP Offer message to the electronic device. The DHCP Offer message includes the router's MAC address.
[0120] DHCP Request: After receiving the DHCP offer message, the electronic device will select a router to connect to, record the MAC address of the router, and broadcast a DHCP request message.
[0121] DHCP response: After receiving the DHCP request message from the device, the router in the target LAN will send a DHCP response message to the electronic device, which includes the dynamic IP address and service information assigned to the electronic device. The service information includes the primary DNS server address and the backup DNS server address.
[0122] IP address allocation: After receiving a DHCP response message, the electronic device selects one DHCP response message, applies the dynamic IP address and service information in the selected DHCP response message to its own network settings, and begins using these configurations for dynamic network connections.
[0123] In the embodiment of the present application, the monitoring module is used to monitor the DHCP response message.
[0124] S502: The monitoring module sends a DHCP response message to the network connection module.
[0125] S503: The monitoring module sends the DHCP response message to the data analysis module.
[0126] S504: The network connection module performs network connection according to the DHCP response message.
[0127] The network connection module connects to the network according to the DHCP response message. It needs to obtain the dynamic IP address and service information in the DHCP response message, configure the network connection according to the dynamic IP address and service information, and use the dynamic IP address to communicate data with the connected router.
[0128] S505: The network connection module sends the network connection status information to the data analysis module.
[0129] The network connection status information may be network connection success information or network connection failure information.
[0130] The network connection module can determine whether the network connection is successful by whether the data can be successfully sent to the router.
[0131] S506. The data analysis module determines whether there are multiple DHCP response messages and the network connection fails. If there are multiple DHCP response messages and the network connection fails, execute S507; otherwise, the process ends.
[0132] S507: The data analysis module sends a self-healing start instruction to the self-healing module.
[0133] S508: The self-healing module generates static network configuration information.
[0134] The static network configuration information includes the static IP address, subnet mask, primary DNS server address, and backup DNS service address.
[0135] In some implementations, the self-healing module generates static network configuration information, which may be performed according to the process shown in FIG6 .
[0136] S601: A self-healing module obtains a second DHCP response message that is different from a first DHCP response message currently used for network connection.
[0137] S602: The self-healing module obtains dynamic network configuration information in the second DHCP response message.
[0138] The dynamic network configuration information in the second DHCP response message includes a dynamic IP address, a primary DNS server address, and a backup DNS server address. The dynamic IP address is the IP address assigned by the router to the electronic device, and the dynamic IP address corresponds to the MAC address of the router.
[0139] S603: The self-healing module sets the static IP address in the static network configuration information as the dynamic IP address in the dynamic network configuration information.
[0140] For example, if the dynamic IP address in the dynamic network configuration information of the second DHCP response message is 192.168.0.1, the static IP address in the static network configuration information is set to 192.168.0.1.
[0141] S604: The self-healing module determines whether there is historical Internet access configuration information in the second DHCP response message.
[0142] In some embodiments, the self-healing module may determine whether historical Internet access configuration information for the second DHCP response message exists based on the dynamic IP address in the second DHCP response message. If the network connection history of the electronic device includes Internet access configuration information corresponding to the dynamic IP address in the second DHCP response message, it is determined that historical Internet access configuration information for the second DHCP response message exists, and step S608 is executed. If the network connection history of the electronic device does not include Internet access configuration information corresponding to the dynamic IP address in the second DHCP response message, it is determined that historical Internet access configuration information for the second DHCP response message does not exist, and step S605 is executed.
[0143] S605: If the self-healing module determines that there is no historical Internet access configuration information in the second DHCP response message, the subnet mask in the static network configuration information is set to the default subnet mask, and then step S606 is executed.
[0144] For example, if the default subnet mask is 255.255.255.0 ( / 24), set the subnet mask in the static network configuration information to 255.255.255.0 ( / 24).
[0145] S606: The self-healing module sets the primary DNS server address in the static network configuration information as the primary DNS server address in the dynamic network configuration information. Execute step S607.
[0146] For example, if the primary DNS server address in the dynamic network configuration information is 8.8.8.8, the primary DNS server address in the static network configuration information is set to 8.8.8.8.
[0147] S607: The self-healing module sets the backup DNS server address in the static network configuration information as the backup DNS server address in the dynamic network configuration information. Execute step S509.
[0148] For example, if the alternate DNS server address in the dynamic network configuration information is 8.8.4.4, the alternate DNS server address in the static network configuration information is set to 8.8.4.4.
[0149] The execution order of S605 to S607 can be set by those skilled in the art according to actual needs, and this application is not limited thereto.
[0150] S608: If the self-healing module determines that there is historical Internet access configuration information in the second DHCP response message, it sets the subnet mask of the static network configuration information to the subnet mask in the historical Internet access configuration information, and then executes step S609.
[0151] For example, if the subnet mask in the historical network configuration information is 255.255.255.0 ( / 24), the subnet mask in the static network configuration information is set to 255.255.255.0 ( / 24).
[0152] S609: The self-healing module sets the primary DNS server in the static network configuration information as the primary DNS server in the historical network configuration information. Execute step S610.
[0153] For example, if the primary DNS server address in the historical network configuration information is 8.8.8.8, the primary DNS server address in the static network configuration information is set to 8.8.8.8.
[0154] In some implementations, S609 may also be the self-healing module setting the primary DNS server in the static network configuration information as the primary DNS server in the dynamic network configuration information.
[0155] S610: The self-healing module sets the backup DNS server in the static network configuration information as the backup DNS server in the historical network configuration information. Execute step S509.
[0156] For example, if the alternate DNS server address in the historical network configuration information is 8.8.4.4, the alternate DNS server address in the static network configuration information is set to 8.8.4.4.
[0157] In some implementations, S610 may also be the self-healing module setting the backup DNS server address in the static network configuration information as the backup DNS server address in the dynamic network configuration information.
[0158] S509: The self-healing module sends the static network configuration information to the network connection module.
[0159] S510: The network connection module performs a static network connection according to the static network configuration information.
[0160] The process of static network connection includes:
[0161] Send a connection request: The electronic device sends a connection request to the connected router. The connection request usually contains static network configuration information.
[0162] Confirming the connection request: When the connected router receives the connection request, it sends a confirmation signal to the electronic device, indicating that it is ready to establish a connection.
[0163] Establishing a connection: After confirming signal reception, a connection is established between the electronic device and the router. At this point, data can be transferred between them.
[0164] Data transmission: Through the established connection, electronic devices can send data to the router, and the router can also send data to electronic devices.
[0165] S511: The network connection module determines whether the static network connection is successful. If the static network connection is successful, the process ends. If the static network connection fails, S512 is executed.
[0166] The network connection module can determine whether the static network connection is successful by whether the data can be successfully sent to the router.
[0167] S512: The network connection module no longer connects to the network in the static mode within the set time period.
[0168] The set duration can be half an hour to 1.5 hours. In some embodiments, the set duration can be one hour.
[0169] Based on the above implementation, if the static network connection fails, the network connection mode will not be set to static mode within the set time, reducing the situation where the network connection is affected because the IP address used for the static network connection is an IP address that cannot be used for network connection.
[0170] In the case where there are more than two routers in the target LAN, in the case of network connection failure, the network connection module sends the network connection failure information to the self-healing module through step S505. As shown in FIG7 , the self-healing module executes the following steps:
[0171] S701. The self-healing module determines whether there is a second DHCP response message without executing the self-healing process. If there is a second DHCP response message without executing the self-healing process, step S702 is executed. If there is no second DHCP response message without executing the self-healing process, step S512 is executed.
[0172] S702: If a second DHCP response message exists without executing the self-healing process, the self-healing module determines whether a third DHCP response message exists in the second DHCP response message without executing the self-healing process. If the third DHCP response message exists in the second DHCP response message without executing the self-healing process, step S703 is executed. If the third DHCP response message does not exist in the second DHCP response message without executing the self-healing process, step S704 is executed.
[0173] The electronic device includes a network connection history corresponding to the IP address in the third DHCP response message. The self-healing module may determine that the plurality of second DHCP response messages includes the third DHCP response message by obtaining the IP address in the second DHCP response message; and determining that the plurality of second DHCP response messages includes the third DHCP response message if a network connection record corresponding to the IP address in the second DHCP response message exists in the network connection history.
[0174] S703: When there is a third DHCP response message in the second DHCP response message for which the self-healing process is not executed, the self-healing module selects a third DHCP response message to execute the self-healing process.
[0175] S704: If there is no third DHCP response message in the second DHCP response message for which the self-healing process is not executed, the self-healing module selects a second DHCP response message for which the self-healing process is not executed to execute the self-healing process.
[0176] The self-healing process includes steps S602 to S610, and steps S509 and S510.
[0177] After S510 is completed, step S705 is executed.
[0178] S705: The network connection module determines whether the static network connection is successful. If the static network connection is successful, the process ends. If the static network connection fails, step S701 is executed.
[0179] As shown in FIG8 , if the network connection module detects that the current state is ARP reachable but unable to access the Internet, step S801 is executed.
[0180] S801, the network connection module determines whether the current network connection is made through a static IP address. If the network connection is made through a static IP address, the process proceeds to step S802. If the network connection is not made through a static IP address, the process ends.
[0181] S802: If the current network connection is made through a static IP, the network connection module determines whether the network connection is made using the static IP address sent by the self-healing module.
[0182] If the network connection is made using the static IP address sent by the self-healing module, execute step S803.
[0183] If the network connection is not established using the static IP address sent by the self-healing module, the process ends.
[0184] S803: The network connection module disconnects the network connection and does not connect to the network in static mode within a set time period.
[0185] The set duration can be half an hour to 1.5 hours. In some embodiments, the set duration can be one hour.
[0186] As shown in FIG9 , the present application further provides a network connection method, which is applied to an electronic device, wherein the electronic device establishes a connection with a router in a target local area network, where there are multiple routers. The method includes:
[0187] S901: The electronic device receives DHCP response messages sent by multiple routers in a target local area network.
[0188] The receiving of DHCP response messages sent by multiple routers in the target local area network may mean receiving DHCP response messages sent by all routers in the target local area network, or receiving DHCP response messages sent by some routers in the target local area network.
[0189] S901 can be executed with reference to step 501.
[0190] S902: The electronic device selects a first DHCP response message from DHCP response messages sent by multiple routers to connect to the network.
[0191] S902 may be performed with reference to step S504.
[0192] S903: If the network connection fails through the first DHCP response message, the electronic device selects a second DHCP response message different from the first DHCP response message from the DHCP response messages sent by multiple routers.
[0193] S903 may be performed with reference to step S601.
[0194] S904: The electronic device obtains the dynamic network configuration information in the second DHCP response message, and generates static network configuration information according to the dynamic network configuration information.
[0195] S904 may be executed with reference to steps S602 to S610 .
[0196] If the electronic device does not have historical Internet access configuration information for the dynamic network configuration information, generating static network configuration information based on the dynamic network configuration information includes: obtaining the IP address and service information in the dynamic network configuration information; determining the static IP address based on the dynamic IP address, determining the primary DNS server address in the static network configuration information based on the primary DNS server address in the service information, and determining the backup DNS server address in the static network configuration information based on the backup DNS server address in the service information. In some embodiments, if the electronic device does not have historical Internet access configuration information for the dynamic network configuration information, the network connection method further includes: setting the subnet mask in the static network configuration information based on a default subnet mask.
[0197] Based on the above implementation, when there is no historical Internet access configuration information of the dynamic network configuration information in the electronic device, a static network connection can be made through the default subnet mask. When there is no historical Internet access configuration information of the dynamic network configuration information in the electronic device, the dynamic IP address in the dynamic network configuration information can be obtained, and the static IP address can be determined based on the dynamic IP address. The service information in the dynamic network configuration information is obtained, and the primary DNS server address in the static network configuration information is determined based on the primary DNS server address in the service information, and the backup DNS server address in the static network configuration information is determined based on the backup DNS server address in the service information. A static network connection is made through the static IP address, the primary DNS server address in the static network configuration information, and the backup DNS server address in the static network configuration information, so that information can be transmitted with the router using the correct IP address through a static network connection.
[0198] If the electronic device contains historical Internet access configuration information of dynamic network configuration information, generating static network configuration information based on the dynamic network configuration information includes: obtaining a dynamic Internet Protocol (IP) address in the dynamic network configuration information, determining a static IP address based on the dynamic IP address, determining a primary Domain Name System (DNS) server address in the static network configuration information based on a primary DNS server address in the historical Internet access configuration information, determining a backup DNS server address in the static network configuration information based on a backup DNS server address in the historical Internet access configuration information, and determining a subnet mask in the static network configuration information based on a subnet mask in the historical Internet access configuration information.
[0199] Based on the above implementation, when historical Internet access configuration information of dynamic network configuration information exists in the electronic device, the dynamic IP address in the dynamic network configuration information can be obtained, and the static IP address can be determined based on the dynamic IP address. The primary DNS server address in the static network configuration information is determined based on the primary DNS server address in the historical Internet access configuration information, and the backup DNS server address in the static network configuration information is determined based on the backup DNS server address in the historical Internet access configuration information. A static network connection is established by using the static IP address, the primary DNS server address in the static network configuration information, and the backup DNS server address in the static network configuration information, so that information can be transmitted with the router using the correct IP address through the static network connection.
[0200] In some embodiments, if there are multiple second DHCP response messages, the static network connection step is performed for each of the multiple second DHCP response messages until the static network connection is successful or all attempts to establish a static network connection using the multiple second DHCP response messages fail. The static network connection step includes: obtaining dynamic network configuration information from the second DHCP response message; generating static network configuration information based on the dynamic network configuration information; and establishing a static network connection using the static network configuration information. In some embodiments, this step can be performed with reference to steps S701 to S705.
[0201] Based on the above implementation, when there are multiple second DHCP response messages, you can first select the dynamic network configuration information of a second DHCP response message, and use the dynamic network configuration information of this second DHCP response message to generate static network configuration information for static network connection. If the static network connection is unsuccessful, then select another second DHCP response message for static network connection until the static network connection is successful or the static network connection attempts using the dynamic network configuration information of multiple second DHCP response messages fail. In this way, when there are multiple second DHCP response messages, you can try to connect one by one to find a second DHCP response message that can successfully connect to the network using the method provided in this application.
[0202] In a possible implementation, if the plurality of second DHCP response messages include a third DHCP response message, performing the static network connection step based on the third DHCP response message;
[0203] The electronic device includes a network connection history corresponding to the IP address in the third DHCP response message.
[0204] Based on the above implementation, when the third DHCP response message is included in multiple second DHCP response messages, since the electronic device includes the network connection history corresponding to the IP address in the third DHCP response message, the probability that the IP address in the third DHCP response message is the correct IP address is relatively high. Therefore, in this case, the third DHCP response message is preferentially selected, and then the network connection is performed according to the static network connection steps, so that the network connection can be established more quickly.
[0205] In a possible implementation of the first aspect, determining that the third DHCP response message is included in the multiple second DHCP response messages is performed as follows: obtaining an IP address in the second DHCP response message; and if a network connection record corresponding to the IP address exists in the network connection history record, determining that the third DHCP response message is included in the multiple second DHCP response messages.
[0206] Based on the above implementation, it is possible to determine whether the second DHCP response message includes the third DHCP response message according to the network connection history stored in the electronic device, thereby quickly and accurately determining the third DHCP response message.
[0207] S905: The electronic device performs a static network connection based on the static network configuration information.
[0208] S905 may be executed with reference to step S510.
[0209] Performing a static network connection based on the static network configuration information includes: performing a static network connection through a static IP address, a primary DNS server address in the static network configuration information, a backup DNS server address in the static network configuration information, and a subnet mask in the static network configuration information.
[0210] Based on the technical solution provided by the embodiments of the present application, when there are multiple routers in a local area network and an electronic device has established a network connection with one router, after broadcasting a DHCP request message, multiple DHCP response messages are obtained. At this time, the electronic device selects one of the multiple DHCP response messages as the first DHCP response message and uses the dynamic network configuration information in the first DHCP response message to connect to the network. In the event that the network connection fails using the dynamic network configuration information in the first DHCP response message, a second DHCP response message different from the first DHCP response message can be selected from the multiple DHCP response messages, the dynamic network configuration information in the second DHCP response message can be obtained, static network configuration information is generated based on the dynamic network configuration information in the second DHCP response message, and the network connection is established based on the static network configuration information. In this way, when there are multiple routers in a local area network and the network connection fails through DHCP because the selected DHCP response message does not match the router, static network configuration information can be generated based on the dynamic network configuration information of the second DHCP response message received, which is different from the first DHCP response message, and then the network connection is established through a static network connection. Therefore, in order to solve the problem that after using DHCP to connect to the network, even if the network connection fails, the dynamic network configuration information cannot be changed and the only option is to disconnect the router and reconnect, a solution is provided to change the dynamic network connection to a static network connection, thereby improving the success rate of the network connection.
[0211] In some embodiments, after establishing a network connection based on the static network configuration information, the process further includes: determining that the Address Resolution Protocol (ARP) is reachable but network communication is not possible; setting the network connection mode to DHCP; and disconnecting the network connection and reconnecting. In some embodiments, the process may refer to steps S801 to S803.
[0212] Based on the above implementation method, after establishing a network connection based on static network configuration information, if the Address Resolution Protocol ARP is reachable but network communication is not possible, it may be that the static IP address is duplicated with the IP address of another electronic device. In this case, disconnecting the network connection and reconnecting can quickly resolve the network connection problem.
[0213] In some embodiments, after establishing a static network connection based on the static network configuration information, the method further includes: if the network connection fails, setting the network connection mode to DHCP mode; and not setting the network connection mode to static mode within a set time period.
[0214] Based on the above implementation, if the static network connection fails, the network connection mode will not be set to static mode within the set time, reducing the situation where the network connection is affected because the IP address used for the static network connection is an IP address that cannot be used for network connection.
[0215] It is understandable that, in order to realize the above functions, the above electronic device includes hardware structures and / or software modules corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of the various examples described in the embodiments disclosed herein, the embodiments of the present invention can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the embodiments of the present application.
[0216] Figure 10 is a schematic diagram of the structure of a multi-device collaboration device provided in an embodiment of the present application. In one embodiment, the electronic device can implement the corresponding functions through the hardware device shown in Figure 10. As shown in Figure 10, the multi-device collaboration device may include: a display screen 1001, a memory 1002, a processor 1003, and a communication module 1004. The above-mentioned components can be connected via one or more communication buses 1005.
[0217] In one embodiment, the display screen 1001 may include a display panel 10011 and a touch sensor 10012, wherein the display panel 10011 is used to display images, and the touch sensor 10012 can transmit the detected touch operation to the application processor 1003 to determine the type of touch event and provide visual output related to the touch operation through the display panel 10011. The processor 1003 may include one or more processing units, for example: the processor 1003 may include an application processor, a modem processor, a graphics processor, an image signal processor, a controller, a video codec, a digital signal processor, a baseband processor, and / or a neural network processor. The different processing units may be independent devices or integrated into one or more processors. The memory 1002 is coupled to the processor 1003 and is used to store various software programs and / or multiple sets of instructions. The memory 1002 may include volatile memory and / or non-volatile memory.
[0218] When the software program and / or multiple groups of instructions in the memory 1002 are executed by the processor 1003, the method steps in the embodiments of the present application are performed.
[0219] An embodiment of the present application also provides an electronic device, which includes a display screen, a memory and one or more processors; the display screen, the memory and the processor are coupled; wherein the memory stores computer program code, and the computer program code includes computer instructions. When the computer instructions are executed by the processor, the electronic device executes the network connection method provided in the first aspect and any possible design method thereof.
[0220] An embodiment of the present application further provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the network connection method provided in the aforementioned embodiment.
[0221] An embodiment of the present application further provides a computer program product, which includes executable instructions. When the computer program product is run on an electronic device, the electronic device executes the network connection method provided in the aforementioned embodiment.
[0222] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0223] In the several embodiments provided in this application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0224] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0225] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0226] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0227] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A network connection method, characterized in that, The method is applied to an electronic device which establishes a connection with a router within a target local area network (LAN). There are multiple routers within the target LAN. The method includes: Receiving Dynamic Host Configuration Protocol (DHCP) response messages sent by multiple routers within the target LAN; Selecting a first DHCP response message from the DHCP response messages sent by the multiple routers for network connection; If the network connection fails through the first DHCP response message, selecting a second DHCP response message different from the first DHCP response message from the DHCP response messages sent by the multiple routers; Obtaining dynamic network configuration information in the second DHCP response message; Generating static network configuration information based on the dynamic network configuration information; Performing a static network connection based on the static network configuration information.
2. The network connection method according to claim 1, wherein If there is no historical Internet access configuration information of the dynamic network configuration information in the electronic device, the generating of the static network configuration information based on the dynamic network configuration information includes: Obtaining the dynamic Internet Protocol (IP) address and service information in the dynamic network configuration information; Determining a static IP address based on the dynamic IP address, determining the primary Domain Name System (DNS) server address in the static network configuration information based on the primary DNS server address in the service information, and determining the secondary DNS server address in the static network configuration information based on the secondary DNS server address in the service information; The performing of the static network connection based on the static network configuration information includes: Performing a static network connection based on the static IP address, the primary DNS server address in the static network configuration information, and the secondary DNS server address in the static network configuration information.
3. The network connection method according to claim 1, wherein, If there is historical Internet access configuration information of the dynamic network configuration information in the electronic device, the generating of the static network configuration information based on the dynamic network configuration information includes: Obtaining the dynamic Internet Protocol (IP) address in the dynamic network configuration information; Determining a static IP address based on the dynamic IP address, determining the primary DNS server address in the static network configuration information based on the primary DNS server address in the historical Internet access configuration information, and determining the secondary DNS server address in the static network configuration information based on the secondary DNS server address in the historical Internet access configuration information; The performing of the static network connection based on the static network configuration information includes: Performing a static network connection based on the static IP address, the primary DNS server address in the static network configuration information, and the secondary DNS server address in the static network configuration information.
4. The network connection method according to claim 2, wherein It further includes: Setting the subnet mask in the static network configuration information according to the default subnet mask; The performing of the static network connection through the static network configuration information includes: Performing a static network connection through the static IP address, the primary DNS server address in the static network configuration information, the secondary DNS server address in the static network configuration information, and the subnet mask in the static network configuration information.
5. The network connection method according to claim 1, wherein If there are multiple second DHCP response messages, perform the static network connection steps one by one on the multiple second DHCP response messages until the static network connection is successful or the static network connection fails through the multiple second DHCP response messages. The static network connection steps include: Obtain the dynamic network configuration information in the second DHCP response message; Generate static network configuration information according to the dynamic network configuration information; Perform a static network connection through the static network configuration information.
6. The network connection method according to claim 5, characterized in that, If the third DHCP response message is included in the multiple second DHCP response messages, perform the static network connection steps based on the third DHCP response message; Wherein, the electronic device includes the network connection history corresponding to the IP address in the third DHCP response message.
7. The network connection method according to claim 6, wherein Determine that the third DHCP response message is included in the multiple second DHCP response messages in the following manner: Obtain the IP address in the second DHCP response message; If there is a network connection record corresponding to the IP address in the network connection history record, determine that the third DHCP response message is included in the multiple second DHCP response messages.
8. The network connection method according to any one of claims 1 to 7, characterized in that, After performing the network connection based on the static network configuration information, it further includes: Determine that the current state is that the Address Resolution Protocol (ARP) is reachable but network communication cannot be performed; Set the network connection mode to the DHCP mode; Disconnect the network connection and reconnect to the network.
9. The network connection method according to any one of claims 1 to 7, characterized in that After performing the static network connection based on the static network configuration information, the method further includes: If the network connection fails, set the network connection mode to the DHCP mode; Within a set duration, do not set the network connection mode to the static mode.
10. An electronic device, characterized in that, Includes: A display screen, a memory, and one or more processors; the display screen and the memory are coupled to the processor; wherein, computer program code is stored in the memory, and the computer program code includes computer instructions. When the computer instructions are executed by the processor, the electronic device executes the network connection method according to any one of claims 1-9.
11. A computer-readable storage medium, characterized in that, Includes computer instructions. When the computer instructions run on an electronic device, the electronic device executes the network connection method according to any one of claims 1-9.
Citation Information
Patent Citations
Method for transforming host storage network IP from dynamic state to static state
CN106534401A
Wireless fidelity (wi-fi) access method and apparatus, electronic device, and storage medium
CN112740762A
Method and device for connecting intelligent equipment to network, storage medium and intelligent equipment
CN115643121A
Device and Method for Discovery and Announcement of Secondary End-Point Reachability Information
US20190081925A1