Disclosure of Invention
The invention aims to solve the technical problems of low convenience and flexibility caused by manual IP configuration when intelligent equipment fails to automatically acquire the IP, and provides an automatic searching method and device for the intelligent equipment.
The invention adopts the following technical means for solving the technical problems:
in a first aspect, an automatic searching method of an intelligent device is provided, and the method is applied to a router, and includes:
receiving a host number detection request sent by a local switch, wherein the host number detection request is generated by the local switch according to a first Internet protocol address IP manually input by a user on first intelligent equipment, and the first intelligent equipment and the router are indirectly communicated through the local switch;
judging whether the type of the first Internet protocol address IP is a host number detection type;
acquiring a second internet protocol address IP of a second intelligent device which is successfully connected by dialing in the local switch under the condition that the type of the first internet protocol address IP is the host number detection type;
determining that the host number with the dialing connection time closest to the current time in the second internet protocol address IP is a target host number, and determining the minimum difference value between the host number which is successfully dialed and connected in the router and the target host number;
determining whether the number of host numbers between the host number corresponding to the minimum difference value of the host numbers and the target host number is the same as the number of intelligent devices connected with the local switch, wherein the intelligent devices connected with the local switch comprise the first intelligent device and the second intelligent device;
when the number of host numbers between the host number corresponding to the minimum difference value of the host numbers and the target host number is the same as the number of intelligent devices connected with the local switch, taking the host number corresponding to the minimum difference value of the host numbers and the host number of the next host number of the smaller host number as the initial host number;
re-determining a target internet protocol address IP of each intelligent device connected with the local switch at least according to the initial host number and the network number of the router;
and sending a response protocol message for responding to the host number detection request to the local switch, so that the local switch sends the response protocol message comprising the target internet protocol address to each intelligent device after receiving the response protocol message sent by the router, and the intelligent devices dial-up connection according to the target internet protocol address in the received response protocol message.
Optionally, the redefining the target internet protocol address of each of the intelligent devices connected to the local switch at least according to the initial host number and the network number of the router includes:
and re-determining the target internet protocol address of each intelligent device connected with the local switch according to the initial host number, the network number of the router and the dial-up connection time of the second intelligent device and the local switch.
Optionally, the redefining the target internet protocol address of each intelligent device connected to the local switch according to the initial host number, the network number of the router and the dial-up connection time of the second intelligent device and the local switch includes:
generating a target internet protocol address of an intelligent device with the farthest dialing connection time from the current time in the second intelligent device and the local switch according to the initial host number and the network number of the router;
and (3) loop execution:
taking the host number of the next bit of the initial host number as a new initial host number, and taking the intelligent device which is not redetermined with the Internet protocol address in the second intelligent device and has the farthest dialing connection time with the local switch from the current time as a target intelligent device; and is combined with the other components of the water treatment device,
generating a target internet protocol address of the target intelligent device according to the new initial host number and the network number of the router until determining the target internet protocol address of the intelligent device with the dialing connection time closest to the current time in the second intelligent device;
and generating the target internet protocol address of the first intelligent device according to the host number of the target internet protocol address of the intelligent device closest to the current time and the network number of the router.
Optionally, the method further comprises:
determining a host number secondary small difference value between the host number successfully dialed and the target host number in the router under the condition that the number of the host numbers corresponding to the minimum difference value of the host numbers is different from the number of the intelligent devices connected with the local switch;
determining whether the number of host numbers between the host number corresponding to the host number minor difference value and the target host number is the same as the number of intelligent devices connected with the local switch;
and under the condition that the number of host numbers corresponding to the host number minor difference value and the host numbers between the host numbers and the target host numbers is the same as the number of intelligent devices connected with the local switch, taking the host number corresponding to the host number minor difference value and the host number of the next host number of the smaller host number as the initial host number.
In a second aspect, an automatic searching apparatus for an intelligent device is provided, and is applied to a router, where the apparatus includes:
the system comprises a receiving module, a router and a first intelligent device, wherein the receiving module is used for receiving a host number detection request sent by a local switch, the host number detection request is generated by the local switch according to a first Internet protocol address IP manually input by a user on the first intelligent device, and the first intelligent device and the router are indirectly communicated through the local switch;
the judging module is used for judging whether the type of the first internet protocol address IP is a host number detection type or not;
the obtaining module is used for obtaining a second internet protocol address IP of a second intelligent device which is successfully connected by dialing in the local switch under the condition that the type of the first internet protocol address IP is the host number detection type;
a first determining module, configured to determine, as a target host number, a host number in the second internet protocol address IP that has a dial-up connection time closest to a current time, and determine a host number minimum difference value between the host number in the router that has been successfully dial-up connected and the target host number;
a second determining module, configured to determine whether the number of host numbers between the host number corresponding to the minimum difference value of host numbers and the target host number is the same as the number of intelligent devices connected to the local switch, where the intelligent devices connected to the local switch include the first intelligent device and the second intelligent device;
a third determining module, configured to, when the number of host numbers between the host number corresponding to the minimum difference value of host numbers and the target host number is the same as the number of intelligent devices connected to the local switch, set a next host number of the smaller host number of the host number corresponding to the minimum difference value of host numbers and the target host number as a starting host number;
a fourth determining module, configured to redetermine, according to at least the initial host number and the network number of the router, a target IP address of each of the intelligent devices connected to the local switch;
and the sending module is used for sending a response protocol message for responding to the host number detection request to the local switch, so that the local switch sends the response protocol message comprising the target internet protocol address to each intelligent device after receiving the response protocol message sent by the router, and the intelligent device dials and connects according to the target internet protocol address in the received response protocol message.
Optionally, the fourth determining module is configured to:
and re-determining the target internet protocol address of each intelligent device connected with the local switch according to the initial host number, the network number of the router and the dial-up connection time of the second intelligent device and the local switch.
Optionally, the fourth determining module is configured to:
generating a target internet protocol address of an intelligent device with the farthest dialing connection time from the current time in the second intelligent device and the local switch according to the initial host number and the network number of the router;
and (3) loop execution:
taking the host number of the next bit of the initial host number as a new initial host number, and taking the intelligent device which is not redetermined with the Internet protocol address in the second intelligent device and has the farthest dialing connection time with the local switch from the current time as a target intelligent device; and is combined with the other components of the water treatment device,
generating a target internet protocol address of the target intelligent device according to the new initial host number and the network number of the router until determining the target internet protocol address of the intelligent device with the dialing connection time closest to the current time in the second intelligent device;
and generating the target internet protocol address of the first intelligent device according to the host number of the target internet protocol address of the intelligent device closest to the current time and the network number of the router.
Optionally, the apparatus further comprises:
a fifth determining module, configured to determine, when the number of host numbers between the host number corresponding to the minimum difference value of host numbers and the target host number is different from the number of intelligent devices connected to the local switch, a host number minor difference value between the host number successfully dialed in the router and the target host number;
a sixth determining module, configured to determine whether the number of host numbers between the host number corresponding to the host number minor difference value and the target host number is the same as the number of intelligent devices connected to the local switch;
and a seventh determining module, configured to, when the number of host numbers between the host number corresponding to the host number minor difference value and the target host number is the same as the number of intelligent devices connected to the local switch, set a next host number of the smaller host number of the host number corresponding to the host number minor difference value and the target host number as an initial host number.
The beneficial effects are that: by receiving a host number probe request; judging whether the type of the first IP in the host number detection request is a host number detection type or not; if so, acquiring a second IP of the second intelligent equipment which is successfully connected; determining a host number with the dialing connection time closest to the current time in the second IP as a target host number, and determining a minimum difference value between the host number with the dialing connection success and the host number of the target host number; determining whether the number of the host numbers corresponding to the minimum difference value of the host numbers is the same as the number of the intelligent devices connected with the local switch or not; if the host numbers are the same, taking the host number of the next host number of the smaller host number of the host numbers corresponding to the minimum difference value of the host numbers and the target host number as the initial host number; re-determining the target IP of each intelligent device according to the initial host number and the network number; a response protocol message including the target IP for responding to the host number probe request is transmitted to the local exchange. The method and the device can conveniently determine the target IP aiming at the intelligent equipment connected with the local switch from the unused host numbers in the router, and improve the flexibility and convenience of manually configuring the IP of the intelligent equipment under the condition of failure of automatically acquiring the IP.
FIG. 1 is a flow chart of one embodiment of an automatic search method for a smart device of the present invention;
FIG. 2 is a block diagram of one embodiment of an automatic search device for a smart device of the present invention.
The invention has the advantages of realizing the purpose, functional characteristics and advantages, and further description with reference to the accompanying drawings.
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, a flowchart of an automatic searching method for an intelligent device according to an embodiment of the present invention is shown in fig. 1, where the method includes:
in step S11, a host number detection request sent by a local switch is received, where the host number detection request is generated by the local switch according to a first internet protocol address IP manually input by a user on a first intelligent device, and the first intelligent device and the router indirectly communicate through the local switch;
in step S12, it is determined whether the type of the first internet protocol address IP is a host number detection type;
in step S13, if the type of the first IP address is the host number detection type, acquiring a second IP address IP of a second smart device that has been successfully dial-up connected in the local switch;
in step S14, determining that the host number with the closest dial-up connection time to the current time in the second internet protocol address IP is the target host number, and determining the minimum difference between the host number in the host numbers with successful dial-up connection in the router and the target host number;
in step S15, determining whether the number of host numbers between the host number corresponding to the minimum difference value of host numbers and the target host number is the same as the number of intelligent devices connected to the local switch, where the intelligent devices connected to the local switch include the first intelligent device and the second intelligent device;
in step S16, when the number of host numbers between the host number corresponding to the minimum difference value of host numbers and the target host number is the same as the number of intelligent devices connected to the local switch, a next host number of the smaller one of the host number corresponding to the minimum difference value of host numbers and the target host number is the initial host number;
in step S17, the target internet protocol address IP of each intelligent device connected to the local switch is redetermined at least according to the initial host number and the network number of the router;
in step S18, a response protocol message for responding to the host number probe request is sent to the local switch, so that after receiving the response protocol message sent by the router, the local switch sends the response protocol message including the target internet protocol address to each intelligent device, so that the intelligent device dials a connection according to the target internet protocol address in the received response protocol message.
By receiving a host number probe request; judging whether the type of the first IP in the host number detection request is a host number detection type or not; if so, acquiring a second IP of the second intelligent equipment which is successfully connected; determining a host number with the dialing connection time closest to the current time in the second IP as a target host number, and determining a minimum difference value between the host number with the dialing connection success and the host number of the target host number; determining whether the number of the host numbers corresponding to the minimum difference value of the host numbers is the same as the number of the intelligent devices connected with the local switch or not; if the host numbers are the same, taking the host number of the next host number of the smaller host number of the host numbers corresponding to the minimum difference value of the host numbers and the target host number as the initial host number; re-determining the target IP of each intelligent device according to the initial host number and the network number; a response protocol message including the target IP for responding to the host number probe request is transmitted to the local exchange. The method and the device can conveniently determine the target IP aiming at the intelligent equipment connected with the local switch from the unused host numbers in the router, and improve the flexibility and convenience of manually configuring the IP of the intelligent equipment under the condition of failure of automatically acquiring the IP.
Optionally, in step S17, the redefining, according to at least the initial host number and the network number of the router, a target internet protocol address of each of the intelligent devices connected to the local switch includes:
and re-determining the target internet protocol address of each intelligent device connected with the local switch according to the initial host number, the network number of the router and the dial-up connection time of the second intelligent device and the local switch.
Optionally, the redefining the target internet protocol address of each intelligent device connected to the local switch according to the initial host number, the network number of the router and the dial-up connection time of the second intelligent device and the local switch includes:
generating a target internet protocol address of an intelligent device with the farthest dialing connection time from the current time in the second intelligent device and the local switch according to the initial host number and the network number of the router;
and (3) loop execution:
taking the host number of the next bit of the initial host number as a new initial host number, and taking the intelligent device which is not redetermined with the Internet protocol address in the second intelligent device and has the farthest dialing connection time with the local switch from the current time as a target intelligent device; and is combined with the other components of the water treatment device,
generating a target internet protocol address of the target intelligent device according to the new initial host number and the network number of the router until determining the target internet protocol address of the intelligent device with the dialing connection time closest to the current time in the second intelligent device;
and generating the target internet protocol address of the first intelligent device according to the host number of the target internet protocol address of the intelligent device closest to the current time and the network number of the router.
Optionally, the method further comprises:
determining a host number secondary small difference value between the host number successfully dialed and the target host number in the router under the condition that the number of the host numbers corresponding to the minimum difference value of the host numbers is different from the number of the intelligent devices connected with the local switch;
determining whether the number of host numbers between the host number corresponding to the host number minor difference value and the target host number is the same as the number of intelligent devices connected with the local switch;
and under the condition that the number of host numbers corresponding to the host number minor difference value and the host numbers between the host numbers and the target host numbers is the same as the number of intelligent devices connected with the local switch, taking the host number corresponding to the host number minor difference value and the host number of the next host number of the smaller host number as the initial host number.
Based on the same inventive concept, the embodiment of the present invention further provides an automatic searching apparatus for an intelligent device, which is applied to a router, and as shown in fig. 2, the apparatus includes:
a receiving module 110, configured to receive a host number detection request sent by a local switch, where the host number detection request is generated by the local switch according to a first internet protocol address IP manually input by a user on a first intelligent device, and the first intelligent device is indirectly communicated with the router through the local switch;
a judging module 120, configured to judge whether the type of the first IP address IP is a host number detection type;
an obtaining module 130, configured to obtain, when the type of the first IP address is the host number detection type, a second IP address IP of a second smart device that has been successfully dial-up connected in the local switch;
a first determining module 140, configured to determine that a host number in the second internet protocol address IP, whose dial-up connection time is closest to a current time, is a target host number, and determine a host number minimum difference value between a host number in the router, which has been successfully dial-up connected, and the target host number;
a second determining module 150, configured to determine whether the number of host numbers between the host number corresponding to the minimum difference value of host numbers and the target host number is the same as the number of intelligent devices connected to the local switch, where the intelligent devices connected to the local switch include the first intelligent device and the second intelligent device;
a third determining module 160, configured to, when the number of host numbers between the host number corresponding to the minimum difference value of host numbers and the target host number is the same as the number of intelligent devices connected to the local switch, set a next host number of the smaller host number of the host number corresponding to the minimum difference value of host numbers and the target host number as a starting host number;
a fourth determining module 170, configured to redetermine a target IP address of each of the intelligent devices connected to the local switch according to at least the initial host number and the network number of the router;
and a sending module 180, configured to send a response protocol message for responding to the host number probe request to the local switch, so that, after receiving the response protocol message sent by the router, the local switch sends the response protocol message including the target internet protocol address to each intelligent device, so that the intelligent device dials a connection according to the target internet protocol address in the received response protocol message.
Optionally, the fourth determining module 170 is configured to:
and re-determining the target internet protocol address of each intelligent device connected with the local switch according to the initial host number, the network number of the router and the dial-up connection time of the second intelligent device and the local switch.
Optionally, the fourth determining module 170 is configured to:
generating a target internet protocol address of an intelligent device with the farthest dialing connection time from the current time in the second intelligent device and the local switch according to the initial host number and the network number of the router;
and (3) loop execution:
taking the host number of the next bit of the initial host number as a new initial host number, and taking the intelligent device which is not redetermined with the Internet protocol address in the second intelligent device and has the farthest dialing connection time with the local switch from the current time as a target intelligent device; and is combined with the other components of the water treatment device,
generating a target internet protocol address of the target intelligent device according to the new initial host number and the network number of the router until determining the target internet protocol address of the intelligent device with the dialing connection time closest to the current time in the second intelligent device;
and generating the target internet protocol address of the first intelligent device according to the host number of the target internet protocol address of the intelligent device closest to the current time and the network number of the router.
Optionally, the apparatus further comprises:
a fifth determining module, configured to determine, when the number of host numbers between the host number corresponding to the minimum difference value of host numbers and the target host number is different from the number of intelligent devices connected to the local switch, a host number minor difference value between the host number successfully dialed in the router and the target host number;
a sixth determining module, configured to determine whether the number of host numbers between the host number corresponding to the host number minor difference value and the target host number is the same as the number of intelligent devices connected to the local switch;
and a seventh determining module, configured to, when the number of host numbers between the host number corresponding to the host number minor difference value and the target host number is the same as the number of intelligent devices connected to the local switch, set a next host number of the smaller host number of the host number corresponding to the host number minor difference value and the target host number as an initial host number.
Although embodiments of the present invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made therein without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.