Detailed Description
The technical solutions in 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 obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
Referring to fig. 1, an embodiment of the method for automatically switching communication modes according to the present invention includes:
s101, the terminal judges whether the currently connected network is a mobile network or a wireless local area network;
in this embodiment, the terminal may be a mobile phone, a tablet computer, or the like. The mobile network to which the terminal is connected may be a cellular mobile network, and the communication signal is forwarded through an external device, such as a base station, a server, etc. The WIreless lan to which the terminal is connected may be a WIreless network generated by a home router, such as WiFi (WIreless-Fidelity).
S102, if the network to which the terminal is currently connected is a wireless local area network, judging whether the terminal and the intelligent device are in the same subnet;
in this embodiment, whether the terminal and the intelligent device are in the same subnet may be determined by broadcasting a Service Set Identifier (SSID), querying an IP (Internet Protocol) address, and the like.
In this embodiment, the intelligent device may be an intelligent monitoring device, an intelligent security device, a digital cinema device, an intelligent lighting device, or the like.
S103, if yes, the terminal is in direct communication with the intelligent device;
and S104, if not, forwarding the communication signal between the terminal and the intelligent device through external equipment.
In this embodiment, the external device may be a base station, a server, or the like.
According to the embodiment of the invention, whether the terminal and the intelligent device are in the same subnet is judged, and the signal transmission through the subnet is preferentially selected, so that the control efficiency of the terminal on the intelligent device is higher.
Referring to fig. 2, an embodiment of the method for automatically switching communication modes according to the present invention includes:
s201, judging whether a network currently connected with a terminal is a mobile network or a wireless local area network;
in this embodiment, the mobile network to which the terminal is connected may be a cellular mobile network, and the communication signal is forwarded through an external device, such as a base station, a server, and the like. The wireless lan to which the terminal is connected may be a wireless network generated by a home router, such as WiFi or the like.
S202, if the network to which the terminal is currently connected is a wireless local area network, acquiring a service set identifier of the intelligent device;
in this embodiment, the terminal may receive the service set identifier of the smart device through the currently connected wireless lan, or may obtain the service set identifier of the smart device through other communication methods, such as bluetooth, a mobile network, and the like.
S203, if the network to which the terminal is currently connected is a mobile network, forwarding a communication signal between the terminal and the intelligent device through external equipment;
in this embodiment, the external device may be a server, the terminal and the server, and the intelligent device and the server are respectively connected through a mobile network, and the server forwards the communication signal to implement communication between the terminal and the intelligent device.
S204, judging whether the service set identifier of the intelligent equipment is empty or not;
in this embodiment, whether the service set identifier of the smart device is empty is determined by the service set identifier cache of the smart device.
S205, if the service set identifier of the intelligent device is not empty, judging whether the service set identifier of the terminal is the same as the service set identifier of the intelligent device;
s206, if the service set identifier of the intelligent device is empty or the service set identifier of the terminal is the same as the service set identifier of the intelligent device, judging whether a search mark (Last Found) is true;
in this embodiment, if the service set identifier of the smart device is empty, it cannot be determined whether the terminal and the smart device are in the same subnet, and it is still necessary to further determine whether the terminal and the smart device are in the same subnet by looking for the identifier.
S207, if the search mark is true, the terminal and the intelligent device are in the same subnet and can directly communicate; otherwise, returning to step S203, forwarding the communication signal between the terminal and the intelligent device through the outside.
In other embodiments, whether the terminal and the intelligent device are in the same subnet may also be determined by querying the IP address, for example, the terminal obtains the IP address of the intelligent device and compares the IP address with the IP address of the terminal, so as to determine whether the terminal and the intelligent device are in the same subnet.
Specifically, referring to fig. 3, the method for setting the search flag specifically includes:
s301, the terminal sends a broadcast in a currently connected subnet to search for intelligent equipment;
in this embodiment, the terminal searches for the smart device by sending a service set identifier broadcast.
S302, judging whether the intelligent equipment responds or not;
s303, if the intelligent equipment responds, setting the search mark to be true;
s304, if the intelligent device does not answer, setting the search mark as false.
In this embodiment, if the smart device and the terminal are in the same subnet, when the smart device receives a service set identifier broadcast sent by the terminal, a signal is fed back to the terminal, and at this time, the search flag is set to true; if the intelligent device and the terminal are not in the same subnet, the intelligent device cannot receive the service set identifier broadcast sent by the terminal and cannot feed back a signal, and at the moment, the searching mark is set to be false.
Referring to fig. 4, the present embodiment may further include:
s401, the terminal monitors system broadcast changed by the wireless local area network and judges whether the wireless local area network connected with the terminal is changed;
in this embodiment, the terminal monitors the system broadcast of the change of the wireless lan through software to determine whether the wireless lan is changed.
S402, if yes, judging whether the terminal and the intelligent device are in the same subnet;
in this embodiment, if the wlan connected to the terminal is changed, it needs to be determined again whether the terminal and the intelligent device are in the same subnet, that is, the step S201 is returned to, and the determining process is repeated.
And S403, otherwise, executing the original communication mode.
In this embodiment, when the wireless local area network connected to the terminal is not changed, if the terminal and the intelligent device are in the same subnet, the terminal and the intelligent device still directly communicate in the subnet; and if the terminal and the intelligent equipment are not in the same subnet, the terminal and the intelligent equipment still transmit the communication signal through the external equipment.
According to the embodiment of the invention, whether the terminal and the intelligent device are in the same subnet is judged, and the signal transmission through the subnet is preferentially selected, so that the control efficiency of the terminal on the intelligent device is higher. Meanwhile, by monitoring the system broadcast changed by the wireless local area network, the original communication mode is executed under the condition that the wireless local area network is not changed, the situation that whether the intelligent equipment exists in the wireless local area network is determined by the terminal in a broadcast mode every time the terminal sends the control signal is avoided, the time and the communication times are saved, and the complexity of degree logic is reduced.
Referring to fig. 5, an embodiment of a terminal 50 of the present invention includes:
a processor 501, configured to determine whether a currently connected network is a mobile network or a wireless local area network; if the network to which the terminal is currently connected is a wireless local area network, judging whether the terminal and the intelligent device are in the same subnet;
the first communication circuit 502 is used for directly communicating with the intelligent device when the terminal and the intelligent device are in the same subnet; and when the terminal and the intelligent equipment are not in the same subnet, transmitting the communication signal between the terminal and the intelligent equipment through the external equipment.
Specifically, the communication method of the terminal 50 refers to the above embodiment of the method for automatically switching the communication mode, and is not described herein again.
According to the embodiment of the invention, whether the terminal and the intelligent device are in the same subnet is judged, and the signal transmission through the subnet is preferentially selected, so that the control efficiency of the terminal on the intelligent device is higher.
Referring to fig. 6, an embodiment of the smart device 60 of the present invention comprises:
a second communication circuit 601, configured to directly communicate with the smart device when the smart device and the terminal are in the same subnet; and when the intelligent equipment and the terminal are not in the same subnet, forwarding a communication signal between the intelligent equipment and the terminal through external equipment.
Specifically, the communication method of the intelligent device 60 refers to the above embodiment of the method for automatically switching the communication mode, and is not described herein again.
According to the embodiment of the invention, whether the terminal and the intelligent device are in the same subnet is judged, and the signal transmission through the subnet is preferentially selected, so that the control efficiency of the terminal on the intelligent device is higher.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes performed by the present specification and drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.