Networking establishment method and device, storage medium and electronic equipment
By sending management frame broadcast requests and receiving responses between devices, and determining the networking relationship based on network parameters, it solves the connection failure problem caused by improper router settings or the device is not under the same router in multi-device networking, and achieves normality between devices Communication.
Patent Information
- Application Number
- CN202411202825.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2025-01-10
AI Technical Summary
In a multi-device networking environment, due to improper router settings or the device is not in the same router, the connection between devices fails and normal communication cannot be achieved.
By sending management frame broadcast requests between devices, carrying network parameters, receiving unicast responses, determining whether networking is needed based on parameters, and establishing networking relationships based on priorities, node types, signal strengths, and MAC addresses, ensuring that devices are connected normal communication.
It effectively solves the communication problems caused by failure of connection between devices and realizes normal networking and communication between devices.
Smart Images

Figure CN119300177A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart home technology, and more specifically, to a method and device for establishing a network, a storage medium, and an electronic device. Background Art
[0002] In the related art, when multiple devices are connected to the same router, improper settings of the router may cause network isolation between the multiple devices, thereby affecting the communication between them. For example, if the LAN mode of the router is set to isolation mode, the devices under the router will not be able to communicate with each other. Alternatively, when multiple devices are not connected to the same router, the connection between the devices will fail and communication will not be possible.
[0003] In the related art, there is no effective solution to the problem that devices cannot communicate due to connection failure. Summary of the invention
[0004] The embodiments of the present application provide a method and apparatus for establishing a network, a storage medium, and an electronic device, so as to at least solve the problem in the related art that devices cannot communicate due to connection failure.
[0005] According to an embodiment of the present application, a method for establishing a network is provided, including: when it is determined that a first device and a second device cannot communicate, sending a management frame broadcast request to the second device, wherein the management frame broadcast request carries the first network parameters of the first device; receiving a management frame unicast response sent by the second device based on the management frame broadcast request, wherein the management frame response carries the second network parameters of the second device; determining whether networking is required based on the first network parameters and the second network parameters; and when networking is required, establishing networking of the first device and the second device.
[0006] In an optional embodiment, determining whether networking is required based on the first network parameter and the second network parameter includes: determining whether the first device and the second device are under the same router through the first network parameter and the second network parameter; when the first device and the second device are not under the same router, determining that networking is required; when the first device and the second device are under the same router, detecting whether the network connection between the first device and the second device is normal, and determining that networking is required if it is abnormal.
[0007] In an optional embodiment, establishing a network of the first device and the second device includes: obtaining first parameter information of the first device and second parameter information of the second device, wherein the first parameter information includes at least one of the following: a first priority, a first node type, a first received signal strength indicator RSSI value, and a first media access control MAC address, and the second parameter information includes at least one of the following: a second priority, a second node type, a second received signal strength indicator RSSI value, and a second media access control MAC address; establishing a network of the first device and the second device according to the first parameter information and the second parameter information.
[0008] In an optional embodiment, a network of the first device and the second device is established based on the first parameter information and the second parameter information, including: comparing the first priority and the second priority; when the first priority is higher than the second priority, networking the second device as a child node of the first device; when the first priority is lower than the second priority, networking the first device as a child node of the second device.
[0009] In an optional embodiment, after comparing the first priority and the second priority, the method further includes: when the first priority and the second priority are consistent, obtaining the first node type and the second node type; when it is determined that the first device is a root node and the second device is a child node based on the first node type and the second node type, networking the second device as a child node of the first device; when it is determined that the second device is a root node and the first device is a child node based on the first node type and the second node type, networking the first device as a child node of the second device.
[0010] In an optional embodiment, after obtaining the first node type and the second node type, the method further includes: when the first node type and the second node type are both root nodes, or when the first node type and the second node type are both child nodes, obtaining a first RSSI value and a second RSSI value; when the first RSSI value is greater than the second RSSI value, networking the second device as a child node of the first device; when the first RSSI value is less than the second RSSI value, networking the first device as a child node of the second device.
[0011] In an optional embodiment, after obtaining the first RSSI value and the second RSSI value, the method further includes: when the first RSSI value is equal to the second RSSI value, obtaining the first MAC address and the second MAC address; when the first MAC address is greater than the second MAC address, networking the second device as a child node of the first device; when the first MAC address is less than the second MAC address, networking the first device as a child node of the second device.
[0012] According to another aspect of the present invention, a device for establishing a network is also provided, including: a sending module, used to send a management frame broadcast request to the second device when it is determined that the first device and the second device cannot communicate, wherein the management frame broadcast request carries the first network parameters of the first device; a receiving module, used to receive a management frame unicast response sent by the second device based on the management frame broadcast request, wherein the management frame response carries the second network parameters of the second device; a determination module, used to determine whether networking is required based on the first network parameters and the second network parameters; and an establishment module, used to establish networking between the first device and the second device when networking is required.
[0013] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned networking establishment method when running.
[0014] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the networking establishment method through the computer program.
[0015] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method for establishing the above-mentioned network is implemented.
[0016] In an embodiment of the present application, when the first device and the second device cannot establish communication, the first device sends a management frame broadcast request to the second device, wherein the first network parameter of the first device is included in the management frame broadcast request, and receives a management frame unicast response sent by the second device, wherein the second network parameter of the second device is included in the management frame unicast response, and determines whether it is necessary to re-network according to the first network parameter and the second network parameter. If networking is required, networking is performed using the first network parameter and the second network parameter, and normal communication can be achieved after successful networking. The above technical solution solves the problem in the related art that devices cannot communicate due to connection failure, and realizes normal communication of devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0019] Figure 1 It is a hardware environment diagram of a method for establishing a network according to an embodiment of the present application;
[0020] Figure 2 is a flowchart of a method for establishing a network according to an embodiment of the present application;
[0021] Figure 3 A flowchart of a method for establishing a network according to an optional embodiment of the present application;
[0022] Figure 4 It is a structural block diagram of a network establishment device according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] According to one aspect of an embodiment of the present application, a method for establishing a network is provided. The method for establishing a network is widely used in smart home (Smart Home), smart home, smart home device ecology, smart residential (Intelligence House) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above-mentioned method for establishing a network can be applied to Figure 1 In the hardware environment composed of the first device 102 and the second device 104 shown in FIG. Figure 1 As shown, the first device 102 is connected to the second device 104 via a network, and can be used to provide services (such as application services, etc.) for the first device 102 or a client installed on the first device 102. A database can be set on the first device 102 or independently of the first device 102 to provide data storage services for the first device 102 and the second device 104. Cloud computing and / or edge computing services can be configured on the first device 102 or independently of the first device 102 to provide data computing services for the first device 102 and the second device 104.
[0026] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The first device 102 and the second device 104 may be but are not limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projection equipment, smart TV, smart clothes drying rack, smart curtain, smart audio and video, smart socket, smart audio, smart speaker, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart sweeping robot, smart window cleaning robot, smart mopping robot, smart air purification equipment, smart steamer, smart microwave oven, smart kitchen treasure, smart purifier, smart water dispenser, system platform, etc.
[0027] In this embodiment, a method for establishing a network is provided, which is applied to the first device mentioned above. Figure 2 : is a flow chart of a method for establishing a network according to an embodiment of the present application, the process includes the following steps:
[0028] Step S202: When it is determined that the first device and the second device cannot communicate, send a management frame broadcast request to the second device, wherein the management frame broadcast request carries a first network parameter of the first device;
[0029] Step S204, receiving a management frame unicast response sent by the second device based on the management frame broadcast request, wherein the management frame response carries a second network parameter of the second device;
[0030] Step S206, determining whether networking is required according to the first network parameter and the second network parameter;
[0031] Step S208: When networking is required, establish networking of the first device and the second device.
[0032] In an embodiment of the present application, when it is determined that the first device and the second device cannot communicate, a management frame broadcast request is sent to the second device, wherein the management frame broadcast request includes the first network parameter of the first device; a management frame unicast response from the second device is received, wherein the management frame unicast response includes the second network parameter of the second device; whether networking is required is determined based on the first network parameter and the second network parameter; if networking is required, the networking of the first device and the second device is established. The above technical solution solves the problem in the related art that the devices cannot communicate due to connection failure, and realizes the normal communication of the devices.
[0033] In an optional embodiment, determining whether networking is required based on the first network parameter and the second network parameter includes: determining whether the first device and the second device are under the same router through the first network parameter and the second network parameter; when the first device and the second device are not under the same router, determining that networking is required; when the first device and the second device are under the same router, detecting whether the network connection between the first device and the second device is normal, and determining that networking is required if it is abnormal.
[0034] Determine whether the first device and the second device are under the same router through the IP address and subnet mask in the first network parameter and the second network parameter. When the IP addresses of the first device and the second device are different and / or the subnet masks do not match, the first device and the second device are not under the same router, and the first device and the second device need to be re-networked. When the IP addresses and subnet masks of the first device and the second device are consistent, it can be determined that the first device and the second device are connected to the same router. At this time, the first device executes the command to ping the IP address of the second device. When a "request timed out" or "destination unreachable" message is received, it is determined that the network connection between the first device and the second device is abnormal, and the first device and the second device need to be networked.
[0035] In an optional embodiment, there are multiple implementations of the above step S208. In an optional embodiment: obtain first parameter information of the first device and second parameter information of the second device, wherein the first parameter information includes at least one of the following: first priority, first node type, first received signal strength indicator RSSI value, first media access control MAC address, and the second parameter information includes at least one of the following: second priority, second node type, second received signal strength indicator RSSI value, second media access control MAC address; establish networking of the first device and the second device according to the first parameter information and the second parameter information. That is, in the embodiment of the present invention, the networking process is performed according to the first parameter information and the second parameter information. The selection of the first parameter information and the second parameter information can be flexibly adjusted according to the actual situation. Only one, two, three, or even all of the parameter information can be selected.
[0036] In the following embodiments, priority, node type, RSSI value and MAC address are selected in turn in the first parameter information and the second parameter information to establish a network of the first device and the second device.
[0037] In an optional embodiment, a network of the first device and the second device is established based on the first parameter information and the second parameter information, including: comparing the first priority and the second priority; when the first priority is higher than the second priority, networking the second device as a child node of the first device; when the first priority is lower than the second priority, networking the first device as a child node of the second device.
[0038] In an optional embodiment, after comparing the first priority and the second priority, the method further includes: when the first priority and the second priority are consistent, obtaining the first node type and the second node type; when it is determined that the first device is a root node and the second device is a child node based on the first node type and the second node type, networking the second device as a child node of the first device; when it is determined that the second device is a root node and the first device is a child node based on the first node type and the second node type, networking the first device as a child node of the second device.
[0039] In an optional embodiment, after obtaining the first node type and the second node type, the method further includes: when the first node type and the second node type are both root nodes, or when the first node type and the second node type are both child nodes, obtaining a first RSSI value and a second RSSI value; when the first RSSI value is greater than the second RSSI value, networking the second device as a child node of the first device; when the first RSSI value is less than the second RSSI value, networking the first device as a child node of the second device.
[0040] In an optional embodiment, after obtaining the first RSSI value and the second RSSI value, the method further includes: when the first RSSI value is equal to the second RSSI value, obtaining the first MAC address and the second MAC address; when the first MAC address is greater than the second MAC address, networking the second device as a child node of the first device; when the first MAC address is less than the second MAC address, networking the first device as a child node of the second device.
[0041] For example, when the first device and the second device need to be re-networked, assuming that the priority of the first device is 1 and the priority of the second device is 2, according to the rule, the priority of the first device is lower than that of the second device, therefore, the first device will be networked under the second device.
[0042] When the first priority and the second priority are consistent, the node types of the first device and the second device are compared. Assuming that the node type of the first device is a root node and the node type of the second device is a child node, according to the rules, the second device will be a child node of the first device. Therefore, the second device will be networked under the first device.
[0043] When the first priority and the second priority are consistent, and the first node type and the second node type are also consistent, compare the RSSI values of the first device and the second device. Assume that the first RSSI value is 1 and the second RSSI value is 2. According to the rule, the first RSSI value is smaller than the second RSSI value. Therefore, the first device will be networked under the second device.
[0044] When the first priority and the second priority are consistent, the first node type and the second node type are consistent, and the first RSSI value and the second RSSI value are also consistent, compare the first MAC address and the second MAC address. Assume that the first MAC address is 1 and the second MAC address is 2. According to the rules, the first MAC address is smaller than the second MAC address. Therefore, the first device will be networked under the second device.
[0045] In another optional embodiment, the node type, priority, MAC address and RSSI value corresponding to the first parameter information and the second parameter information are selected in sequence to perform a networking method in another arrangement manner.
[0046] In an optional embodiment, establishing a network of the first device and the second device based on the first parameter information and the second parameter information includes: obtaining the first node type and the second node type; networking the second device as a child node of the first device when it is determined that the first device is a root node and the second device is a child node based on the first node type and the second node type; networking the first device as a child node of the second device when it is determined that the second device is a root node and the first device is a child node based on the first node type and the second node type.
[0047] In an optional embodiment, after obtaining the first node type and the second node type, the method further includes: when the first node type and the second node type are both root nodes, or when the first node type and the second node type are both child nodes, comparing the first priority and the second priority; when the first priority is higher than the second priority, networking the second device as a child node of the first device; when the first priority is lower than the second priority, networking the first device as a child node of the second device.
[0048] In an optional embodiment, after comparing the first priority and the second priority, the method further includes: when the first priority and the second priority are consistent, obtaining the first MAC address and the second MAC address; when the first MAC address is greater than the second MAC address, networking the second device as a child node of the first device; when the first MAC address is less than the second MAC address, networking the first device as a child node of the second device.
[0049] In an optional embodiment, after obtaining the first MAC address and the second MAC address, the method further includes: when the first MAC address and the second MAC address are of the same size, obtaining the first RSSI value and the second RSSI value; when the first RSSI value is greater than the second RSSI value, networking the second device as a child node of the first device; when the first RSSI value is less than the second RSSI value, networking the first device as a child node of the second device.
[0050] It should be noted that the above embodiment is only one possible networking method, and another networking method can be obtained through other combinations of the first parameter information and the second parameter information, and this application does not impose any limitation on this.
[0051] In order to better understand the process of the method for establishing the above-mentioned network, the process of the method for establishing the above-mentioned network is described below in combination with an optional embodiment, but it is not used to limit the technical solution of the embodiment of the present application.
[0052] Figure 3 is a flow chart of a method for establishing a network according to an optional embodiment of the present invention, such as Figure 3 As shown, the specific steps include:
[0053] In an optional embodiment of the present invention, according to the search mechanism, the first device needs to determine that the purpose of sending the management frame is to establish a connection with the second device. According to the set purpose, the first device needs to configure the corresponding management frame broadcast request type as a probe frame, and the management frame broadcast request includes the first network parameter of the first device; send a management frame broadcast request with the broadcast address as the destination, so that all devices can receive the management frame broadcast request of the first device.
[0054] After searching for the management frame broadcast request of the first device, the second device will generate a management frame unicast response, which contains the second network parameters of the second device. In order to ensure that the management frame unicast response is sent directly to the first device, the second device needs to set its own address as the source address and the address of the first device as the destination address in the management frame unicast response; after setting the source address and destination address, the second device sends the management frame unicast response to the first device.
[0055] After receiving the management frame unicast response from the second device, the first device parses the source address and destination address in the management frame unicast response to ensure that the signal received is from the second device, and determines whether networking is required based on the decision mechanism established by the first network parameters and the second network parameters.
[0056] In the decision-making mechanism, when the IP addresses of the first device and the second device are different or the subnet masks do not match, the first device and the second device are not under the same router, and the two devices need to be re-networked. When the IP addresses and subnet masks of the first device and the second device are consistent, the first device and the second device are under the same router. The first device executes the command to ping the IP address of the second device. If it receives a message of "request timeout" or "destination unreachable", it determines that the network connection between the first device and the second device is abnormal, and the first device and the second device need to be re-networked.
[0057] The networking method of the first device and the second device is determined according to the networking mechanism. First, the party with a lower priority is grouped under the party with a higher priority according to the networking preference value priority (equivalent to the priority of the above embodiment); when the networking preference value priority is the same, it is judged according to the device roles of both parties. When one party is a UMESH child node and the other party is a UMESH root node, the child node party needs to be re-networked under the root node party; when both parties are child nodes or both are root nodes, the RSSI values of both parties are compared, and the party with a smaller RSSI is grouped under the party with a larger RSSI; when the RSSI is the same, the MAC addresses of both parties are compared, and the party with a smaller MAC address is grouped under the party with a larger MAC address. After the networking is successful, normal communication can be achieved.
[0058] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, an operating terminal, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0059] Figure 4 is a structural block diagram of a network establishment device according to an embodiment of the present application; Figure 4 As shown, including:
[0060] A sending module 40, configured to send a management frame broadcast request to the second device when it is determined that the first device and the second device cannot communicate, wherein the management frame broadcast request carries the first network parameter of the first device;
[0061] A receiving module 42, configured to receive a management frame unicast response sent by the second device based on the management frame broadcast request, wherein the management frame response carries a second network parameter of the second device;
[0062] A determination module 44, configured to determine whether networking is required according to the first network parameter and the second network parameter;
[0063] The establishing module 46 is used to establish a network between the first device and the second device when networking is required.
[0064] In an embodiment of the present application, when it is determined that the first device and the second device cannot communicate, a management frame broadcast request is sent to the second device, wherein the management frame broadcast request includes the first network parameter of the first device; a management frame unicast response from the second device is received, wherein the management frame unicast response includes the second network parameter of the second device; whether networking is required is determined based on the first network parameter and the second network parameter; if networking is required, the networking of the first device and the second device is established. The above technical solution solves the problem in the related art that the devices cannot communicate due to connection failure, and realizes the normal communication of the devices.
[0065] In an optional embodiment, the determination module 44 is also used to determine whether the first device and the second device are under the same router through the first network parameter and the second network parameter; when the first device and the second device are not under the same router, determine that networking is required; when the first device and the second device are under the same router, detect whether the network connection between the first device and the second device is normal, and if abnormal, determine that networking is required.
[0066] In an optional embodiment, the establishment module 46 is also used to obtain first parameter information of the first device and second parameter information of the second device, wherein the first parameter information includes at least one of the following: a first priority, a first node type, a first received signal strength indicator RSSI value, and a first media access control MAC address, and the second parameter information includes at least one of the following: a second priority, a second node type, a second received signal strength indicator RSSI value, and a second media access control MAC address; and a network of the first device and the second device is established based on the first parameter information and the second parameter information.
[0067] In an optional embodiment, module 46 is established to compare the priorities of the first priority and the second priority; when the first priority is higher than the second priority, the second device is networked as a child node of the first device; when the first priority is lower than the second priority, the first device is networked as a child node of the second device.
[0068] In an optional embodiment, module 46 is established, and is also used to obtain the first node type and the second node type when the first priority and the second priority are consistent; when it is determined that the first device is a root node and the second device is a child node based on the first node type and the second node type, the second device is networked as a child node of the first device; when it is determined that the second device is a root node and the first device is a child node based on the first node type and the second node type, the first device is networked as a child node of the second device.
[0069] In an optional embodiment, module 46 is established, and is also used to obtain the first RSSI value and the second RSSI value when both the first node type and the second node type are root nodes, or when both the first node type and the second node type are child nodes; when the first RSSI value is greater than the second RSSI value, the second device is networked as a child node of the first device; when the first RSSI value is less than the second RSSI value, the first device is networked as a child node of the second device.
[0070] In an optional embodiment, module 46 is established, and is also used to obtain the first MAC address and the second MAC address when the first RSSI value is equal to the second RSSI value; when the first MAC address is greater than the second MAC address, network the second device as a child node of the first device; when the first MAC address is less than the second MAC address, network the first device as a child node of the second device.
[0071] An embodiment of the present application further provides a storage medium, which includes a stored program, wherein the program executes any of the above methods when it is run.
[0072] Optionally, in this embodiment, the storage medium may be configured to store program codes for executing the following steps:
[0073] S1, when it is determined that the first device and the second device cannot communicate, sending a management frame broadcast request to the second device, wherein the management frame broadcast request carries a first network parameter of the first device;
[0074] S2, receiving a management frame unicast response sent by the second device based on the management frame broadcast request, wherein the management frame response carries a second network parameter of the second device;
[0075] S3, determining whether networking is required according to the first network parameter and the second network parameter;
[0076] S4: When networking is required, establish networking of the first device and the second device.
[0077] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0078] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0079] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0080] S1, when it is determined that the first device and the second device cannot communicate, sending a management frame broadcast request to the second device, wherein the management frame broadcast request carries a first network parameter of the first device;
[0081] S2, receiving a management frame unicast response sent by the second device based on the management frame broadcast request, wherein the management frame response carries a second network parameter of the second device;
[0082] S3, determining whether networking is required according to the first network parameter and the second network parameter;
[0083] S4: When networking is required, establish networking of the first device and the second device.
[0084] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
[0085] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0086] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0087] The embodiments of the present application also provide a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in any one of the above method embodiments.
[0088] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0089] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0090] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for establishing a network, characterized in that: include: In a case where it is determined that the first device and the second device cannot communicate, sending a management frame broadcast request to the second device, wherein the management frame broadcast request carries the first network parameters of the first device; receiving a management frame unicast response sent by the second device based on the management frame broadcast request, wherein the management frame response carries the second network parameters of the second device; Determining whether networking is required according to the first network parameter and the second network parameter; When networking is required, a network of the first device and the second device is established.
2. The method for establishing a network according to claim 1, characterized in that: Determining whether networking is required according to the first network parameter and the second network parameter includes: Determine whether the first device and the second device are under the same router according to the first network parameter and the second network parameter; When the first device and the second device are not on the same router, determining that networking is required; In the case where the first device and the second device are under the same router, it is detected whether the network connection between the first device and the second device is normal, and if it is abnormal, it is determined that networking is required.
3. The method for establishing a network according to claim 1, characterized in that: Establishing a network of the first device and the second device includes: Acquire first parameter information of the first device and second parameter information of the second device, wherein the first parameter information includes at least one of the following: a first priority, a first node type, a first received signal strength indicator RSSI value, and a first media access control MAC address, and the second parameter information includes at least one of the following: a second priority, a second node type, a second received signal strength indicator RSSI value, and a second media access control MAC address; A network of the first device and the second device is established according to the first parameter information and the second parameter information.
4. The method for establishing a network according to claim 3, characterized in that: Establishing a network of the first device and the second device according to the first parameter information and the second parameter information includes: comparing the first priority and the second priority; When the first priority is higher than the second priority, networking the second device as a child node of the first device; When the first priority is lower than the second priority, the first device is networked as a child node of the second device.
5. The method for establishing a network according to claim 4, characterized in that: After comparing the first priority and the second priority, the method further includes: When the first priority and the second priority are consistent, acquiring the first node type and the second node type; When it is determined according to the first node type and the second node type that the first device is a root node and the second device is a child node, networking the second device as a child node of the first device; When it is determined that the second device is a root node according to the first node type and the second node type, and the first device is a child node, the first device is networked as a child node of the second device.
6. The method for establishing a network according to claim 5, characterized in that: After acquiring the first node type and the second node type, the method further includes: When both the first node type and the second node type are root nodes, or both the first node type and the second node type are child nodes, obtaining a first RSSI value and a second RSSI value; When the first RSSI value is greater than the second RSSI value, networking the second device as a child node of the first device; When the first RSSI value is less than the second RSSI value, the first device is networked as a child node of the second device.
7. The method for establishing a network according to claim 6, characterized in that: After acquiring the first RSSI value and the second RSSI value, the method further includes: When the first RSSI value is equal to the second RSSI value, acquiring the first MAC address and the second MAC address; When the first MAC address is greater than the second MAC address, networking the second device as a child node of the first device; When the first MAC address is smaller than the second MAC address, the first device is networked as a child node of the second device.
8. A device for establishing a network, characterized in that: include: a sending module, configured to send a management frame broadcast request to the second device when it is determined that the first device and the second device cannot communicate, wherein the management frame broadcast request carries a first network parameter of the first device; a receiving module, configured to receive a management frame unicast response sent by the second device based on the management frame broadcast request, wherein the management frame response carries a second network parameter of the second device; A determination module, configured to determine whether networking is required according to the first network parameter and the second network parameter; An establishing module is used to establish a network between the first device and the second device when networking is required.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.