Connection establishment method, device, terminal equipment and storage medium based on local area network
By determining the IP address of the target IOT device and establishing a connection based on the LAN, the problems of low connection establishment efficiency and difficulty in automatic reconnection in the existing technology are solved, and an efficient and intelligent LAN connection is realized, supporting long-term connection and low power consumption.
Patent Information
- Application Number
- CN202111067907.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-13
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-09-13
AI Technical Summary
The existing LAN-based connection establishment process is inefficient, requires user participation, and does not support automatic reconnection after the connection is abnormally disconnected, making it difficult to maintain a long-term connection.
By determining the IP address of the target IOT device that has been paired successfully and is in the same LAN, a connection based on the LAN is established, supporting automatic reconnection and long-term connection, avoiding cloud transfer and account system dependence.
Connections can be quickly established without user participation, improving connection efficiency and intelligence. It supports initial connection and automatic reconnection after abnormal disconnection, with high transmission efficiency and low power consumption.
Smart Images

Figure CN113873684B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of Internet of Things, and in particular to a method, apparatus, terminal device and storage medium for establishing a connection based on a local area network. Background Art
[0002] With the development of Internet of Things technology, LAN-based connections have provided great convenience for business scenarios such as cross-terminal execution of intelligent voice commands and message and file transfer between devices.
[0003] At present, the process of establishing a connection based on a LAN includes: the terminal device registers and discovers services in the current LAN, finds multiple Internet of Things (IoT) devices in the same LAN, and then the user selects a target IoT device from the multiple IoT devices, and the terminal device establishes a connection based on the LAN with the target IoT device.
[0004] However, when the connection is abnormally disconnected and needs to be re-established, the connection still needs to be established through the above process, that is, each time a connection is established, user participation is required, so the efficiency of the above LAN-based connection establishment process is low. Summary of the invention
[0005] The embodiments of the present application provide a method, apparatus, terminal device and storage medium for establishing a connection based on a local area network to solve the problem of low efficiency of the existing connection establishment process based on a local area network.
[0006] A first aspect of an embodiment of the present application provides a method for establishing a connection based on a local area network, which is applied to a terminal device. The method includes: determining a target IOT device, which meets the following conditions: it has been successfully paired with the terminal device and is currently in the same local area network as the terminal device; and establishing a connection based on a local area network with the target IOT device according to the IP address of the target IOT device.
[0007] According to a second aspect of an embodiment of the present application, a connection establishment device based on a local area network is provided, the device comprising: a determination module and an establishment module; the determination module is used to determine a target IOT device, and the target IOT device satisfies the following conditions: it has been successfully paired with the terminal device and is currently in the same local area network as the terminal device; the establishment module is used to establish a connection based on the local area network with the target IOT device according to the IP address of the target IOT device.
[0008] According to a third aspect of an embodiment of the present application, a terminal device is provided, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method for establishing a connection based on a local area network as described in the first aspect.
[0009] According to a fourth aspect of an embodiment of the present application, a readable storage medium is provided, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method for establishing a connection based on a local area network as described in the first aspect are implemented.
[0010] In a fifth aspect of an embodiment of the present application, a chip is provided, which includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the local area network-based connection establishment method as described in the first aspect.
[0011] In the embodiment of the present application, the target IOT device can be determined; according to the IP address of the target IOT device, a connection based on a local area network is established with the target IOT device; wherein the target IOT device satisfies the following conditions: it has been successfully paired with the terminal device and is currently in the same local area network as the terminal device. In this solution, the terminal device can establish a connection based on a local area network with the target IOT device that has been successfully paired and is in the same local area network, thereby eliminating the need for user participation, simplifying the process of establishing a connection based on a local area network, improving the efficiency of establishing a connection based on a local area network, and improving the intelligence of establishing a connection based on a local area network. In addition, this solution supports both the scenario of establishing a connection based on a local area network for the first time and the scenario of automatically reconnecting after an abnormal disconnection of a connection based on a local area network, and can maintain a long-term connection. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments and the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and other drawings can be obtained based on these drawings.
[0013] Figure 1 A schematic diagram of the structure of a connection system based on a local area network provided in an embodiment of the present application;
[0014] Figure 2A One of the flow charts of the method for establishing a connection based on a local area network provided in an embodiment of the present application;
[0015] Figure 2B A second flowchart of a method for establishing a connection based on a local area network provided in an embodiment of the present application;
[0016] Figure 2CA third flowchart of a method for establishing a connection based on a local area network provided in an embodiment of the present application;
[0017] Figure 2D A fourth flowchart of a method for establishing a connection based on a local area network provided in an embodiment of the present application;
[0018] Figure 3 A fifth flowchart of a method for establishing a connection based on a local area network provided in an embodiment of the present application;
[0019] Figure 4 Flow chart six of the method for establishing a connection based on a local area network provided in an embodiment of the present application;
[0020] Figure 5 Flow chart of the method for establishing a connection based on a local area network provided in an embodiment of the present application, No. 7;
[0021] Figure 6 A structural block diagram of a local area network-based connection establishment device provided in an embodiment of the present application;
[0022] Figure 7 A schematic diagram of the hardware structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0024] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0025] At present, there are two solutions for long-term connection of devices. One is to configure the network for IOT devices, connect with the account system, and complete the communication between devices by pushing messages through the cloud; the other is to adopt the peer-to-peer (p2p) direct connection mode to communicate directly between two devices.
[0026] However, the method of pushing messages through the cloud relies on the account system, which is not friendly to scenarios where the terminal device and IoT device are from different manufacturers, and the communication needs to be transferred through the cloud, which has low transmission efficiency, especially in the scenario of large data transmission. The direct P2P direct connection mode is not easy to reconnect when disconnected, and there is a problem of high power consumption if a long connection is maintained.
[0027] The existing technology also has connections based on local area networks. The process of establishing a connection requires human participation, is not intelligent enough, does not support automatic reconnection, and the efficiency of the connection establishment process is low.
[0028] In order to solve the above problems, in the embodiment of the present application, the target IOT device can be determined; according to the IP address of the target IOT device, a connection based on a local area network is established with the target IOT device; wherein the target IOT device satisfies the following conditions: it has been successfully paired with the terminal device and is currently in the same local area network as the terminal device. In this solution, the terminal device can establish a connection based on a local area network with the target IOT device that has been successfully paired and is in the same local area network, thereby eliminating the need for user participation, simplifying the process of establishing a connection based on a local area network, improving the efficiency of establishing a connection based on a local area network, and improving the intelligence of establishing a connection based on a local area network. Moreover, this solution supports the scenario of establishing a connection based on a local area network for the first time, and supports the scenario of automatic reconnection after an abnormal disconnection of a connection based on a local area network, and can maintain a long-term connection. Moreover, the connection based on a local area network in the embodiment of the present application does not need to be transferred through the cloud, does not rely on the account system, has a high transmission efficiency, is easy to reconnect compared to the P2p direct connection mode, and has low power consumption for maintaining a long connection.
[0029] first, Figure 1 This is a connection system based on a local area network shown in an embodiment of the present application. Figure 1 As shown, the LAN-based connection system includes: a router device 10, at least one terminal device 11 and at least one IOT device 12; the figure takes the terminal device 11 as a mobile phone and the IOT device 12 as a TV as an example. The terminal device 11 and the IOT device 12 establish a LAN-based connection based on the router device 10. In the embodiment of the present application, the LAN-based connection refers to a connection based on the same LAN, that is, the terminal device 11 and the IOT device are in the same LAN.
[0030] The terminal device in the embodiment of the present application can be a mobile terminal device or a non-mobile terminal device. The mobile terminal device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc.; the non-mobile terminal device can be a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc.; the embodiment of the present application does not specifically limit it. It should be noted that in the embodiment of the present application, the terminal device is an IOT device.
[0031] In the embodiments of the present application, the IOT device may be a mobile terminal device such as a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal device, a wearable device, a UMPC, a netbook, or a PDA, or may be a non-mobile terminal device such as a PC, a TV, a teller machine, or a self-service machine; the embodiments of the present application do not specifically limit this. The target IOT device and the terminal device may be IOT devices of the same type or different types, which is not limited in the embodiments of the present application.
[0032] The executor of the LAN-based connection establishment method provided in the embodiment of the present application can be the above-mentioned terminal device (including mobile terminal devices and non-mobile terminal devices), or it can be a functional module and / or functional entity in the terminal device that can implement the LAN-based connection establishment method. The specific execution can be determined according to actual usage requirements, and the embodiment of the present application is not limited.
[0033] The following is a detailed description of the local area network-based connection establishment method provided by the embodiment of the present application through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0034] like Figure 2A As shown, the embodiment of the present application provides a method for establishing a connection based on a local area network. The following takes the execution subject as a terminal device as an example to exemplarily illustrate the method for establishing a connection based on a local area network provided by the embodiment of the present application. The method may include the following steps 201 to 202.
[0035] 201. The terminal device determines a target IOT device.
[0036] Among them, the target IOT device meets the following conditions: it has been successfully paired with the terminal device and is currently in the same local area network as the terminal device.
[0037] In the embodiment of the present application, the device that has been successfully paired with the terminal device is a device that has established trust with the terminal device through pairing (for example, fast pairing, OPlus Framework Accessory (OAF) fast pairing, Google fast pairing, Bluetooth pairing, etc., which are not limited in the embodiment of the present application.), and a connection based on a local area network can be established between the two. Therefore, a connection based on a local area network can be established through the method for establishing a connection based on a local area network provided in the embodiment of the present application.
[0038] Among them, if two IOT devices (such as a terminal device and a target IOT device) are paired successfully, the trust credentials required to establish a connection channel based on a local area network are generated for the two IOT devices. For example, during the OAF fast pairing process, a secret key for data transmission can be generated between the terminal device and the target IOT device based on the OAF protocol, so that the connection based on the local area network established based on the OAF fast pairing can ensure the security of data transmission during data transmission through the OAF channel.
[0039] It can be understood that the target IOT device can meet other conditions in addition to the above conditions, and the embodiments of the present application are not limited. For example, the target IOT device can also have the performance of establishing a connection based on a LAN with other IOT devices, and the target IOT device can also have the performance of supporting LAN reconnection. Among them, LAN reconnection refers to the terminal device determining the target IOT device and establishing a LAN-based connection with the target IOT device based on the instruction triggered by the user to establish a LAN-based connection between the terminal device and other devices. After that, when the LAN-based connection is abnormally disconnected (the terminal device and the target IOT device are still in the same LAN, the abnormal disconnection may be shutdown or application crash, etc.) or the terminal device is in the same LAN with the target IOT device again, the terminal device can automatically reconnect to the target IOT device on the LAN to re-establish a LAN-based connection with the target IOT device (no user instruction is required to establish a LAN-based connection, that is, automatically establish a LAN-based connection).
[0040] It can be understood that when a terminal device joins a local area network and needs to establish a LAN-based connection with other IOT devices in the LAN, the terminal device searches for IOT devices with which it can establish a LAN-based connection. When the terminal device searches for an IOT device that has been successfully paired in the LAN, the IOT device is determined as the target IOT device.
[0041] In the embodiments of the present application, the scenario in which the terminal device needs to establish a LAN-based connection with other IOT devices in the LAN where the terminal device is located includes at least one of the following: the terminal device switches from one LAN to another, the terminal device has established a LAN-based connection with other IOT devices in the current LAN, the terminal device is powered off and restarted, the corresponding application in the terminal device crashes and then restarts (for example, the OAF process restarts), and a user instruction is received to trigger the terminal device to establish a LAN-based connection. The scenario in which the terminal device needs to establish a LAN-based connection with other IOT devices in the LAN where the terminal device is located may also include other feasible scenarios, which are not limited by the embodiments of the present application.
[0042] 202. The terminal device establishes a connection with the target IOT device based on a local area network according to the IP address of the target IOT device.
[0043] In the embodiment of the present application, the connection based on the local area network can be a long connection based on the local area network, or it can be a short connection based on the local area network, and the embodiment of the present application does not limit it.
[0044] In an embodiment of the present application, a terminal device can quickly establish a connection based on a local area network with an IoT device that has been successfully paired and is in the same local area network.
[0045] In the embodiments of the present application, a local area network (LAN) is a computer communication network that connects various computers, external devices, and databases within a local geographical area (such as a school, factory, or office). It can be connected to a remote local area network, database, or processing center through a data communication network or a dedicated data circuit to form a large-scale information processing system. The local area network can be a local area network established based on routing settings, or a local area network established based on wired network, infrared, etc. settings; the embodiments of the present application do not limit this.
[0046] Optionally, the above-mentioned successful pairing with the terminal device specifically refers to: successful OAF fast pairing with the terminal device; the above-mentioned step 202 can be specifically implemented through the following step 202a.
[0047] 202a. Establish an OAF channel with the target IOT device according to the IP address of the target IOT device to establish a connection based on the local area network.
[0048] It can be understood that when an IOT device satisfies the conditions that it has successfully performed OAF quick pairing with the terminal device and is currently in the same local area network as the terminal device, the terminal device can determine the IOT device as the target IOT device, and then establish an OAF channel with the target IOT device based on the IP address of the target IOT device. In this way, the terminal device and the target IOT device establish a connection based on the local area network.
[0049] In the embodiment of the present application, when the terminal device and the target IOT device have performed OAF fast pairing and are in the same local area network, a connection based on the local area network is established by establishing an OAF channel. Not only can the security of data transmission be guaranteed by the key generated by the OAF fast pairing; but also the channel established based on OAF is encapsulated in the OAF framework, which simplifies the access process of upper-layer services (data transmission between device applications), that is, simplifies the process of establishing the connection channel between devices, and improves the efficiency of establishing a connection based on the local area network; furthermore, the OAF framework is separated from the application, and different applications can reuse the OAF framework, so there is no need to integrate a communication interface with the corresponding function (establishing a connection channel between devices) in the application, which simplifies the complexity of the application.
[0050] Optionally, combined Figure 2A ,like Figure 2B As shown, the above step 201 can be specifically implemented through the following steps 201a to 201b.
[0051] 201a. The terminal device performs service discovery in the local area network.
[0052] Optionally, in an embodiment of the present application, service discovery can be based on an application program interface (API) to listen to service broadcasts on the local network to view available services (Discover services on the network, NSD Discovery), for example, service discovery based on API NSD Discovery under the Android system, and can also be service discovery based on API NSD Discovery under other systems; it can also be other service discoveries, which are not limited in the embodiments of the present application.
[0053] 201b. When the terminal device finds at least one IOT device through the service discovery, the terminal device determines the target IOT device from the at least one IOT device according to the connection information stored by the terminal device.
[0054] The connection information includes at least one piece of pairing information, and each piece of pairing information is used to indicate a device that has been successfully paired with the terminal device.
[0055] It can be understood that the connection information includes pairing information between the terminal device and the target IOT device. Each of the at least one IOT device is a device that has registered for service in the local area network where the terminal device is located, and can establish a local area network-based connection with other IOT devices in the local area network. Exemplarily, each IOT device has registered a service on the local network based on an API (Register your service on the network, NSD Register), so that it can provide connections to other devices on the network.
[0056] Exemplarily, if the terminal device has the performance of supporting the connection based on the local area network provided by the embodiment of the present application, the terminal device can monitor the network status in real time. When the terminal device detects that the terminal device has joined a local area network, the terminal device can call the API NSD Discovery of the Android system for service discovery, find at least one IOT device that has been API NSD Registered in the local area network, and determine the IOT device that has been successfully paired with the terminal device in the at least one IOT device as the target IOT device, and then obtain the IP address of the target IOT device, and complete the establishment of the OAF channel with the target IOT device based on the IP address, that is, complete the establishment of the connection based on the local area network.
[0057] Optionally, in the embodiment of the present application, the connection based on the LAN can be a technical solution for the connection based on the OAF channel, or a technical solution for the connection not based on the OAF channel. Among them, the technical solution for the connection not based on the OAF channel can encapsulate the ability to support the connection based on the LAN and the ability to connect back based on the LAN connection in the Software Development Kit (SDK) interface. In this way, when there is a need for connection and communication based on the LAN between the terminal device and any IOT device that supports NSD, it can be realized by only integrating the SDK with the corresponding application, adding relevant configurations and initializing.
[0058] Optionally, before the above step 201, the LAN-based connection establishment method provided in the embodiment of the present application may further include the following steps 203 to 204.
[0059] 203. When pairing with the target IOT device is successful, obtain a configuration file corresponding to the target IOT device.
[0060] The configuration file is used to indicate whether the target IOT device supports connection based on a local area network.
[0061] In the embodiment of the present application, the terminal device can obtain the configuration file corresponding to the target IoT device from multiple configuration files stored locally, and each of the multiple configuration files is used to indicate whether an IoT device supports connection based on a local area network. The multiple configuration files can be built into the terminal device when the terminal device leaves the factory, or can be issued by the server to the terminal device.
[0062] Among them, the server sends the multiple configuration files to the terminal device, and the server can re-send the corresponding configuration files according to the actual situation (if some IOT devices change from supporting LAN-based connections to supporting LAN-based connections, or some IOT devices change from supporting LAN-based connections to not supporting LAN-based connections, etc.), so that the terminal device updates the multiple configuration files. Moreover, the solution of the server sending the multiple configuration files to the terminal device can facilitate the dynamic control of the switch of the LAN-based connection through the server, as well as the personalized customization of the parameters of the LAN-based connection.
[0063] 204. When it is determined according to the configuration file that the target IOT device supports connection based on a local area network, the terminal device saves pairing information with the target IOT device into the connection information.
[0064] The pairing information includes the device identification of the target IOT device, such as the identity document (ID) of the IOT device, and the fact that the terminal device has been successfully paired with the target IOT device.
[0065] It can be understood that in the embodiment of the present application, when the terminal device is successfully paired with the target IOT device, if it is detected that the IOT device supports a connection based on a LAN, the pairing information with the target IOT device can be saved to the connection information. This makes it convenient for the terminal device to determine the target IOT device from at least one IOT device found through service discovery based on the connection information, and then complete the establishment of a connection channel based on a LAN with the target IOT device to establish a connection based on a LAN. (For example, when the OAF process is restarted, the terminal device determines the target IOT device through service discovery, and then establishes an OAF channel with the target IOT device). Similarly, if the target IOT device detects that the terminal device supports a connection based on a LAN, the pairing information with the terminal device can also be saved to the corresponding connection information. In this way, when the target IOT device needs to establish a connection based on a LAN, it is convenient to find the terminal device through service discovery, thereby establishing a connection based on a LAN with the terminal device.
[0066] In an embodiment of the present application, when the terminal device determines that the IOT device supports a connection based on a local area network, the pairing information with the target IOT device can be saved to the link information, so that the terminal device and the target IOT device can subsequently quickly establish a connection based on a local area network, thereby improving the efficiency of establishing a connection between the two.
[0067] Optionally, in an embodiment of the present application, it can be assumed that all IOT devices that can be found through service discovery support connections based on a local area network, or it can be assumed that all IOT devices support connections based on a local area network. In this way, the above steps 203 to 204 can be replaced by the terminal device saving the pairing information with the target IOT device to the connection information when pairing with the target IOT device is successful.
[0068] Optionally, before the above step 202, the LAN-based connection establishment method provided in the embodiment of the present application may further include the following step 205.
[0069] 205. The terminal device obtains the IP address of the target IoT device through the service discovery.
[0070] Optionally, the terminal device may receive the IP address of the target IOT device broadcasted by the target IOT device during the service discovery process.
[0071] For example, the NSD service is based on the Multicast DNS (MDNS) protocol. If a device has the MDNS service enabled, when the device joins a local area network, it will multicast a message to all devices in the local area network, and the message includes the IP address of the device. Therefore, if the service discovery is based on the NSD Service, the terminal device can receive the IP address of the target IOT device broadcast by the target IOT device during the service discovery process based on the NSD Service.
[0072] Optionally, during the service discovery process, the terminal device establishes a connection with the target IOT device and obtains the IP address of the target IOT device.
[0073] In the embodiment of the present application, the process of the terminal device discovering and obtaining the IP address of the target IOT device through the service can also refer to the existing related technology, and the embodiment of the present application is not limited.
[0074] In the embodiment of the present application, after the terminal device obtains the IP address through the service discovery, it can quickly establish a local area network-based connection with the target IOT device based on the IP address.
[0075] Optionally, combined Figure 2B ,like Figure 2C As shown, after the above step 201a, the LAN-based connection establishment method provided in the embodiment of the present application may further include the following steps 206 to 207.
[0076] 206. When the terminal device finds that no IOT device is found through the service, it establishes a short-range wireless communication connection with the first IOT device.
[0077] Short-range wireless communication technologies may include: Near Field Communication (NFC), Radio Frequency Identification (RFID), Bluetooth, ZigBee, infrared and other technologies.
[0078] In the embodiment of the present application, the short-range wireless communication connection can be: Bluetooth Low Energy (Bluetooh LowEnergy, BLE) connection, Classic Bluetooth connection (Classic Bluetooth, BT), NFC connection, etc., which is not limited in the embodiment of the present application. The establishment of a specific short-range wireless communication connection can refer to relevant short-range wireless communication technologies, which is not limited in the embodiment of the present application.
[0079] In the embodiment of the present application, the connection based on the local area network has a fast transmission speed and a wide coverage compared to the short-range wireless communication connection (such as Bluetooth connection, etc.).
[0080] The first IOT device is a device that has been successfully paired with the terminal device.
[0081] 207. When the terminal device determines through the short-range wireless communication connection that the terminal device and the first IOT device are both in the local area network, the first IOT device is determined as the target IOT device.
[0082] It can be understood that in the embodiments of the present application, through a large number of stress testing experiments, it is found that in stress testing scenarios, the above service discovery may not be able to find IOT devices, that is, the above service discovery may fail to find devices (for example, in a large number of stress testing scenarios, due to the defects of the API itself, the NSD API may not be able to stably return the devices registered for services in the local area network). In this way, in order to ensure that a connection based on the local area network can be established, the embodiments of the present application determine the target IOT device through a short-range wireless communication connection, and obtain the IP address of the target IOT device, so as to facilitate the establishment of a local area network-based connection with the target IOT device based on the IP address.
[0083] In an embodiment of the present application, when no IOT device is found through the service discovery, the target IOT device and the IP address of the target IOT device are determined through a short-range wireless communication connection, thereby ensuring that a connection based on a local area network can be achieved.
[0084] In the embodiment of the present application, the establishment of a connection based on a local area network can be better guaranteed by utilizing an encrypted channel of BLE (ie, a BLE connection) with a high and stable connection success rate.
[0085] Optionally, before the above step 202, the LAN-based connection establishment method provided in the embodiment of the present application may further include the following step 208.
[0086] 208. The terminal device obtains the IP address through the short-range wireless communication connection.
[0087] It can be understood that the terminal device can receive the IP address from the target IOT device through the short-range wireless communication connection, and thus quickly establish a local area network-based connection with the target IOT device based on the IP address.
[0088] Optionally, combined Figure 2C ,like Figure 2D As shown, before the above step 207, the LAN-based connection establishment method provided in the embodiment of the present application may further include the following steps 209 to 210.
[0089] 209. The terminal device sends the MAC address and subnet mask of the terminal device in the local area network to the first IOT device through the short-range wireless communication connection.
[0090] The media access control (MAC) address and the subnet mask are used by the first IOT device to determine whether it is in the same local area network as the terminal device.
[0091] It can be understood that the MAC address and subnet mask under the local area network are the MAC address and subnet mask of the wireless access point (AP) to which the terminal device is currently connected. After receiving the MAC address and subnet mask, the first IOT device verifies the MAC address and subnet mask with the MAC address and subnet mask of the AP to which the first IOT device is currently connected. If the verification passes, the first IOT device determines that it is in the same local area network as the terminal device; otherwise, the first IOT device determines that it is not in the same local area network as the terminal device.
[0092] 210. The terminal device receives a reply message from the first IOT device through the short-range wireless communication connection.
[0093] The reply message is used to indicate that the first IOT device and the terminal device are in the same local area network.
[0094] For example, Figure 3 As shown, the above steps 209 to 210 can be specifically implemented through the following steps 301 to 305.
[0095] 301. The terminal device obtains the MAC address of the currently connected AP (recorded as MAC address 1) and the subnet mask of the currently connected AP (recorded as subnet mask 1).
[0096] The terminal device may also obtain the IP address of the current terminal device (recorded as IP address 1) or may not obtain IP address 1, which is not limited in the embodiment of the present application.
[0097] 302. The first IOT device obtains the MAC address of the currently connected AP (recorded as MAC address 2) and the subnet mask of the currently connected AP (recorded as subnet mask 2), and the current IP address of the first IOT device (recorded as IP address 2).
[0098] It should be noted that the first IOT device may also obtain the IP address 2 before the following step 305, for example, when it is determined in the following step 304 that the terminal device and the first IOT device are in the same local area network, the IP address 2 is obtained.
[0099] 303. The terminal device sends MAC address 1 and subnet mask 1 to the first IOT device.
[0100] The terminal device may also send IP address 1 to the first IOT device, or may not send IP address 1, which is not limited in the embodiment of the present application.
[0101] 304. The first IOT device verifies the received MAC address 1 and subnet mask 1 with the received MAC address 2 and subnet mask 2. If the verification passes, it indicates that the first IOT device and the terminal device are in the same local area network.
[0102] If the verification fails, it means that the first IOT device and the terminal device are not in the same local area network.
[0103] 305. The first IOT device sends a reply message to the terminal device.
[0104] The reply message is used to indicate that the first IOT device and the terminal device are in the same local area network, and the reply message carries the IP address 2 of the first IOT device.
[0105] Optionally, the above steps 209 to 210 can be replaced by: the terminal device receives the MAC address, subnet mask and IP address of the first IOT device in the local area network sent by the first IOT device through the short-range wireless communication connection; the terminal device verifies the MAC address and subnet mask of the first IOT device with the MAC address and subnet mask of the terminal device in the local area network where the terminal device is located, and if the verification passes, it is determined that it is in the same local area network as the first IOT device; otherwise, it is determined that it is not in the same local area network as the first IOT device. The specific process can refer to the relevant description of the above steps 301 to 305, which will not be repeated here.
[0106] In an embodiment of the present application, the terminal device determines that the first IOT device and the terminal device are in the same local area network through a short-range wireless communication connection with the first IOT device, and can obtain the IP address of the first IOT device, thereby ensuring the rapid establishment of a connection based on the local area network.
[0107] Optionally, in the embodiment of the present application, the terminal device may not perform the service discovery process, but directly determine the target IoT device through a short-range wireless communication connection, and then establish a local area network-based connection with the target IoT device based on the IP address of the target IoT device. The specific description of steps 206 to 210 above will not be repeated here.
[0108] Optionally, after the terminal device joins a local area network, for example, before the above step 201 or after the above step 201, the local area network-based connection establishment method provided in the embodiment of the present application may further include the following step 211.
[0109] 211. The terminal device registers for services in the local area network.
[0110] The terminal device can define its own service name, port number and other information, call the Android system API NSDRegister, and register the service in the local area network so that other devices joining the local area network can discover it.
[0111] Similarly, after joining the LAN, the target IOT device can also define its own service name, port number and other information, call the Android system API NSD Register, and register the service in the LAN so that other devices joining the LAN can discover it.
[0112] In the embodiment of the present application, the terminal device and the target IOT device register for services in the same local area network, and then both devices can allow the other party to find themselves through service discovery, so that they can try to establish a connection based on the local area network with other devices based on the connection information, thereby ensuring the establishment of a connection channel based on the local area network. For example, using the NSD service (Servie) API provided by the Android system, NSDRegister and NSD discovery are performed between two devices that need to establish a connection based on the local area network. Then, both devices can allow the other party to find themselves through NSD discovery, and can find each other through NSD discovery, and when the process is restarted, they try to establish a connection based on the local area network through the recorded connection information, thereby ensuring that the channel can be established normally.
[0113] Optionally, after the above step 202, the LAN-based connection establishment method provided in the embodiment of the present application may further include the following step 212.
[0114] 212. The terminal device maintains the connection based on the LAN through a heartbeat mechanism.
[0115] It can be understood that the heartbeat mechanism requires the local device to send a heartbeat packet to the peer device at regular intervals, and the peer device replies after receiving the heartbeat packet to detect the online status of the device. Therefore, the terminal device can maintain the connection status based on the LAN through the heartbeat mechanism.
[0116] For example, Figure 4 As shown, the process of maintaining a connection based on a local area network between the terminal device and the target IOT device through a heartbeat mechanism is shown in the following steps 401 to 404.
[0117] 401. The terminal device sends a heartbeat mechanism initialization parameter (Heartbeat init) to the target IOT device.
[0118] 402. The target IoT device sends a heartbeat mechanism initialization parameter response to the terminal device.
[0119] The target IOT device receives the Heartbeat init sent by the terminal device, and replies to the terminal device with a Heartbeat init response based on the Heartbeat init. In this way, the heartbeat parameters of the heartbeat mechanism are negotiated between the terminal device and the target IOT device. After the target IOT device replies with the Heartbeat init response, it waits for the terminal device to send a heartbeat packet (Heartbeat).
[0120] Then, the following steps 403 to 404 are repeated between the terminal device and the target IOT device until the connection based on the local area network between the terminal device and the target IOT device is disconnected, and the heartbeat mechanism ends.
[0121] 403. The terminal device sends a heartbeat packet to the target IoT device.
[0122] After receiving the Heartbeat init response from the target IoT device, the terminal device sends a heartbeat packet to the target IoT device.
[0123] 404. The target IoT device sends a heartbeat packet response to the terminal device.
[0124] After receiving the heartbeat packet sent by the terminal device, the target IOT device replies a Heartbeatresponse to the terminal device, so that the terminal device determines that the connection based on the LAN is maintained between the target IOT device and the terminal device.
[0125] It should be noted that in the embodiment of the present application, the heartbeat mechanism between the terminal device and the target IOT device can also be initiated by the target IOT device, that is, the target IOT device sends a Heartbeat init to the terminal device, and the terminal device replies with a Heartbeat init response; the target IOT device sends a Heartbeat to the terminal device, and the terminal device replies with a Heartbeat response.
[0126] In the embodiment of the present application, the terminal device can maintain a connection based on the local area network through a heartbeat mechanism to determine whether there is an abnormality in the connection status with the target IOT device.
[0127] Terminal equipment manufacturers often have requirements for power consumption. In some low-power scenarios, such as low battery or screen-off state, some scheduled tasks will be aligned to a certain time point for unified execution. This will cause the established channel to be abnormally disconnected because the heartbeat packet cannot be sent and received in time.
[0128] For example, the target IOT device is in the off-screen state, the Heartbeat response is delayed, and if the terminal device does not receive the Heartbeat response after the timeout, it will try to resend the heartbeat packet to verify whether the connection with the target IOT device is disconnected. The terminal device resends the heartbeat packet (Heartbeat retry). If the Heartbeat response is received within the scheduled time, the attempt to resend the heartbeat packet is successful (retry Success), and the heartbeat packet can continue to be sent according to the original heartbeat parameters; if the Heartbeat response is not received after the timeout (within the scheduled time), the attempt to resend the heartbeat packet fails (retry Fail).
[0129] In order to solve the above problem, when one end device is in low power consumption, the heartbeat parameters of the heartbeat mechanism can be adjusted through messages to ensure that heartbeat packets can be sent and received normally, thereby maintaining the connection based on the LAN.
[0130] Exemplarily, after the above step 202, the LAN-based connection establishment method provided by the embodiment of the present application may further include the following step 213. In other words, during the above step 212, the LAN-based connection establishment method provided by the embodiment of the present application may further include the following step 213.
[0131] 213. In the process of maintaining the connection based on the local area network through the heartbeat mechanism, if the terminal device detects that the terminal device is in the target scene, the heartbeat parameters of the heartbeat mechanism are adjusted to ensure the normal operation of the heartbeat mechanism.
[0132] Among them, the target scenario is the screen-off scenario, or the scenario where the remaining power of the terminal device is less than or equal to the power threshold.
[0133] Among them, the heartbeat parameter can be the frequency of sending the heartbeat packet, or the time interval of sending the heartbeat packet. The power threshold can be determined according to actual use requirements, and the embodiment of the present application does not limit it. The power threshold can be a percentage, such as 20%. The target scene can also be other low-power consumption scenes, and the embodiment of the present application does not limit it.
[0134] It can be understood that if the terminal device detects that the terminal device is in the target scenario, it can negotiate new heartbeat parameters with the target IOT device through messages, or the terminal device and the target IOT device have previously negotiated the heartbeat parameters for the target scenario. At this time, it only needs to send a message to notify the other device to adjust to the heartbeat parameters in the target scenario to match the delay of the terminal device in the low power consumption scenario.
[0135] For example, Figure 5As shown, the above step 213 can be specifically implemented through the following steps 501 to 509.
[0136] 501. The terminal device detects that the terminal device is in a screen-off state, and sends a first adjustment parameter message to a target IOT device.
[0137] Among them, the first parameter adjustment message is used to indicate that the terminal device is currently in the screen off state, and the terminal device has updated the heartbeat parameters (adjusted to the heartbeat parameters in the screen off state. The heartbeat parameters in the screen off state can be determined according to actual usage requirements, and are not limited in the embodiments of the present application), requiring the target IOT device to synchronously adjust the heartbeat parameters.
[0138] Optionally, in an embodiment of the present application, the heartbeat parameters in the screen off state may be those previously negotiated between the terminal device and the target IOT device. After the target IOT device receives the first adjustment parameter message, it obtains the heartbeat parameters in the screen off state stored locally in the target IOT device, and updates the current heartbeat parameters according to the heartbeat parameters in the screen off state; the heartbeat parameters in the screen off state may also be those sent by the terminal device to the target IOT device via the first adjustment parameter message (i.e., the first adjustment parameter message carries the heartbeat parameters in the screen off state). After the target IOT device receives the first adjustment parameter message, it obtains the heartbeat parameters in the screen off state from the first adjustment parameter message, and updates the current heartbeat parameters according to the heartbeat parameters in the screen off state; this is not limited to the embodiments of the present application.
[0139] 502. The terminal device sends a heartbeat packet to the target IoT device using the heartbeat parameters in the screen-off state.
[0140] Correspondingly, the target IOT device receives the heartbeat packet sent by the terminal device with the heartbeat parameters in the screen-off state.
[0141] 503. The target IOT device sends a heartbeat response to the terminal device using the heartbeat parameters in the screen-off state.
[0142] When the terminal device is in the screen-off state, the terminal device and the target IOT device cyclically execute the above steps 502 to 503 to maintain the heartbeat mechanism with the heartbeat parameters in the screen-off state.
[0143] 504. The terminal device detects that the terminal device is in a screen-on state, and sends a first message to the target IOT device.
[0144] Among them, the first message is used to indicate that the terminal device is currently in the screen on state, and to ask the target IOT device whether it is necessary to adjust the heartbeat parameters to the heartbeat parameters in the screen on state (adjusted to the heartbeat parameters in the screen on state, the heartbeat parameters in the screen on state can be determined according to actual usage requirements, and are not limited in the embodiments of the present application).
[0145] 505. After receiving the first message, the target IOT device detects whether the target IOT device is currently in a screen-on state.
[0146] If the target IOT device detects that the target IOT device is in the screen-on state, then execute the following steps 506 to 508; if the target IOT device detects that the target IOT device is in the screen-off state, then execute the following steps 509 to 511.
[0147] 506. The target IOT device detects that the target IOT device is in a screen-on state, and sends a second adjustment parameter message to the terminal device.
[0148] Among them, the second parameter adjustment message is used to indicate that the target IOT device is currently in the screen-on state, and the heartbeat parameters have been updated to the heartbeat parameters in the screen-on state, requiring the terminal device to synchronously adjust the heartbeat parameters.
[0149] Optionally, the heartbeat parameters in the screen-on state may be those negotiated beforehand between the terminal device and the target IOT device; or they may be sent via a second adjustment parameter message (ie, the second adjustment parameter message carries the heartbeat parameters in the screen-on state); this is not limited in the embodiments of the present application.
[0150] Correspondingly, the terminal device receives the second parameter adjustment message and updates the current heartbeat parameters according to the heartbeat parameters in the screen-on state.
[0151] 507. The terminal device sends a heartbeat packet to the target IOT device with the heartbeat parameters in the screen-on state.
[0152] Correspondingly, the target IOT device receives the heartbeat packet sent by the terminal device with the heartbeat parameters in the screen-on state.
[0153] 508. The target IoT device sends a heartbeat response to the terminal device using the heartbeat parameters in the screen-on state.
[0154] Correspondingly, the terminal device receives the heartbeat response sent by the target IOT device with the heartbeat parameters in the screen-on state.
[0155] When both the terminal device and the target IOT device are in the screen-on state, the terminal device and the target IOT device cyclically execute the above steps 507 to 508 to maintain the heartbeat mechanism with the heartbeat parameters in the screen-on state.
[0156] 509. The target IOT device detects that the target IOT device is in a screen-off state, and sends a second message to the terminal device.
[0157] Among them, the second message is used to indicate that the target IOT device is currently in the screen-off state and still needs to maintain the heartbeat parameters in the screen-off state.
[0158] Correspondingly, the terminal device receives the second message, and according to the second message, keeps sending heartbeat packets to the target IOT device with the heartbeat parameters in the off-screen state. After the target IOT device receives the heartbeat packet sent by the terminal device with the heartbeat parameters in the off-screen state, it sends a heartbeat response to the terminal device with the heartbeat parameters in the off-screen state.
[0159] 510. The terminal device sends a heartbeat packet to the target IOT device using the heartbeat parameters in the screen-off state.
[0160] 511. The target IoT device sends a heartbeat response to the terminal device using the heartbeat parameters in the screen-off state.
[0161] The terminal device and the target IOT device cyclically execute the above steps 510 to 511 to maintain the heartbeat mechanism with the heartbeat parameters in the screen-off state.
[0162] It should be noted that if the target IOT device is in a low power consumption scenario, the target IOT device can also actively adjust the heartbeat parameters of the heartbeat mechanism through messages to match the delay of the target IOT device in the low power consumption scenario. The specific process can be referred to the above description and will not be repeated here.
[0163] In an embodiment of the present application, the present solution supports dynamic adjustment of heartbeat parameters. In specific scenarios (such as low-power scenarios such as low-battery scenarios or screen-off scenarios), different heartbeat parameters are used to allow heartbeat packets to be sent and received normally, thereby ensuring the normal operation of the heartbeat mechanism that maintains the connection based on the LAN.
[0164] Optionally, after the above step 202, the LAN-based connection establishment method provided in the embodiment of the present application may further include the following step 214.
[0165] 214. The terminal device sends a target instruction to the target IOT device according to the received instruction from the user to search for the target IOT device.
[0166] The target instruction is used to instruct the target IOT device to output prompt information, and the prompt information is used to determine the location of the target IOT device.
[0167] The prompt information may be at least one of voice prompt information, vibration prompt information, flash screen prompt information, etc., and is not limited in the embodiment of the present application.
[0168] Exemplarily, a connection establishment method based on a local area network provided in an embodiment of the present application can be used to establish a connection based on a local area network between various IOT devices (such as mobile phones, tablets, televisions, computers, smart watches, etc.) in a home scene. In this way, when a user cannot find a target IOT device in a home scene, a target instruction can be sent to the target IOT device through a terminal device, and then the target IOT device can be controlled to output a prompt message through the target instruction, so that the user can find the target IOT device according to the prompt message. The instruction for the user to find the target IOT device can be text information input through an input method keyboard, or it can be a voice message input through a voice assistant, which is not limited in the embodiment of the present application. Taking the example of the user finding the instruction for the target IOT device as a voice message input through a voice assistant, the above step 214 can be specifically implemented through the following steps 214a to 214c.
[0169] 214a. The terminal device receives a voice instruction to search for a target IOT device through a voice assistant in the terminal device.
[0170] 214b. The terminal device sends the target instruction to the voice assistant of the target IOT device based on the voice instruction through the connection between the terminal device and the target IOT device based on the local area network.
[0171] 214c. The target IOT device receives the target instruction through the voice assistant of the target IOT device, and outputs voice prompt information through the voice assistant of the target IOT device according to the target instruction.
[0172] After receiving the voice prompt information, the user finds the target IOT device according to the voice prompt information.
[0173] It should be noted that if the user cannot find the terminal device in a scenario such as home, the user can also send a corresponding instruction to the terminal device through the target IOT device, and then control the target IOT device to output prompt information through the corresponding instruction, so that the user can find the terminal device according to the prompt information.
[0174] In an embodiment of the present application, one device among two devices establishing a connection based on a local area network obtains and parses the user's search instruction, and then sends the instruction to the other device through the established connection channel based on the local area network. The other device responds, thereby achieving the effect of finding the device, and the operation is simple and convenient.
[0175] Figure 6 The structural block diagram of a local area network-based connection establishment device shown in an embodiment of the present application is as follows: Figure 6As shown, it includes: a determination module 601 and an establishment module 602; the determination module 601 is used to determine the target IOT device, and the target IOT device meets the following conditions: it has been successfully paired with the terminal device and is currently in the same local area network as the terminal device; the establishment module 602 is used to establish a local area network-based connection with the target IOT device according to the IP address of the target IOT device.
[0176] Optionally, the successful pairing with the terminal device specifically means: successful quick pairing with the terminal device through the OUGA Group Accessory Connection Framework OAF; the establishment module 602 is specifically used to establish an OAF channel with the target IOT device according to the IP address of the target IOT device to establish a connection based on a local area network.
[0177] Optionally, the determination module 601 is specifically used to perform service discovery in the local area network; when at least one IOT device is found through the service discovery, the target IOT device is determined from the at least one IOT device according to the connection information saved by the terminal device; wherein the connection information includes at least one pairing information, each pairing information is used to indicate a device that has been successfully paired with the terminal device.
[0178] Optionally, the LAN-based connection establishment device also includes: an acquisition module and a saving module; the acquisition module is used to acquire the configuration file of the target IOT device when pairing with the target IOT device is successful before the determination module 601 determines the target IOT device; the saving module is used to save the pairing information with the target IOT device to the connection information when it is determined that the IOT device supports LAN-based connection according to the configuration file obtained by the acquisition module.
[0179] Optionally, the acquisition module is further used to acquire the IP address through the service discovery before the establishment module 602 establishes a LAN-based connection with the target IOT device according to the IP address of the target IOT device.
[0180] Optionally, the establishment module 602 is also used to establish a short-range wireless communication connection with a first IOT device after the determination module 601 performs service discovery in the local area network, if no IOT device is found through the service discovery, and the first IOT device is a device that has been successfully paired with the terminal device; the determination module 601 is also used to determine the first IOT device as the target IOT device when it is determined that the terminal device and the first IOT device are both in the local area network through the short-range wireless communication connection established by the establishment module 602.
[0181] Optionally, the acquisition module is further used to acquire the IP address through the short-range wireless communication connection before the establishment module 602 establishes a LAN-based connection with the target IOT device according to the IP address of the target IOT device.
[0182] Optionally, the connection establishment device based on the local area network also includes: a sending module and a receiving module; the sending module is used to send the MAC address and subnet mask of the terminal device in the local area network to the first IOT device through the short-range wireless communication connection before the determination module 601 determines the first IOT device as the target IOT device, and the MAC address and the subnet mask are used by the first IOT device to determine whether it is in the same local area network as the terminal device; the receiving module is used to receive a reply message from the first IOT device through the short-range wireless communication connection, and the reply message is used to indicate that the first IOT device and the terminal device are in the same local area network.
[0183] Optionally, the local area network-based connection establishment device further includes: a registration module; the registration module is used to perform service registration in the local area network before the determination module 601 determines the target IOT device.
[0184] Optionally, the LAN-based connection establishment device also includes: a maintenance module; the maintenance module is used to maintain the LAN-based connection through a heartbeat mechanism after the establishment module 602 establishes a LAN-based connection with the target IOT device according to the IP address of the target IOT device.
[0185] Optionally, the LAN-based connection establishment device also includes: an adjustment module; the adjustment module is used to adjust the heartbeat parameters of the heartbeat mechanism if it is detected that the terminal device is in a target scenario during the process of maintaining the LAN-based connection through the heartbeat mechanism to ensure the normal operation of the heartbeat mechanism, wherein the target scenario is a screen-off scenario, or a scenario where the remaining power of the terminal device is less than or equal to a power threshold.
[0186] Optionally, the LAN-based connection establishment device also includes: a sending module; the sending module is used to send a target instruction to the target IOT device according to the received user's instruction to search for the target IOT device after the establishment module 602 establishes a LAN-based connection with the target IOT according to the IP address of the target IOT device, and the target instruction is used to instruct the target IOT device to output prompt information, and the prompt information is used to determine the location of the target IOT device.
[0187] It should be noted that in the embodiment of the present application, the LAN-based connection establishment device can be the terminal device in the above method embodiment, or it can be a functional module and / or functional entity in the terminal device in the above method embodiment that can implement the functions of the above device embodiment, and the embodiment of the present application is not limited.
[0188] In the embodiments of the present application, each module can implement the LAN-based connection establishment method provided in the above method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0189] Figure 7 A schematic diagram of the hardware structure of a terminal device for implementing each embodiment of the present application is shown in FIG. Figure 7 As shown, the terminal device includes but is not limited to: radio frequency (RF) circuit 701, memory 702, input unit 703, display unit 704, sensor 705, audio circuit 706, wireless communication (WiFi) module 707, processor 708, power supply 709, and camera 710. Among them, the RF circuit 701 includes a receiver 7011 and a transmitter 7012. Those skilled in the art can understand that Figure 7 The terminal device structure shown in the figure does not constitute a limitation on the terminal device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0190] The RF circuit 701 can be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 708 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit 701 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 701 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to the global system of mobile communication (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), long term evolution (LTE), email, short messaging service (SMS), etc.
[0191] The memory 702 can be used to store software programs and modules. The processor 708 executes various functional applications and data processing of the terminal device by running the software programs and modules stored in the memory 702. The memory 702 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the terminal device (such as audio data, a phone book, etc.), etc. In addition, the memory 702 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0192] The input unit 703 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the terminal device. Specifically, the input unit 703 may include a touch panel 7031 and other input devices 7032. The touch panel 7031, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 7031 or near the touch panel 7031 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 7031 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 708, and can receive and execute commands sent by the processor 708. In addition, the touch panel 7031 can be implemented in a variety of ways such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 7031, the input unit 703 may also include other input devices 7032. Specifically, the other input devices 7032 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0193] The display unit 704 can be used to display information input by the user or information provided to the user and various menus of the terminal device. The display unit 704 may include a display panel 7041. Optionally, the display panel 7041 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 7031 may cover the display panel 7041. When the touch panel 7031 detects a touch operation on or near it, it is transmitted to the processor 708 to determine the touch event. Subsequently, the processor 708 provides a corresponding visual output on the display panel 7041 according to the touch event. Although in Figure 7 In the embodiment, the touch panel 7031 and the display panel 7041 are used as two independent components to realize the input and output functions of the terminal device, but in some embodiments, the touch panel 7031 and the display panel 7041 can be integrated to realize the input and output functions of the terminal device.
[0194] The terminal device may also include at least one sensor 705, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 7041 according to the brightness of the ambient light, and the proximity sensor may exit the display panel 7041 and / or the backlight when the terminal device is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used for applications that identify the posture of the terminal device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors such as gyroscopes, geomagnetic sensors, barometers, hygrometers, thermometers, infrared sensors, etc. that can also be configured in the terminal device, they will not be repeated here. In the embodiment of the present application, the terminal device may include an accelerometer, a depth sensor, or a distance sensor, etc.
[0195] The audio circuit 706, the speaker 7061, and the microphone 7062 can provide an audio interface between the user and the terminal device. The audio circuit 706 can transmit the electrical signal converted from the received audio data to the speaker 7061, which is converted into a sound signal for output; on the other hand, the microphone 7062 converts the collected sound signal into an electrical signal, which is received by the audio circuit 706 and converted into audio data, and then the audio data is output to the processor 708 for processing, and then sent to another terminal device through the RF circuit 701, or the audio data is output to the memory 702 for further processing.
[0196] WiFi is a short-range wireless transmission technology. The terminal device can help users send and receive emails, browse web pages and access streaming media through the WiFi module 707. It provides users with wireless broadband Internet access. Figure 7 A WiFi module 707 is shown, but it is understandable that it is not a necessary component of the terminal device and can be omitted as needed without changing the essence of the invention.
[0197] The processor 708 is the control center of the terminal device. It uses various interfaces and lines to connect various parts of the entire terminal device. By running or executing software programs and / or modules stored in the memory 702 and calling data stored in the memory 702, it executes various functions of the terminal device and processes data, thereby monitoring the terminal device as a whole. Optionally, the processor 708 may include one or more processing units; preferably, the processor 708 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 708.
[0198] The terminal device also includes a power supply 709 (such as a battery) for supplying power to each component. Preferably, the power supply can be logically connected to the processor 708 through a power management system, so that the power management system can manage charging, discharging, and power consumption management. Although not shown, the terminal device can also include a Bluetooth module, etc., which will not be repeated here.
[0199] In an embodiment of the present application, processor 708 is used to determine a target IOT device, which meets the following conditions: it has been successfully paired with the terminal device and is currently in the same local area network as the terminal device; and establishes a local area network-based connection with the target IOT device based on the IP address of the target IOT device.
[0200] Optionally, the successful pairing with the terminal device specifically means: successful quick pairing with the terminal device through the OUGA Group Accessory Connection Framework OAF; processor 708 is specifically used to establish an OAF channel with the target IOT device according to the IP address of the target IOT device to establish a connection based on a local area network.
[0201] Optionally, processor 708 is specifically used to perform service discovery in the local area network; when at least one IOT device is found through the service discovery, the target IOT device is determined from the at least one IOT device according to the connection information saved by the terminal device; wherein the connection information includes at least one pairing information, each pairing information is used to indicate a device that has been successfully paired with the terminal device.
[0202] Optionally, the processor 708 is also used to, before determining the target IOT device, obtain a configuration file corresponding to the target IOT device when pairing with the target IOT device is successful; when it is determined according to the configuration file obtained by the acquisition module that the IOT device supports a connection based on a local area network, the pairing information with the target IOT device is saved to the connection information.
[0203] Optionally, the processor 708 is further configured to obtain the IP address through the service discovery before establishing a LAN-based connection with the target IOT device according to the IP address of the target IOT device.
[0204] Optionally, processor 708 is also used to establish a short-range wireless communication connection with a first IOT device after performing service discovery in the local area network, if no IOT device is found through the service discovery, and the first IOT device is a device that has been successfully paired with the terminal device; when it is determined through the short-range wireless communication connection that the terminal device and the first IOT device are both in the local area network, the first IOT device is determined as the target IOT device.
[0205] Optionally, the processor 708 is further configured to obtain the IP address through the short-range wireless communication connection before establishing a local area network-based connection with the target IOT device according to the IP address of the target IOT device.
[0206] Optionally, the processor 708 is also used to, before determining the first IOT device as the target IOT device, send the MAC address and subnet mask of the terminal device in the local area network to the first IOT device through the short-range wireless communication connection, and the MAC address and the subnet mask are used by the first IOT device to determine whether it is in the same local area network as the terminal device; and receive a reply message from the first IOT device through the short-range wireless communication connection, and the reply message is used to indicate that the first IOT device and the terminal device are in the same local area network.
[0207] Optionally, the processor 708 is further configured to perform service registration in the local area network before determining the target IOT device.
[0208] Optionally, the processor 708 is further configured to, after establishing a connection based on the local area network with the target IOT device according to the IP address of the target IOT device, maintain the connection based on the local area network through a heartbeat mechanism.
[0209] Optionally, processor 708 is also used to adjust the heartbeat parameters of the heartbeat mechanism to ensure the normal operation of the heartbeat mechanism if it is detected that the terminal device is in a target scenario during the process of maintaining the LAN-based connection through the heartbeat mechanism, wherein the target scenario is a screen-off scenario, or a scenario in which the remaining power of the terminal device is less than or equal to a power threshold.
[0210] Optionally, the processor 708 is also used to, after establishing a LAN-based connection with the target IOT device according to the IP address of the target IOT device, send a target instruction to the target IOT device according to a received user instruction to search for the target IOT device, wherein the target instruction is used to instruct the target IOT device to output prompt information, and the prompt information is used to determine the location of the target IOT device.
[0211] The beneficial effects of various implementation methods in this embodiment can be specifically referred to the beneficial effects of the corresponding implementation methods in the above-mentioned local area network-based connection establishment method embodiment. To avoid repetition, they will not be repeated here.
[0212] An embodiment of the present application also provides a terminal device, which may include: a processor, a memory, and a program or instruction stored in the memory and executable on the processor. When the program or instruction is executed by the processor, the various processes of the local area network-based connection establishment method provided in the above method embodiment can be implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0213] An embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the local area network-based connection establishment method provided in the above method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0214] An embodiment of the present application also provides a computer program product, wherein the computer program product includes computer instructions. When the computer program product runs on a processor, the processor executes the computer instructions to implement the various processes of the local area network-based connection establishment method provided in the above method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0215] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned local area network-based connection establishment method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0216] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0217] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices, servers and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0218] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0219] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0220] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0221] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for establishing a connection based on a local area network, It is characterized in that Applied to a terminal device, the method comprises: Performing service discovery in the local area network; In the case where at least one IOT device is found through the service discovery, a target IOT device is determined from the at least one IOT device according to the connection information saved by the terminal device, wherein the connection information includes at least one pairing information, each pairing information is used to indicate a device that has been successfully paired with the terminal device, and the target IOT device meets the following conditions: it has been successfully paired with the terminal device and is currently in the same local area network as the terminal device; In the case where no IOT device is found through the service discovery, a short-range wireless communication connection is established with a first IOT device, where the first IOT device is a device that has been successfully paired with the terminal device; in the case where it is determined through the short-range wireless communication connection that both the terminal device and the first IOT device are in the local area network, the first IOT device is determined as the target IOT device; According to the IP address of the target IOT device, a connection based on a local area network is established with the target IOT device.
2. The method according to claim 1, It is characterized in that The successful pairing with the terminal device specifically means: successful quick pairing with the terminal device through the Ouga Group Accessory Connection Framework OAF; The step of establishing a connection with the target IOT device based on a local area network according to the IP address of the target IOT device comprises: According to the IP address of the target IOT device, an OAF channel is established with the target IOT device to establish a connection based on a local area network.
3. The method according to claim 1, It is characterized in that Before determining the target IOT device, the method further includes: When pairing with the target IOT device is successful, obtaining a configuration file corresponding to the target IOT device; When it is determined according to the configuration file that the target IOT device supports connection based on a local area network, the pairing information with the target IOT device is saved in the connection information.
4. The method according to claim 1, It is characterized in that Before determining the first IOT device as the target IOT device, the method further includes: Sending the media access control MAC address and subnet mask of the terminal device in the local area network to the first IOT device through the short-range wireless communication connection, wherein the MAC address and the subnet mask are used by the first IOT device to determine whether it is in the same local area network as the terminal device; A reply message from the first IOT device is received through the short-range wireless communication connection, where the reply message is used to indicate that the first IOT device and the terminal device are in the same local area network.
5. The method according to any one of claims 1 to 4, It is characterized in that After establishing a connection with the target IOT device based on a local area network according to the IP address of the target IOT device, the method further includes: In the process of maintaining the connection based on the local area network through the heartbeat mechanism, if it is detected that the terminal device is in the target scene, the heartbeat parameters of the heartbeat mechanism are adjusted to ensure the normal operation of the heartbeat mechanism; Among them, the target scenario is a screen-off scenario, or a scenario in which the remaining power of the terminal device is less than or equal to a power threshold.
6. The method according to any one of claims 1 to 4, It is characterized in that After establishing a connection with the target IOT device based on a local area network according to the IP address of the target IOT device, the method further includes: According to the received user instruction to search for the target IOT device, a target instruction is sent to the target IOT device, wherein the target instruction is used to instruct the target IOT device to output prompt information, and the prompt information is used to determine the location of the target IOT device.
7. A connection establishment device based on a local area network, It is characterized in that The device comprises: a determination module and an establishment module; The determination module is used to perform service discovery in the local area network; when at least one IOT device is found through the service discovery, a target IOT device is determined from the at least one IOT device according to the connection information saved by the terminal device, wherein the connection information includes at least one pairing information, each pairing information is used to indicate a device that has been successfully paired with the terminal device, and the target IOT device meets the following conditions: it has been successfully paired with the terminal device and is currently in the same local area network as the terminal device; The establishing module is used to establish a short-range wireless communication connection with a first IOT device after the determining module performs service discovery in the local area network, if no IOT device is found through the service discovery, wherein the first IOT device is a device that has been successfully paired with the terminal device; The determining module is further configured to determine the first IOT device as the target IOT device when it is determined that the terminal device and the first IOT device are both in the local area network through the short-range wireless communication connection established by the establishing module; The establishing module is also used to establish a connection based on a local area network with the target IOT device according to the IP address of the target IOT device.
8. A terminal device, It is characterized in that It comprises a processor, a memory and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method for establishing a connection based on a local area network as described in any one of claims 1 to 6.
9. A readable storage medium, It is characterized in that The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the method for establishing a connection based on a local area network as described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Method and terminal for establishing connection
CN103687061A
Method and device for automatically connecting WIFI (Wireless Fidelity) hotspot and mobile terminal
CN106211051A
Device search method and device
CN109194754A
Multi-terminal joint control method, device and equipment based on local area network, and storage medium
CN111277505A
Electronic equipment discovery method and device, computer readable storage medium and electronic device
CN111405042A
