Invention content
The present invention provides a kind of method, terminal and smart machine for automatically switching communication mode, to solve in the prior art
The technical issues of control signal transmission efficiency caused by cannot preferentially selecting sub-nets transmission during terminal control smart machine is low.
In order to solve the above technical problems, one aspect of the present invention is to provide a kind of automatic switchover communication mode
Method, including:
The network that terminal judgement currently connects is mobile network or WLAN;
If the network that the terminal currently connects is the WLAN, judge whether are the terminal and smart machine
In same subnet;
If so, the terminal and the smart machine direct communication, otherwise by external device forward the terminal with
Signal of communication between the smart machine.
In order to solve the above technical problems, another technical solution used in the present invention is to provide a kind of terminal, including:
Processor, for judging that the network currently connected is mobile network or WLAN;If the terminal is current
Whether the network of connection is the WLAN, then judge the terminal with smart machine in same subnet;
First telecommunication circuit, for when the terminal and the smart machine are in same subnet, being set with the intelligence
Standby direct communication;When the terminal and the smart machine be not in same subnet, pass through external device forwarding and the intelligence
Signal of communication between energy equipment.
In order to solve the above technical problems, another technical solution used in the present invention is to provide a kind of smart machine, including:
Second telecommunication circuit is straight with the smart machine for when the smart machine and terminal are in same subnet
Connect letter;When the smart machine and terminal be not in same subnet, by between external device forwarding and the terminal
Signal of communication.
The present invention is by judging that terminal whether in same subnet, preferentially selects to pass through sub-nets transmission letter with smart machine
Number so that the control efficiency higher of terminal-pair smart machine.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete
Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, those of ordinary skill in the art are obtained every other without making creative work
Embodiment belongs to the scope of protection of the invention.
Referring to Fig. 1, one embodiment of method that the present invention automatically switches communication mode includes:
The network that S101, terminal judgement currently connect is mobile network or WLAN;
In the present embodiment, terminal can be mobile phone, tablet computer etc..The mobile network of terminal connection can be that honeycomb moves
Dynamic network passes through external device, such as the forwarding signal of communication such as base station, server.Terminal connection WLAN can be
The wireless network generated by home router, such as WiFi (WIreless-Fidelity, Wireless Fidelity) etc..
If the network that S102, terminal currently connect is WLAN, judge terminal with smart machine whether same
In subnet;
In the present embodiment, it can be broadcasted by service set (SSID, Service Set Identifier), inquiry
Whether the modes such as IP (Internet Protocol, procotol) address judge terminal with smart machine in same subnet.
In the present embodiment, smart machine can be intelligent monitoring device, intelligent security guard equipment, digital cinema equipment, intelligence
Energy lighting apparatus etc..
S103, if so, the terminal and the smart machine direct communication;
S104, if it is not, then forwarding the signal of communication between the terminal and the smart machine by external device.
In the present embodiment, external device can be base station, server etc..
The embodiment of the present invention is by judging that terminal whether in same subnet, preferentially selects to pass through subnet biography with smart machine
Defeated signal so that the control efficiency higher of terminal-pair smart machine.
Referring to Fig. 2, one embodiment of method that the present invention automatically switches communication mode includes:
S201, judge that the network that terminal currently connects is mobile network or WLAN;
In the present embodiment, the mobile network of terminal connection can be cellular mobile network, pass through external device, such as base
It stands, the forwarding signal of communication such as server.The WLAN of terminal connection can be the wireless network generated by home router
Network, such as WiFi etc..
If the network that S202, terminal currently connect is WLAN, the service set of smart machine is obtained;
In the present embodiment, terminal can receive the services set mark of smart machine by the WLAN currently connected
Know, the service set of smart machine, such as bluetooth, mobile network etc. can also be obtained by other communication modes.
If the network that S203, terminal currently connect is mobile network, pass through external device forwarding terminal and smart machine
Between signal of communication;
In the present embodiment, external device can be server, and terminal is led to respectively with server, smart machine and server
Mobile network's connection is crossed, signal of communication is forwarded to realize the communication between terminal and smart machine by server.
Whether S204, the service set for judging smart machine are empty;
In the present embodiment, by the service set of smart machine caching judge smart machine service set whether
For sky.
If the service set of S205, smart machine is not sky, the service set and smart machine of terminal are judged
Whether service set is identical;
If the service set of S206, smart machine is the empty or service set of terminal and the services set of smart machine
Identify it is identical, then judge find label (Last Found) whether be true;
In the present embodiment, if the service set of smart machine is sky, it can not determine whether are terminal and smart machine
In same subnet, still need to further judge terminal with smart machine whether in same subnet by finding label.
If S207, finding labeled as very, terminal and smart machine, can be with direct communications in same subnet;Otherwise it returns
Step S203 is returned, the signal of communication between forwarding terminal and smart machine is set by the external world.
In other embodiments, terminal can also be judged with smart machine whether same by way of inquiring IP address
In subnet, for example, terminal obtains the IP address of smart machine, it is compared with the IP address of terminal, so that it is determined that terminal and intelligence
Whether energy equipment is in same subnet.
Specifically, referring to Fig. 3, the method that label is found in setting specifically includes:
S301, terminal send broadcast in the subnet currently connected and find smart machine;
In the present embodiment, terminal finds smart machine by sending service set broadcast.
S302, judge whether smart machine replys;
If S303, smart machine response, label will be found and be set as true;
If S304, smart machine are unresponsive, label will be found and be set to false as.
In the present embodiment, if smart machine and terminal are in same subnet, when smart machine receives terminal transmission
Service set is broadcasted, will feedback signal to terminal, label will be found at this time and be set as true;If smart machine does not exist with terminal
In same subnet, smart machine can not receive terminal transmission service set broadcast, just can not feedback signal, will seek at this time
Label is looked for be set to false as.
Referring to Fig. 4, can also include in the present embodiment:
The system broadcasts that S401, terminal monitoring WLAN change, judge whether the WLAN of terminal connection is sent out
It is raw to change;
In the present embodiment, terminal judges WLAN by system broadcasts that software monitoring wireless LAN changes
Whether change.
S402, if so, rejudging terminal and smart machine whether in same subnet;
In the present embodiment, if the WLAN of terminal connection changes, need to rejudge terminal with intelligently setting
It is standby to return to above-mentioned step S201 whether in same subnet, repeat deterministic process.
S403, original communication mode is otherwise performed.
In the present embodiment, the WLAN of terminal connection is when changing, if terminal with smart machine same
In one subnet, then terminal still directly communicates with smart machine in subnet;If terminal is with smart machine not in same subnet
Interior, then terminal forwards signal of communication with smart machine yet by external device.
The embodiment of the present invention is by judging that terminal whether in same subnet, preferentially selects to pass through subnet biography with smart machine
Defeated signal so that the control efficiency higher of terminal-pair smart machine.The system broadcasts changed simultaneously by monitoring wireless LAN,
In the case where WLAN does not change, original communication mode is performed, terminal is avoided to send control signal every time
When be required for determining that smart machine whether there is by way of broadcast in a wireless local area network, save the time and communication time
Number reduces the complexity of degree logic.
Referring to Fig. 5,50 embodiment of terminal of the present invention includes:
Processor 501, for judging that the network currently connected is mobile network or WLAN;If terminal currently connects
Whether the network connect is WLAN, then judge terminal with smart machine in same subnet;
First telecommunication circuit 502, it is directly logical with smart machine for when terminal and smart machine are in same subnet
Letter;When terminal and smart machine be not in same subnet, pass through the signal of communication between external device forwarding and smart machine.
Specifically, embodiment of the method for the communication means of terminal 50 referring to above-mentioned automatic switchover communication mode, herein no longer
It repeats.
The embodiment of the present invention is by judging that terminal whether in same subnet, preferentially selects to pass through subnet biography with smart machine
Defeated signal so that the control efficiency higher of terminal-pair smart machine.
Referring to Fig. 6,60 embodiment of smart machine of the present invention includes:
Second telecommunication circuit 601, for when the smart machine and terminal are in same subnet, with the smart machine
Direct communication;When the smart machine and terminal be not in same subnet, by between external device forwarding and the terminal
Signal of communication.
Specifically, embodiment of the method for the communication means of smart machine 60 referring to above-mentioned automatic switchover communication mode, herein
It repeats no more.
The embodiment of the present invention is by judging that terminal whether in same subnet, preferentially selects to pass through subnet biography with smart machine
Defeated signal so that the control efficiency higher of terminal-pair smart machine.
The foregoing is merely embodiments of the present invention, are not intended to limit the scope of the invention, every to utilize this
It is relevant to be directly or indirectly used in other for the equivalent structure or equivalent flow shift that description of the invention and accompanying drawing content are made
Technical field is included within the scope of the present invention.