Method, device, equipment and storage medium for determining master device and slave device
Automatically determine the master and slave devices through data interaction between wireless networking devices, solving the problem of manual configuration in the prior art, realizing the automated networking process, reducing user costs and improving user experience.
Patent Information
- Application Number
- CN202210499124.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-09
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2042-05-09
AI Technical Summary
During the networking process, existing wireless networking equipment requires users to manually configure the master or slave equipment, which increases the user's usage costs and learning costs, and is prone to errors.
Through the data interaction between the first to-network device and the second to-network device, the master and slave devices are automatically determined, avoiding the need for manual manual settings and additional network cables.
The automated networking process of wireless networking equipment has been realized, which reduces user usage costs and learning costs, improves user experience, and expands the scope of application.
Smart Images

Figure CN115119230B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of communication technology, and in particular, relates to a method, an apparatus, a device and a storage medium for determining a master device and a slave device. Background Art
[0002] With the rapid development of information technology, people's demand for Internet access has increased dramatically. Traditional single wireless network equipment can no longer meet users' Internet access needs. Therefore, wireless network equipment networking has become the choice of more people.
[0003] In conventional wireless networking devices, there are generally two roles: master device and slave device, such as the Controller (master device) and Agent (slave device) in the EasyMesh network. In the EasyMesh network, the Controller, as the management center of the entire EasyMesh network, is mainly responsible for the network access configuration of other nodes, receiving information such as link quality and network capacity from other nodes, and controlling the channel selection, device roaming and load balancing of the nodes. In the EasyMesh network, except for the Controller, all others are Agents. The Agent is mainly responsible for receiving messages from the Controller and other Agents, and reporting link quality reports, standby quantity and other information to the Controller.
[0004] However, the wireless networking devices currently on the market still have the following problems during networking:
[0005] 1) Users are required to manually configure the wireless network device as a master device or a slave device before starting the networking process.
[0006] 2) Before using the wireless network device normally, the user needs to log in to the management page multiple times to make relevant settings, which increases the user's usage cost and reduces the user experience.
[0007] 3) Users generally do not have relevant networking background knowledge, so it is very easy to make mistakes when making relevant settings on the management page, the user learning cost is high, and it is not user-friendly. Summary of the invention
[0008] The present invention aims to solve one of the technical problems in the related art at least to a certain extent. To this end, one object of the present invention is to provide a method, apparatus, device and storage medium for determining a master device and a slave device.
[0009] In order to solve the above technical problems, the embodiments of the present invention provide the following technical solutions:
[0010] A method for determining a master device and a slave device, applied to a first device to be networked, comprising:
[0011] When the first networking device is in an election state, an election message is sent;
[0012] Obtain a message to be networked, determine the state of the second device to be networked according to the message to be networked, and if the second device to be networked is in the election state, generate a confirmation message and enter the confirmation state; or if the second device to be networked is in the confirmation state, determine the master device based on the message to be networked, and enter the confirmation state;
[0013] When the first device to be networked is in the confirmation state, sending the confirmation message;
[0014] The to-be-networked message is obtained, and the state of the second to-be-networked device is determined according to the to-be-networked message. If the second to-be-networked device is in a confirmation state, the master device and the slave device are determined based on the to-be-networked message.
[0015] Optionally, the election message includes a first parameter set of the first device to be networked;
[0016] The first parameter set includes a first level one parameter and a first level two parameter.
[0017] Optionally, if the second device to be networked is in the election state, generating a confirmation message and entering a confirmation state includes:
[0018] Obtaining the first level parameters;
[0019] Obtaining a second parameter set of the second device to be networked based on the message to be networked; the second parameter set includes a second first-level parameter and a second second-level parameter;
[0020] comparing the first primary parameter and the second primary parameter;
[0021] If the first level parameter is not equal to the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state;
[0022] If the first first-level parameter is equal to the second first-level parameter, comparing the first second-level parameter and the second second-level parameter, and obtaining a comparison result;
[0023] According to the comparison result, the confirmation message is generated based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and the confirmation state is entered.
[0024] Optionally, if the first level parameter is not equal to the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state, includes:
[0025] If the first level parameter is greater than the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked, and entering the confirmation state;
[0026] If the first level parameter is less than the second level parameter, the confirmation message is generated based on the MAC address of the second device to be networked, and the confirmation state is entered.
[0027] Optionally, the confirmation message includes at least the MAC address of the master device.
[0028] Optionally, if the second device to be networked is in a confirmation state, determining a master device and a slave device based on the message to be networked includes:
[0029] If the second device to be networked is in the confirmation state, entering the setting state;
[0030] Acquire the MAC address of the master device based on the to-be-networked message;
[0031] Compare the MAC address of the master device with the MAC address of the first device to be networked;
[0032] If the MAC address of the master device is the same as the MAC address of the first device to be networked, determining the first device to be networked as the master device;
[0033] If the MAC address of the master device is different from the MAC address of the first device to be networked, the first device to be networked is determined as the slave device.
[0034] Optionally, when the first device to be networked is in the confirmation state, the confirmation message is sent, and the message to be networked is received; and the state of the second device to be networked is determined according to the message to be networked, further comprising:
[0035] If the second device to be networked is in the election state, the message to be networked is not processed;
[0036] Continue to receive the to-be-networked message until the second to-be-networked device is in the confirmation state, and then enter the setting state;
[0037] The master device and the slave device are determined based on the message to be networked.
[0038] Optionally, also include:
[0039] Determine whether the first device to be networked has completed networking;
[0040] If the first device to be networked completes networking, the first device to be networked stops sending the confirmation message.
[0041] An embodiment of the present invention further provides a device for determining a master device and a slave device, which is applied to a first device to be networked, and includes:
[0042] An election module, configured to send an election message when the first to-be-networked device is in an election state;
[0043] A first judgment module is used to obtain a message to be networked, determine the state of the second device to be networked according to the message to be networked, and if the second device to be networked is in the election state, generate a confirmation message and enter the confirmation state; or if the second device to be networked is in the confirmation state, determine the master device based on the message to be networked, and enter the confirmation state;
[0044] A confirmation module, configured to send the confirmation message when the first device to be networked is in the confirmation state;
[0045] The second judgment module is used to obtain the message to be networked, determine the state of the second device to be networked according to the message to be networked, and if the second device to be networked is in a confirmation state, determine the master device and the slave device based on the message to be networked.
[0046] An embodiment of the present invention further provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the method described above when executing the computer program.
[0047] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the method described above.
[0048] The embodiments of the present invention have the following technical effects:
[0049] The above-mentioned technical scheme of the present invention, 1) based on the data interaction between the first device to be networked and the second device to be networked, realizes the first device to be networked and the second device to be networked to automatically determine the master device and the slave device, thereby avoiding the cumbersome problem of master and slave device configuration before networking. After the master device and the slave device are determined, the conventional networking process can be started directly without manual setting of the master device or the slave device, and no additional network cable is required, thereby reducing costs and expanding the scope of application; in addition, after the master device and the slave device are automatically determined, the conventional networking process can be started directly and can be used normally. Therefore, before the user normally uses the wireless network device, there is no need to log in to the management page multiple times to perform relevant settings, which reduces the user's usage cost and improves the user experience.
[0050] 2) By controlling the termination time of sending the confirmation message of the first device to be networked, the problem that the second device to be networked cannot receive the confirmation message sent by the first device to be networked due to the probabilistic packet loss of the wireless broadcast message is solved; at the same time, it also solves the problem that when the first device to be networked obtains the confirmation message, if it stops sending the wireless broadcast message and directly enters the setting state, the second device to be networked may not receive any election message and confirmation message sent by the first device to be networked, which will cause networking failure.
[0051] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 It is a flowchart of a method for determining a master device and a slave device provided by an embodiment of the present invention;
[0053] Figure 2 This is an example of a process of a method for determining a master device and a slave device provided by an embodiment of the present invention;
[0054] Figure 3 It is a structural schematic diagram of an apparatus for determining a master device and a slave device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0055] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.
[0056] In order to facilitate the understanding of the embodiments by those skilled in the art, some terms are explained:
[0057] (1) MAC: Media Access Control.
[0058] (2)Beacon: beacon.
[0059] (3) BSS: Basic Service Set.
[0060] At present, before wireless networking equipment is networked, it is necessary to manually set the devices participating in the networking as slave devices or master devices, which makes the networking process very cumbersome. In addition, although there are a very small number of wireless networking devices that can determine the master and slave devices through wired connections, it is still necessary to manually connect each device with a network cable, which not only incurs additional network cable costs, but also cannot be used for networking between wireless devices without network ports. The scope of application is small and cannot be popularized.
[0061] In order to solve the above technical problem, an embodiment of the present invention provides a system for determining a master device and a slave device, including:
[0062] A first device to be networked and a second device to be networked; wherein, the first device to be networked and the second device to be networked are both wireless network devices that support working as a master device or a slave device at the same time, that is, the first device to be networked or the second device to be networked may be determined as the master device later, and no matter whether the first device to be networked or the second device to be networked is determined as the master device, the first device to be networked or the second device to be networked can achieve normal configuration, normal networking and normal operation after networking.
[0063] Specifically, the embodiment of the present invention takes two wireless network devices as an example to automatically determine the master device and the slave device, and then automatically determines one of the wireless network devices as the master device and the other wireless network device as the slave device without manual intervention.
[0064] Furthermore, in the embodiment of the present invention, the first device to be networked and the second device to be networked can be controlled to enter the election state and end the networking process by means of buttons or intelligent control.
[0065] like Figure 1 As shown, an embodiment of the present invention further provides a method for determining a master device and a slave device, which is applied to a first device to be networked, and includes:
[0066] Step S1: When the first device to be networked is in an election state, an election message is sent;
[0067] The embodiments of the present invention use wireless broadcast messages as carriers for information exchange during networking, that is, election messages, messages to be networked in various states, and other messages involved in the embodiments of the present invention are all transmitted based on wireless broadcast messages as carriers.
[0068] Furthermore, in an embodiment of the present invention, in the process of determining a master device and a slave device, the first device to be networked and the second device to be networked have no priority difference and have equal authority to be determined as a master device or a slave device. Therefore, an embodiment of the present invention is explained based on the determination process on the side of the first device to be networked, and similarly, the determination process on the side of the second device to be networked can be obtained.
[0069] In an actual application scenario, when the first device to be networked determines to participate in networking, the first device to be networked enters an election state. At this time, the first device to be networked periodically sends an election message.
[0070] Step S2: obtaining a message to be networked, determining the state of the second device to be networked according to the message to be networked, and if the second device to be networked is in the election state, generating a confirmation message and entering the confirmation state; or if the second device to be networked is in the confirmation state, determining the master device based on the message to be networked, and entering the confirmation state;
[0071] In an embodiment of the present invention, when a first device to be networked in an election state receives a message to be networked sent from a second device to be networked, the message to be networked is parsed so as to determine the state of the second device to be networked based on the parsing result; wherein the parsing result includes the current state of the second device to be networked; that is, the first parameter set and the second parameter set also include state parameters; then, the subsequent process is determined according to the state of the second device to be networked.
[0072] Further, if the first device to be networked in the election state receives a confirmation message sent by the second device to be networked in the confirmation state, it enters the setting state;
[0073] The first device to be networked obtains the MAC address of the master device based on the confirmation message; then compares the MAC address of the master device with its own MAC address. If they are consistent, it sets itself as the master device and enters the normal networking process; if they are inconsistent, it sets itself as the slave device and enters the normal networking process.
[0074] Specifically, the election message includes a first parameter set of the first device to be networked;
[0075] The first parameter set includes a first level one parameter and a first level two parameter.
[0076] That is, when the first device to be networked parses the networked message and obtains the second first-level parameter and the second second-level parameter, it can be determined that the second device to be networked is in the election state.
[0077] Further, the determining the state of the second device to be networked according to the networked message, if the second device to be networked is in the election state, generating a confirmation message and entering a confirmation state, includes:
[0078] Obtaining the first level parameters;
[0079] Obtaining a second parameter set of the second device to be networked based on the message to be networked; the second parameter set includes a second first-level parameter and a second second-level parameter;
[0080] comparing the first primary parameter and the second primary parameter;
[0081] If the first level parameter is not equal to the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state;
[0082] If the first first-level parameter is equal to the second first-level parameter, comparing the first second-level parameter and the second second-level parameter, and obtaining a comparison result;
[0083] According to the comparison result, the confirmation message is generated based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and the confirmation state is entered.
[0084] For example: the first level parameter data may specifically be a potential value of a first master device, where the potential value of the first master device is an evaluation value or score of the first device to be networked obtained based on relevant parameters of the first device to be networked, and the first device to be networked may be used as a master device; wherein the relevant parameters may include user service quality, channel quality, interference, etc.; similarly, the second master device potential value of the second device to be networked may be obtained.
[0085] Furthermore, different relevant parameters can be set with different weights, and then summed up to obtain a score value, that is, the potential value of the first master device; similarly, the potential value of the second master device can be obtained.
[0086] In addition, the first and second level parameters may be the first MAC address, and similarly, the second and second level parameters may be the second MAC address; the embodiments of the present invention do not specifically limit this. In actual application scenarios, the categories of parameters included in the first parameter set or the second parameter set may be determined according to actual needs. The order or level of each type of parameter included in the first parameter set or the second parameter set participating in subsequent algorithm calls may also be determined according to actual needs.
[0087] In an embodiment of the present invention, in order to make the election process effective and thus smoothly enter the confirmation state, when the potential value of the first master device is equal to the potential value of the second master device, the master device and the slave device are determined based on the size of the first and second secondary parameters.
[0088] Further, if the first level parameter is not equal to the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state, includes:
[0089] If the first level parameter is greater than the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked, and entering the confirmation state;
[0090] If the first level parameter is less than the second level parameter, the confirmation message is generated based on the MAC address of the second device to be networked, and the confirmation state is entered.
[0091] Furthermore, the confirmation message includes at least a MAC address of the master device.
[0092] In an optional embodiment of the present invention, the first parameter set and the second parameter set may include other categories of parameters for determining the master device and the slave device in addition to the master device potential value, MAC address and status parameters; for example, when the master device and the slave device still cannot be determined based on the size of the first and second level parameters and the second and second level parameters, the master device and the slave device may also be determined based on other parameters.
[0093] Step S3: When the first device to be networked is in the confirmation state, sending the confirmation message;
[0094] In the embodiment of the present invention, when the first device to be networked is in a confirmation state, a confirmation message is periodically sent out until the first device to be networked completes the networking process.
[0095] Step S4: Acquire the message to be networked, determine the state of the second device to be networked according to the message to be networked, and if the second device to be networked is in a confirmation state, determine the master device and the slave device based on the message to be networked.
[0096] The embodiments of the present invention realize that the first device to be networked and the second device to be networked automatically determine the master device and the slave device based on the data interaction between the first device to be networked and the second device to be networked, thereby avoiding the problem of cumbersome configuration of the master and slave devices before networking. After the master device and the slave device are determined, the conventional networking process can be started directly without manual setting of the master device or the slave device and without additional network cables, thereby reducing costs and expanding the scope of application.
[0097] In addition, since the normal networking process can be started directly after the master device and the slave device are automatically determined and can be applied normally, the user does not need to log in to the management page multiple times to make relevant settings before using the wireless network device normally, which reduces the user's usage cost and improves the user experience.
[0098] Specifically, if the second device to be networked is in a confirmation state, determining a master device and a slave device based on the message to be networked includes:
[0099] If the second device to be networked is in the confirmation state, entering the setting state;
[0100] Acquire the MAC address of the master device based on the to-be-networked message;
[0101] Compare the MAC address of the master device with the MAC address of the first device to be networked;
[0102] If the MAC address of the master device is the same as the MAC address of the first device to be networked, determining the first device to be networked as the master device;
[0103] If the MAC address of the master device is different from the MAC address of the first device to be networked, the first device to be networked is determined as the slave device.
[0104] In an embodiment of the present invention, if the first device to be networked in the confirmation state receives a confirmation message sent by the second device to be networked in the confirmation state, it directly enters the setting state;
[0105] The first device to be networked obtains the MAC address of the master device based on the confirmation message; then compares the MAC address of the master device with its own MAC address. If they are consistent, it sets itself as the master device and enters the normal networking process; if they are inconsistent, it sets itself as the slave device and enters the normal networking process.
[0106] In an optional embodiment of the present invention, when the first device to be networked is in the confirmation state, the confirmation message is sent, and the message to be networked is received; and the state of the second device to be networked is determined according to the message to be networked, further comprising:
[0107] If the second device to be networked is in the election state, the message to be networked is not processed;
[0108] Continue to receive the to-be-networked message until the second to-be-networked device is in the confirmation state, and then enter the setting state;
[0109] The master device and the slave device are determined based on the message to be networked.
[0110] In the embodiment of the present invention, the first device to be networked will not enter the setting state until it receives a confirmation message sent by the second device to be networked, and then determine and set the master device and the slave device.
[0111] Optionally, also include:
[0112] Determine whether the first device to be networked has completed networking;
[0113] If the first device to be networked completes networking, the first device to be networked stops sending the confirmation message.
[0114] The embodiments of the present invention solve the problem that the second device to be networked cannot receive the confirmation message sent by the first device to be networked due to the probabilistic packet loss of the wireless broadcast message by controlling the termination time of sending the confirmation message of the first device to be networked; at the same time, it also solves the problem that when the first device to be networked obtains the confirmation message, if it stops sending the wireless broadcast message and directly enters the setting state, the second device to be networked may not receive any election message and confirmation message sent by the first device to be networked, which will cause networking failure.
[0115] Embodiments of the present invention, such as Figure 2 As shown, it can be implemented based on the following implementation methods:
[0116] Among them, the wireless broadcast message takes Beacon as an example, and the manufacturer's customization of the fields is represented based on the following Table 1;
[0117] Table 1
[0118]
[0119] Specifically, two wireless networking devices that support both master and slave functions are selected and are represented by device A and device B respectively, and currently, device A and device B are in the same mode;
[0120] For example: based on State (0X01), Score (A), MAC (A.MAC)), an election message of device A is generated; wherein, State (0X01) indicates that the current state of device A is 0X01, that is, the election state; Score (A) indicates the master device potential value of device A, which is a specific value obtained by actual calculation, such as: 0X08 or 0X18, etc. For the convenience of description, the embodiment of the present invention is represented by Score (A); MAC (A.MAC) indicates the MAC address of device A; similarly, the above information of device B can be obtained.
[0121] Since the processes and principles for the A device and the B device to participate in determining the master device and the slave device are the same, the embodiment of the present invention is specifically explained based on the process for the A device to participate in determining the master device and the slave device:
[0122] 1) Device A enters the election state, for example, based on a control key on device A, device A is controlled to enter the election state, or in any other feasible manner, device A is controlled to enter the election state, and the embodiments of the present invention do not impose any limitation on this;
[0123] 2) After device A enters the election state, it generates an election message based on its own state information, and periodically sends an election message Beacon (State (0X01), Score (A), MAC (A.MAC)) carrying a custom field; at the same time, device A listens to the Beacon of device B. If it receives the Beacon of device B, it extracts the custom information in the frame and makes a judgment;
[0124] 3) If the state field of device B is State (0X02), it indicates that device B is in the confirmation state. Based on the Beacon of device B, the MAC address of the master device is obtained, and then the confirmation state is entered; the MAC (A.MAC) and the MAC address of the master device are compared. If the MAC (A.MAC) and the MAC address of the master device are consistent, device A is the master device and the normal networking process is entered; if the MAC (A.MAC) and the MAC address of the master device are inconsistent, device A is the slave device and the normal networking process is entered;
[0125] 4) If the state field of device B is State (0X01), it indicates that device B is in the election state, then compare the size of Score (A) and Score (B);
[0126] If Score(A)>Score(B), it can be determined that device A is the primary device, obtain MAC(A.MAC), generate a confirmation message, and then enter the confirmation state; if Score(A)<Score(B), it can be determined that device B is the primary device, obtain MAC(B.MAC), generate a confirmation message, and then enter the confirmation state;
[0127] If Score(A)=Score(B), then compare MAC(A.MAC) and MAC(B.MAC);
[0128] If MAC(A.MAC)>MAC(B.MAC), it can be determined that device A is the master device, obtain MAC(A.MAC), generate a confirmation message, and then enter the confirmation state;
[0129] If MAC(A.MAC)<MAC(B.MAC), it can be determined that device B is the master device, obtain MAC(B.MAC), generate a confirmation message, and then enter the confirmation state;
[0130] 5) After device A enters the confirmation state, it periodically sends confirmation messages Beacon carrying custom fields until device A completes networking; at the same time, device A listens to the Beacon of device B. If it receives the Beacon of device B, it extracts the custom information in the Beacon frame and makes a judgment;
[0131] 6) If the state field of device B is State (0X01), it indicates that device B is in the election state, ignores the Beacon of device B, and continues to send confirmation message Beacon. At the same time, device A listens to the Beacon of device B. If the Beacon of device B is received, it extracts the custom information in the Beacon frame and makes a judgment;
[0132] 7) If the status field of device B is State (0X02), it means that device B is in the confirmation state, device A enters the setting state, and compares the size of MAC (A.MAC) and the MAC address of the main device.
[0133] 8) If the MAC (A.MAC) is consistent with the MAC address of the master device, the A device will be the master device and enter the normal networking process;
[0134] If the MAC (A.MAC) and the MAC address of the master device are different, device A will be set as a slave device and enter the normal networking process.
[0135] 9) After device A completes networking, it stops sending confirmation messages Beacon.
[0136] like Figure 3As shown, an embodiment of the present invention further provides a device 300 for determining a master device and a slave device, which is applied to a first device to be networked, and includes:
[0137] The election module 301 is used to send an election message when the first to-be-networked device is in an election state;
[0138] The first judgment module 302 is used to obtain a message to be networked, determine the state of the second device to be networked according to the message to be networked, and if the second device to be networked is in the election state, generate a confirmation message and enter the confirmation state; or if the second device to be networked is in the confirmation state, determine the master device based on the message to be networked, and enter the confirmation state;
[0139] A confirmation module 303, configured to send the confirmation message when the first to-be-networked device is in the confirmation state;
[0140] The second judgment module 304 is used to obtain the to-be-networked message, determine the state of the second to-be-networked device according to the to-be-networked message, and if the second to-be-networked device is in a confirmation state, determine the master device and the slave device based on the to-be-networked message.
[0141] Optionally, the election message includes a first parameter set of the first device to be networked;
[0142] The first parameter set includes a first level one parameter and a first level two parameter.
[0143] Optionally, if the second device to be networked is in the election state, generating a confirmation message and entering a confirmation state includes:
[0144] Obtaining the first level parameters;
[0145] Obtaining a second parameter set of the second device to be networked based on the message to be networked; the second parameter set includes a second first-level parameter and a second second-level parameter;
[0146] comparing the first primary parameter and the second primary parameter;
[0147] If the first level parameter is not equal to the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state;
[0148] If the first first-level parameter is equal to the second first-level parameter, comparing the first second-level parameter and the second second-level parameter, and obtaining a comparison result;
[0149] According to the comparison result, the confirmation message is generated based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and the confirmation state is entered.
[0150] Optionally, if the first level parameter is not equal to the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state, includes:
[0151] If the first level parameter is greater than the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked, and entering the confirmation state;
[0152] If the first level parameter is less than the second level parameter, the confirmation message is generated based on the MAC address of the second device to be networked, and the confirmation state is entered.
[0153] Optionally, the confirmation message includes at least the MAC address of the master device.
[0154] Optionally, if the second device to be networked is in a confirmation state, determining a master device and a slave device based on the message to be networked includes:
[0155] If the second device to be networked is in the confirmation state, entering the setting state;
[0156] Acquire the MAC address of the master device based on the to-be-networked message;
[0157] Compare the MAC address of the master device with the MAC address of the first device to be networked;
[0158] If the MAC address of the master device is the same as the MAC address of the first device to be networked, determining the first device to be networked as the master device;
[0159] If the MAC address of the master device is different from the MAC address of the first device to be networked, the first device to be networked is determined as the slave device.
[0160] Optionally, when the first device to be networked is in the confirmation state, the confirmation message is sent, and the message to be networked is received; and the state of the second device to be networked is determined according to the message to be networked, further comprising:
[0161] If the second device to be networked is in the election state, the message to be networked is not processed;
[0162] Continue to receive the to-be-networked message until the second to-be-networked device is in the confirmation state, and then enter the setting state;
[0163] The master device and the slave device are determined based on the message to be networked.
[0164] Optionally, also include:
[0165] Determine whether the first device to be networked has completed networking;
[0166] If the first device to be networked completes networking, the first device to be networked stops sending the confirmation message.
[0167] An embodiment of the present invention further provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the method described above when executing the computer program.
[0168] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the method described above.
[0169] In addition, other structures and functions of the device in the embodiment of the present invention are known to those skilled in the art and will not be described in detail here to reduce redundancy.
[0170] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0171] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0172] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0173] In the description of the present invention, it is to be understood that the terms “center”, “longitudinal”, “lateral”, “length”, “width”, “thickness”, “up”, “down”, “front”, “back”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, “clockwise”, “counterclockwise”, “axial”, “radial”, “circumferential”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0174] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0175] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0176] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0177] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for determining a master device and a slave device, characterized in that: Applicable to the first device to be networked, including: When the first networking device is in an election state, an election message is sent; Obtain a message to be networked, determine the state of the second device to be networked according to the message to be networked, and if the second device to be networked is in the election state, generate a confirmation message and enter the confirmation state; if the second device to be networked is in the confirmation state, determine the master device based on the message to be networked, and enter the confirmation state; When the first device to be networked is in the confirmation state, sending the confirmation message; Acquire the to-be-networked message, determine the state of the second to-be-networked device according to the to-be-networked message, and if the second to-be-networked device is in a confirmation state, determine the master device and the slave device based on the to-be-networked message; The election message includes a first parameter set of the first device to be networked; Wherein, the first parameter set includes the first level one parameter and the first level two parameter; If the second device to be networked is in the election state, a confirmation message is generated and the confirmation state is entered, including: Obtaining the first level parameters; Obtaining a second parameter set of the second device to be networked based on the message to be networked; the second parameter set includes a second first-level parameter and a second second-level parameter; comparing the first primary parameter and the second primary parameter; If the first level parameter is not equal to the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state; If the first primary parameter is equal to the second primary parameter, comparing the first secondary parameter and the second secondary parameter, and obtaining a comparison result; According to the comparison result, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state; The confirmation message includes at least the MAC address of the master device.
2. The method according to claim 1, characterized in that If the first level parameter is not equal to the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state, includes: If the first level parameter is greater than the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked, and entering the confirmation state; If the first level parameter is less than the second level parameter, the confirmation message is generated based on the MAC address of the second device to be networked, and the confirmation state is entered.
3. The method according to claim 1, characterized in that If the second device to be networked is in a confirmation state, determining a master device and a slave device based on the message to be networked includes: If the second device to be networked is in the confirmation state, entering the setting state; Acquire the MAC address of the master device based on the to-be-networked message; Compare the MAC address of the master device with the MAC address of the first device to be networked; If the MAC address of the master device is the same as the MAC address of the first device to be networked, determining the first device to be networked as the master device; If the MAC address of the master device is different from the MAC address of the first device to be networked, the first device to be networked is determined as the slave device.
4. The method according to claim 1, characterized in that: When the first device to be networked is in the confirmation state, the confirmation message is sent and the message to be networked is received; Determining the state of the second device to be networked according to the message to be networked, further comprising: If the second device to be networked is in the election state, the message to be networked is not processed; Continue to receive the to-be-networked message until the second to-be-networked device is in the confirmation state, and then enter the setting state; The master device and the slave device are determined based on the message to be networked.
5. The method according to claim 1, characterized in that Also includes: Determine whether the first device to be networked has completed networking; If the first device to be networked completes networking, the first device to be networked stops sending the confirmation message.
6. A device for determining a master device and a slave device, characterized in that: Applicable to the first device to be networked, including: An election module, configured to send an election message when the first to-be-networked device is in an election state; A first judgment module is used to obtain a message to be networked, determine the state of the second device to be networked according to the message to be networked, and if the second device to be networked is in the election state, generate a confirmation message and enter the confirmation state; if the second device to be networked is in the confirmation state, determine the master device based on the message to be networked, and enter the confirmation state; A confirmation module, configured to send the confirmation message when the first device to be networked is in the confirmation state; a second judgment module, configured to obtain the to-be-networked message, determine the state of the second to-be-networked device according to the to-be-networked message, and if the second to-be-networked device is in a confirmation state, determine the master device and the slave device based on the to-be-networked message; The election message includes a first parameter set of the first device to be networked; Wherein, the first parameter set includes the first level one parameter and the first level two parameter; If the second device to be networked is in the election state, a confirmation message is generated and the confirmation state is entered, including: Obtaining the first level parameters; Obtaining a second parameter set of the second device to be networked based on the message to be networked; the second parameter set includes a second first-level parameter and a second second-level parameter; comparing the first primary parameter and the second primary parameter; If the first level parameter is not equal to the second level parameter, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state; If the first primary parameter is equal to the second primary parameter, comparing the first secondary parameter and the second secondary parameter, and obtaining a comparison result; According to the comparison result, generating the confirmation message based on the MAC address of the first device to be networked or the MAC address of the second device to be networked, and entering the confirmation state; The confirmation message includes at least the MAC address of the master device.
7. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Distributed system and message processing method
CN106789095A
POE (Power Over Ethernet) smart home gateway networking configuration method
CN108111358A
Selection method, device and equipment for master node
CN108810100A
AP election method and device and computer readable storage medium
CN114258112A