Device connection method, first device, electronic device, and storage medium
Patent Information
- Application Number
- CN202311789561.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-22
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-12-22
AI Technical Summary
可见,两个设备重新组网的方式比较繁琐
[0041]本申请实施例提供了一种存储介质,其上存储有计算机程序,该计算机程序被处理器执行时,实现上述的设备连接方法。
Smart Images

Figure CN117835456B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network technology, and to, but is not limited to, a device connection method, a first device, an electronic device, and a storage medium. Background Technology
[0002] After two electronic devices establish a network connection, if the network connection is abnormally lost, there is no reconnection mechanism. In this case, the user needs to select the device again from the device list, re-establish the trust relationship, and restart the network connection. Therefore, reconnecting two devices to a network is quite cumbersome. It requires manual selection and a trust handshake each time before a network connection can be established. Summary of the Invention
[0003] This application mainly provides a device connection method, a first device, an electronic device, and a storage medium, which creates a reconnection mechanism that enables two devices to quickly reconnect to the network after an abnormal network disconnection, thereby ensuring the continuity and stability of network functions.
[0004] The technical solution of this application embodiment is implemented as follows:
[0005] This application provides a device connection method, which is applied to a first device, and the method includes:
[0006] Establish a first wireless network connection with the second device;
[0007] Based on the first wireless network connection, first information is transmitted to the second device, and a second wireless network connection is established with the second device based on the first information, while controlling the first wireless network connection to be in the first connection state;
[0008] In the event of an abnormal connection to the second wireless network, the system transmits second information to the second device based on the first wireless network connection in the first connection state, and re-establishes the second wireless network connection with the second device based on the second information; wherein the first information and the second information contain the same type of information.
[0009] The first wireless network connection is based on a first network protocol, and the second wireless network connection is based on a second network protocol. The first network protocol is different from the second network protocol.
[0010] In some embodiments, the method further includes:
[0011] The third information is transmitted to the second device based on the first wireless network connection;
[0012] Based on the third information, a trust verification is performed with the second device;
[0013] If the trust verification is successful, the public key is obtained and saved; wherein the public key is used to encrypt the first information and the second information.
[0014] In some embodiments, before transmitting the second information to the second device based on the first wireless network connection in a first connection state, the method further includes:
[0015] Transmitting abnormal information to the second device; wherein, the abnormal information includes: first abnormal information sent to the second device, and second abnormal information received from the second device;
[0016] Based on the aforementioned abnormal information, the network connection method is determined;
[0017] The second information is determined based on the aforementioned network connection method.
[0018] In some embodiments, determining the network connection method based on the abnormal information includes:
[0019] The first network status corresponding to the first device is determined based on the first abnormal information;
[0020] The second network status corresponding to the second device is determined based on the second abnormal information;
[0021] The network connection method is determined based on the first network connection status and the second network connection status; wherein the network connection method includes at least one of the following network connection types: hotspot network type, P2P network type, and local area network type.
[0022] In some embodiments, determining the network connection method based on the first network connection state and the second network connection state includes:
[0023] If, based on the first network status and the second network status, it is determined that the first device and the second device belong to the same local area network, the network connection method is determined to be local area network (LAN) connection; or,
[0024] If the first network state and the second network state indicate that both the first device and the second device support hotspot establishment capability, the network connection method is determined to be hotspot network connection; or,
[0025] If, based on the first network status and the second network status, it is determined that the first device and the second device do not belong to the same local area network, and the first device and / or the second device do not support the ability to establish hotspots, then the network connection method is determined to be P2P network connection.
[0026] In some embodiments, the method further includes:
[0027] When the networking method is a local area network or a P2P network, the first device or the second device initiates a network connection to re-establish the second wireless network connection;
[0028] When the network connection method is hotspot connection, the first device initiates a network connection to re-establish the second wireless network connection.
[0029] In some embodiments, controlling the first wireless network connection to be in a first connection state includes:
[0030] Receive the first data packet sent by the second device at intervals;
[0031] In response to receiving the first data packet, a second data packet is sent to the second device to control the first wireless network connection to be in a first connection state.
[0032] This application provides a first device, the first device comprising:
[0033] Establishment unit, used to establish a first wireless network connection with the second device;
[0034] The transmission unit is used to transmit first information to the second device based on the first wireless network connection;
[0035] The establishment unit is further configured to establish a second wireless network connection with the second device based on the first information;
[0036] A control unit is used to control the first wireless network connection to be in a first connection state.
[0037] The transmission unit is further configured to transmit second information to the second device based on the first wireless network connection in the first connection state when the second wireless network connection is abnormal;
[0038] The establishment unit is further configured to re-establish a second wireless network connection with the second device based on the second information;
[0039] Wherein, both the first information and the second information are used to establish a network connection with the second device; the first wireless network connection is based on a first network protocol, and the second wireless network connection is based on a second network protocol, wherein the first network protocol and the second network protocol are different.
[0040] This application provides an electronic device, including a memory and a processor. The memory stores a computer program that can run on the processor, and the processor executes the program to implement the above-described device connection method.
[0041] This application provides a storage medium storing a computer program, which, when executed by a processor, implements the device connection method described above.
[0042] The device connection method provided in this application first establishes a first wireless network connection between a first device and a second device. Then, based on the first wireless network connection, first information is transmitted to the second device, and a second wireless network connection is established with the second device based on the first information, keeping the first wireless network connection in a first connection state. Finally, in the event of an abnormal second wireless network connection, second information is transmitted to the second device based on the first wireless network connection in the first connection state, and a second wireless network connection is re-established with the second device based on the second information. Thus, after the two devices establish the first wireless network connection, the first wireless network connection is always kept in the first connection state. In this way, if the second wireless network connection between the two devices is abnormally disconnected, second information can be automatically transmitted to the second device based on the first wireless network connection to quickly rebuild the second wireless network connection. Therefore, based on the established reconnection mechanism, rapid network reconnection is achieved, thereby ensuring the continuity and stability of network functions. Attached Figure Description
[0043] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0044] Figure 1 A schematic flowchart illustrating a device connection method provided in an embodiment of this application;
[0045] Figure 2 A schematic flowchart illustrating a device connection method provided in an embodiment of this application;
[0046] Figure 3 A schematic flowchart illustrating a device connection method provided in an embodiment of this application;
[0047] Figure 4 A schematic flowchart illustrating a device connection method provided in an embodiment of this application;
[0048] Figure 5 A schematic flowchart illustrating a device connection method provided in an embodiment of this application;
[0049] Figure 6 A schematic flowchart illustrating a device connection method provided in an embodiment of this application;
[0050] Figure 7 A schematic flowchart illustrating a device connection method provided in an embodiment of this application;
[0051] Figure 8This is a schematic diagram of the structure of a first device provided in an embodiment of this application;
[0052] Figure 9 This is a schematic diagram of the composition structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0054] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0055] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0057] To address the problems existing in related technologies, this application provides a device connection method, which can be executed by a first device. The first device establishes a first wireless network connection with a second device. After the first wireless network connection is established, it is consistently maintained in a first connection state. Thus, in the event of an abnormal disconnection of the second wireless network connection between the two devices, second information can be automatically transmitted to the second device based on the first wireless network connection to quickly re-establish the second wireless network connection. Therefore, based on this reconnection mechanism, rapid network reconnection is achieved, thereby ensuring the continuity and stability of network functions.
[0058] The following embodiments use a first device as the execution subject to executorly illustrate the device connection method proposed in the embodiments of this application.
[0059] Figure 1 This is a flowchart illustrating a device connection method provided in an embodiment of this application. Figure 1As shown, the device connection method specifically includes the following steps:
[0060] S101: Establish a first wireless network connection with the second device.
[0061] In embodiments of this application, the first device may establish a first wireless network connection with the second device.
[0062] In this embodiment of the application, the first wireless network connection can be a classic Bluetooth connection or a low-power Bluetooth connection.
[0063] In this embodiment, after the first device and the second device establish a first wireless network connection, they can perform trust verification based on third information to generate a public key. This public key can encrypt the first and second information described below. In other words, the first device also needs to transmit the third information to the second device based on the first wireless network connection to complete the trust verification between them. Only when the trust verification is successful can the first device and the second device generate their respective public keys.
[0064] S102: Transmit first information to the second device based on the first wireless network connection, and establish a second wireless network connection with the second device based on the first information, and control the first wireless network connection to be in the first connection state.
[0065] In the embodiments of this application, after establishing a first wireless network connection with the second device, the first device can further transmit first information to the second device based on the first wireless network connection, and establish a second wireless network connection with the second device based on the first information, while controlling the first wireless network connection to be in a first connection state.
[0066] In this application embodiment, different first pieces of information correspond to different network connection types. The first pieces of information include, but are not limited to, any one of the following: IP (Internet Protocol) information for a local area network (LAN), password and SSID (Service Set Identifier) for a hotspot, or password and ID (IDentity) for a peer-to-peer (P2P) network. The network connection type includes, but is not limited to, any one of LAN networking, hotspot networking, or P2P networking.
[0067] For example, in some embodiments, when the first information is the IP information of a local area network, the corresponding network type is local area network networking; when the first information is the password and SSID of a hotspot, the corresponding network type is hotspot networking; when the first information is the password and ID of a P2P network, the corresponding network type is P2P networking.
[0068] It should be noted that in practical applications, for different types of networking methods, a higher-priority networking method can be selected for networking based on a pre-set priority order. Different types of networking methods can have different priorities, and the priority of each type of networking method can be referenced during the networking process.
[0069] It should be noted that, in the embodiments of this application, the priority order of different types of networking methods indicated by the pre-set priority order can be any order, and this application does not impose any specific limitations on it.
[0070] For example, in some embodiments, a pre-set priority order can indicate that the priority of LAN connections, hotspot connections, and P2P connections decreases in that order. That is, in practical applications, LAN connections are given priority, followed by hotspot connections, and P2P connections are considered last.
[0071] In embodiments of this application, a first device receives a first data packet sent by a second device at intervals, and then sends a second data packet to the second device in response to receiving the first data packet. Thus, based on the mutual feedback between the first and second devices, the first wireless network connection is maintained in a first connected state.
[0072] In this embodiment, the first connection state can be a state where data transmission is always possible. That is, a link that can always transmit information is maintained between the first device and the second device. Thus, even if the second wireless network connection is abnormally disconnected, information can continue to be transmitted through this link to quickly re-establish the second wireless network connection.
[0073] S103: In the event of an abnormal second wireless network connection, second information is transmitted to the second device based on the first wireless network connection in the first connection state, and the second wireless network connection is re-established with the second device based on the second information; wherein, the first information and the second information contain the same type of information; the first wireless network connection is based on the first network protocol, the second wireless network connection is based on the second network protocol, and the first network protocol and the second network protocol are different.
[0074] In the embodiments of this application, after transmitting first information to the second device based on the first wireless network connection, establishing a second wireless network connection with the second device based on the first information, and controlling the first wireless network connection to be in a first connection state, in the event of an abnormal second wireless network connection, the first device can further transmit second information to the second device based on the first wireless network connection in the first connection state, and re-establish the second wireless network connection with the second device based on the second information; wherein, the first information and the second information contain the same information type; the first wireless network connection is based on a first network protocol, the second wireless network connection is based on a second network protocol, and the first network protocol and the second network protocol are different.
[0075] In this embodiment of the application, after determining that the second wireless network connection is abnormal, the first device can further transmit abnormal information to the second device to determine the network connection method and further determine the second information corresponding to the network connection method.
[0076] In the embodiments of this application, different network connection types correspond to different second wireless network connection anomalies. For example, if the second wireless network connection anomaly is a local area network (LAN) disconnection, the corresponding second wireless network connection is a LAN connection; if the second wireless network connection anomaly is a hotspot shutdown, the corresponding second wireless network connection is a hotspot connection; if the second wireless network connection anomaly is a P2P disconnection, the corresponding second wireless network connection is a P2P connection.
[0077] In the embodiments of this application, different abnormal information determines different network states for the first and second devices, and different network states determine different network connection methods. The network state includes, but is not limited to, the first and second devices belonging to the same local area network (LAN), or both the first and second devices supporting hotspot establishment capabilities, or any other state besides the two mentioned above. The network connection method includes, but is not limited to, LAN networking, hotspot networking, or P2P networking.
[0078] For example, in some embodiments, if the abnormal information determines that the first device and the second device belong to the same local area network, then the determined networking method includes local area network networking; if the abnormal information determines that the first device and the second device both support hotspot establishment capability, then the determined networking method includes hotspot networking; if the abnormal information determines that the first device and the second device do not belong to the same local area network, and the first device and / or the second device do not support hotspot establishment capability, then the determined networking method includes P2P networking.
[0079] In the embodiments of this application, there is a one-to-one correspondence between the network connection method and the second information. For example, if the network connection method is a local area network (LAN), the second information includes the LAN's IP information; if the network connection method is a hotspot connection, the second information includes the hotspot's password and SSID; if the network connection method is a P2P connection, the second information includes the P2P password and ID.
[0080] In this embodiment, since both the first information and the second information are used to establish a network connection with the second device, the types of information contained in the first information and the second information can be the same; that is, the second information can also be any one of the following: local area network IP information, hotspot password and SSID, or P2P password and ID.
[0081] In this embodiment of the application, the public key of the first device can encrypt the second information, and the public key of the second device can decrypt the encrypted second information.
[0082] In this embodiment of the application, the re-established second wireless network connection can be any one of a local area network connection, a hotspot connection, or a P2P connection.
[0083] In the embodiments of this application, when the network connection method is determined to be either a local area network (LAN) connection or a P2P connection, either the first device or the second device can initiate the network connection. That is, when the network connection method is determined to be a LAN connection, either the first device can transmit the LAN's IP information to the second device, or the first device can receive the LAN's IP information transmitted by the second device, to re-establish the second wireless network connection. Similarly, when the network connection method is determined to be a P2P connection, either the first device can transmit the P2P password and ID to the second device, or the first device can receive the P2P password and ID transmitted by the second device, to re-establish the second wireless network connection.
[0084] In the embodiments of this application, when the network connection method is determined to be hotspot networking, only the first device can initiate the network connection. That is, when the network connection method is determined to be hotspot networking, only the first device can transmit the hotspot password and SSID to the second device to re-establish the second wireless network connection.
[0085] In this embodiment of the application, the first network protocol may be GATT (Generic Attribute Profile).
[0086] In this embodiment of the application, the second network protocol may be a WLAN (Wireless Local Area Network) protocol, such as a WiFi (Wireless Fidelity) protocol.
[0087] The device connection method provided in this application first establishes a first wireless network connection between a first device and a second device. Then, based on the first wireless network connection, first information is transmitted to the second device, and a second wireless network connection is established with the second device based on the first information, keeping the first wireless network connection in a first connection state. Finally, in the event of an abnormal second wireless network connection, second information is transmitted to the second device based on the first wireless network connection in the first connection state, and a second wireless network connection is re-established with the second device based on the second information. Thus, after the two devices establish the first wireless network connection, the first wireless network connection is always kept in the first connection state. In this way, if the second wireless network connection between the two devices is abnormally disconnected, second information can be automatically transmitted to the second device based on the first wireless network connection to quickly rebuild the second wireless network connection. Therefore, based on the established reconnection mechanism, rapid network reconnection is achieved, thereby ensuring the continuity and stability of network functions.
[0088] Furthermore, Figure 2 This is a flowchart illustrating a device connection method provided in an embodiment of this application, as shown below. Figure 2 As shown, after establishing a first wireless network connection with the second device, i.e., after step 101, the device connection method may further include the following steps:
[0089] S104: Transmit third information to the second device based on the first wireless network connection.
[0090] In the embodiments of this application, after establishing a first wireless network connection with the second device, the first device may further transmit third information to the second device based on the first wireless network connection.
[0091] In this embodiment of the application, the third information may be information regarding the handshake and trust between the first device and the second device. For example, the third information may be a PIN code (Personal identification number).
[0092] S105: Based on third-party information, perform trust verification with the second device.
[0093] In the embodiments of this application, after transmitting third information to the second device based on the first wireless network connection, the first device can further perform trust verification with the second device based on the third information.
[0094] In this embodiment of the application, the trust verification between the first device and the second device can be a PIN code verification. For example, the process of transmitting the PIN code displayed by the first device to the second device, and then having the second device input the corresponding PIN code, constitutes the trust verification process between the first device and the second device.
[0095] S106: If the trust verification is successful, obtain and save the public key; wherein, the public key of the first device is used to encrypt the first information and the second information.
[0096] In the embodiments of this application, after trust verification with the second device based on the third information, the first device can further obtain and save the public key if the trust verification is successful; wherein, the public key is used to encrypt the first information and the second information.
[0097] In this embodiment of the application, since the PIN code displayed by the first device has been transmitted to the second device, only when the two PIN codes are completely identical after the second device enters the corresponding PIN code can it be said that the trust verification between the first device and the second device has been passed, that is, the first device and the second device have completed the handshake trust.
[0098] In this embodiment, the first device and the second device can only generate their respective public keys after the trust verification between them is successful. These public keys can be stored on their respective devices. That is, the first device's public key is stored on the first device, and the second device's public key is stored on the second device.
[0099] In this embodiment of the application, the public key of the first device can encrypt the first information or the second information, and correspondingly, the public key of the second device can decrypt the first information or the second information transmitted from the first device.
[0100] In some embodiments, when the second device performs the device connection method, the public key of the second device can encrypt the first information or the second information, and correspondingly, the public key of the first device can decrypt the first information or the second information transmitted from the second device.
[0101] The device connection method provided in this application requires, before the first device and the second device establish a second wireless network connection for the first time, to further transmit third information to the second device based on the first wireless network connection, thereby performing trust verification with the second device. If the trust verification is successful, the public key is obtained and saved. Thus, only after the trust verification between the first device and the second device is successful can the first information to be transmitted be encrypted based on the generated public key, thereby ensuring the security of the initial second wireless network connection.
[0102] Furthermore, Figure 3 This is a flowchart illustrating a device connection method provided in an embodiment of this application, as shown below. Figure 3 As shown, after the second wireless network connection fails, before transmitting the second information to the second device based on the first wireless network connection in the first connection state, the device connection method may further include the following steps:
[0103] S107: Transmitting abnormal information to the second device.
[0104] In an embodiment of this application, after the second wireless network connection fails, the first device may further transmit exception information to the second device.
[0105] In embodiments of this application, the abnormal information includes: first abnormal information sent to the second device, and second abnormal information received from the second device.
[0106] In the embodiments of this application, the first abnormal information can be any one of the following: abnormal disconnection of the local area network, abnormal shutdown of the hotspot, or abnormal disconnection of the P2P connection. The second abnormal information can also be any one of the following: abnormal disconnection of the local area network, abnormal shutdown of the hotspot, or abnormal disconnection of the P2P connection. It should be noted that the first and second abnormal information are of the same type.
[0107] It should be noted that the error information is transmitted based on the first wireless network connection that is in a keep-alive state.
[0108] S108: Determine the network connection method based on the abnormal information.
[0109] In the embodiments of this application, after transmitting abnormal information to the second device, the first device can further determine the networking method based on the abnormal information.
[0110] In the embodiments of this application, different error messages determine different network connection methods. For example, if the error message is a local area network (LAN) disconnection, the LAN connection method is selected first; if the error message is a hotspot shutdown, the LAN connection method is selected first, and if the connection fails, the hotspot connection method is selected; if the error message is a P2P connection disconnection, the LAN connection method is selected first, and if the connection fails, the hotspot connection method is selected. If the connection still fails, the P2P connection method is selected last.
[0111] S109: Determine the second information based on the network connection method.
[0112] In the embodiments of this application, after determining the network connection method based on the abnormal information, the first device can further determine the network connection method based on the abnormal information.
[0113] In the embodiments of this application, there is a one-to-one correspondence between the network connection method and the second information. For example, if the network connection method is a local area network (LAN), the second information is the LAN's IP information; if the network connection method is a hotspot connection, the second information is the hotspot's password and SSID; if the network connection method is a P2P connection, the second information is the P2P password and ID.
[0114] The device connection method provided in this application determines the corresponding network connection method through first and second abnormal information, thereby determining the corresponding second information, and re-establishing a second wireless network connection with the second device through the second information. This improves the success rate of reconnection.
[0115] Furthermore, Figure 4 This is a flowchart illustrating a device connection method provided in an embodiment of this application, as shown below. Figure 4 As shown, based on Figure 3 , Figure 3 S108 in the middle can be implemented through S1081-S1083, which will combine Figure 4 The steps shown are explained below:
[0116] S1081: Determine the first network status corresponding to the first device based on the first abnormal information.
[0117] In the embodiments of this application, after transmitting abnormal information to the second device, the first device can further determine the first network status corresponding to the first device based on the first abnormal information.
[0118] In the embodiments of this application, the first network connection state can be any one of a local area network (LAN) network state, a hotspot network state, or a P2P network state. For example, if the first abnormal information is a LAN abnormal disconnection, the first network connection state of the first device can be determined to be a LAN network state; if the first abnormal information is a hotspot abnormal shutdown, the first network connection state of the first device can be determined to be a hotspot network state; if the first abnormal information is a P2P connection abnormal disconnection, the first network connection state of the first device can be determined to be a P2P network state.
[0119] S1082: Determine the second network status corresponding to the second device based on the second abnormal information.
[0120] In the embodiments of this application, after determining the first network status corresponding to the first device based on the first abnormal information, the first device can further determine the second network status corresponding to the second device based on the second abnormal information.
[0121] In the embodiments of this application, the second network state can be any one of a local area network (LAN) network state, a hotspot network state, or a P2P network state. For example, if the second abnormal information is a LAN abnormal disconnection, the second network state of the second device can be determined to be a LAN network state; if the second abnormal information is a hotspot abnormal shutdown, the second network state of the second device can be determined to be a hotspot network state; if the second abnormal information is a P2P connection abnormal disconnection, the second network state of the second device can be determined to be a P2P network state.
[0122] S1083: Determine the network connection method based on the first network connection state and the second network connection state; wherein, the network connection method includes at least one of the following network connection types: hotspot network connection type, P2P network connection type, local area network connection type.
[0123] In the embodiments of this application, after determining the second network status corresponding to the second device based on the second abnormal information, the first device can further determine the network connection method based on the first network status and the second network status. The network connection method includes at least one of the following network types: hotspot network type, P2P network type, and local area network type.
[0124] In the embodiments of this application, if it is determined that the first device and the second device belong to the same local area network based on the first network state and the second network state, the network connection method is determined to be local area network connection; or, if the first network state and the second network state indicate that both the first device and the second device support hotspot establishment capability, the network connection method is determined to be hotspot connection; or, if it is determined that the first device and the second device do not belong to the same local area network based on the first network state and the second network state, and the first device and / or the second device do not support hotspot establishment capability, the network connection method is determined to be P2P connection.
[0125] In the embodiments of this application, since local area network (LAN) networking has a higher priority than hotspot networking, when the first and second networking states indicate that both the first and second devices support hotspot establishment capabilities, it can be determined first whether the first and second devices belong to the same LAN. If the first and second devices belong to the same LAN, the LAN networking method can be selected first; while if the first and second devices do not belong to the same LAN, hotspot networking can continue.
[0126] In the embodiments of this application, the first device supporting hotspot establishment capability can mean that the first device has the ability to establish a hotspot. The second device supporting hotspot establishment capability can mean that the second device has the ability to provide secondary Wi-Fi.
[0127] In the embodiments of this application, the first device not supporting the hotspot establishment capability may mean that the first device lacks the ability to establish a hotspot; the second device not supporting the hotspot establishment capability may mean that the second device lacks the ability to provide secondary Wi-Fi. It should be noted that the first device lacking the ability to establish a hotspot, or the second device lacking the ability to provide secondary Wi-Fi, or both the first device lacking the ability to establish a hotspot and the second device lacking the ability to provide secondary Wi-Fi, can all indicate that the first device and the second device do not support hotspot networking.
[0128] In the embodiments of this application, when the network connection method is a local area network or a P2P network, the first device or the second device initiates a network connection to re-establish the second wireless network connection; when the network connection method is a hotspot network, the first device initiates a network connection to re-establish the second wireless network connection.
[0129] In the embodiments of this application, when the network connection method is determined to be either a local area network (LAN) connection or a P2P connection, either the first device or the second device can initiate the network connection. That is, when the network connection method is determined to be a LAN connection, either the first device can transmit the LAN's IP information to the second device, or the second device can transmit the LAN's IP information to the first device, to re-establish the second wireless network connection. Similarly, when the network connection method is determined to be a P2P connection, either the first device can transmit the P2P password and ID to the second device, or the second device can transmit the P2P password and ID to the first device, to re-establish the second wireless network connection.
[0130] In the embodiments of this application, when the network connection method is determined to be hotspot networking, only the first device can initiate the network connection. That is, when the network connection method is determined to be hotspot networking, only the first device can transmit the hotspot password and SSID to the second device to re-establish the second wireless network connection.
[0131] The device connection method provided in this application determines the network status of a device based on abnormal information, and further determines the corresponding network mode based on different network statuses. This improves the accuracy of determining the network mode. Based on different network modes, it is determined whether a first device or a second device initiates a network connection to re-establish a second wireless network connection. This allows for targeted network connection establishment, ensuring the effectiveness of the network connection.
[0132] Furthermore, Figure 5 This is a flowchart illustrating a device connection method provided in an embodiment of this application, as shown below. Figure 5 As shown, controlling the first wireless network connection to be in the first connection state may include the following steps:
[0133] S201: Receive the first data packet sent by the second device at intervals.
[0134] In the embodiments of this application, after establishing a first wireless network connection with the second device, the first device may further receive first data packets sent by the second device at intervals.
[0135] In the embodiments of this application, the first data packet can be an empty data packet or a data packet carrying information. This application does not impose any limitations on this.
[0136] In embodiments of this application, the interval time can be less than or equal to a certain threshold time, for example, the threshold can be 30 seconds.
[0137] S202: In response to receiving the first data packet, a second data packet is sent to the second device to control the first wireless network connection to be in the first connection state.
[0138] In embodiments of this application, after receiving a first data packet sent by a second device at intervals, the first device may further respond to receiving the first data packet by sending a second data packet to the second device to control the first wireless network connection to be in a first connection state.
[0139] In the embodiments of this application, the second data packet can be an empty data packet or a data packet carrying information. This application does not impose any limitations on this.
[0140] In this embodiment, the first connection state can be a state where data transmission is always possible. That is, a link that can always transmit information is maintained between the first device and the second device. Thus, even if the second wireless network connection is abnormally disconnected, information can continue to be transmitted through this link to quickly re-establish the second wireless network connection.
[0141] The device connection method provided in this application embodiment involves a first device receiving a first data packet sent by a second device at intervals, and then sending a second data packet to the second device in response to receiving the first data packet. In this way, based on the mutual feedback between the first and second devices, the first wireless network connection is maintained in a first connection state, thereby improving the efficiency of network reconnection.
[0142] Furthermore, Figure 6 This is a flowchart illustrating a device connection method provided in an embodiment of this application, as shown below. Figure 6 As shown, controlling the first wireless network connection to be in the first connection state may further include the following steps:
[0143] S301: Send a second data packet to the second device at intervals.
[0144] In the embodiments of this application, after establishing a first wireless network connection with the second device, the first device may further send a second data packet to the second device at intervals.
[0145] In the embodiments of this application, the first data packet can be an empty data packet or a data packet carrying information. This application does not impose any limitations on this.
[0146] In embodiments of this application, the interval time can be less than or equal to a certain threshold time, for example, the threshold can be 30 seconds.
[0147] S302: Receive the first data packet sent by the second device to control the first wireless network connection to be in the first connection state.
[0148] In embodiments of this application, after sending a second data packet to the second device at intervals, the first device may further receive a first data packet sent by the second device to control the first wireless network connection to be in a first connection state.
[0149] In the embodiments of this application, the second data packet can be an empty data packet or a data packet carrying information. This application does not impose any limitations on this.
[0150] In this embodiment, the first connection state can be a state where data can be transmitted at any time. That is, a link that can always transmit information is maintained between the first device and the second device.
[0151] In this embodiment, the first connection state can be a state where data transmission is always possible. That is, a link that can always transmit information is maintained between the first device and the second device. Thus, even if the second wireless network connection is abnormally disconnected, information can continue to be transmitted through this link to quickly re-establish the second wireless network connection.
[0152] The device connection method provided in this application embodiment involves a first device sending a second data packet to a second device at intervals, and then receiving a first data packet sent by the second device. In this way, based on the mutual feedback between the first and second devices, the first wireless network connection is maintained in a first connection state, thereby improving the efficiency of network reconnection.
[0153] Furthermore, Figure 7 This is a flowchart illustrating a device connection method provided in an embodiment of this application, as shown below. Figure 7 As shown, the device connection method specifically includes the following steps:
[0154] S401: After Device A (the second device) and Device B (the first device) exchange JPake (Password Authenticated Key Exchange by Juggling) keys (e.g., PIN codes) through the established first wireless connection (e.g., GATT connection), both Device A and Device B possess the encrypted public key.
[0155] S402: Device B creates a local area network, hotspot, or establishes a P2P connection, and transmits first connection information (first information) encrypted with a public key through a GATT connection, and interconnects with Device A (second wireless network connection);
[0156] S403: Keep the GATT connection (first wireless network connection) between device A and device B uninterrupted;
[0157] S404: The network connection between device A and device B has been abnormally disconnected;
[0158] S405: Device B will send an error message via GATT connection, and Device A will also provide feedback based on the disconnection situation, and determine the network status based on the error message;
[0159] S406: Determine the reconnection method based on the network status, and based on the reconnection method, device B reconnects with device A (second wireless network connection) using the second connection information (second information) encrypted with the GATT connection interaction public key.
[0160] In this embodiment, the PIN code displayed by device B is transmitted to device A. Then, the corresponding PIN code is entered on device A. Only when the two PIN codes match exactly is the trust verification between device A and device B successful, meaning that device A and device B have completed the handshake trust process. At this point, device A and device B can generate their respective public keys, which can be stored on their respective devices. In other words, device B's public key is stored on device B, and device A's public key is stored on device A.
[0161] In this embodiment of the application, the GATT connection between device A and device B is kept open. Specifically, within 30 seconds, device A and device B transmit data packets to each other to keep the GATT connection open.
[0162] In this application embodiment, abnormal network connection disconnection includes, but is not limited to, abnormal shutdown of the hotspot of device B or abnormal disconnection of P2P connection. In addition, there is also local area network connection disconnection.
[0163] It should be noted that in practical applications, hotspot connections have a higher priority than P2P connections, and LAN connections have a higher priority than hotspot connections. In other words, in practical applications, LAN connections should be considered first, followed by hotspot connections, and P2P connections should be considered last.
[0164] In this application embodiment, different reconnection methods are determined for different abnormal information. For example, if the abnormal information is a local area network (LAN) disconnection, the LAN reconnection method is selected first; if the abnormal information is a hotspot shutdown, the LAN reconnection method is selected first, and if the connection fails, the hotspot reconnection method is selected; if the abnormal information is a P2P connection disconnection, the LAN reconnection method is selected first, and if the connection fails, the hotspot reconnection method is selected. If the connection still fails, the P2P reconnection method is selected last.
[0165] In the embodiments of this application, there is a one-to-one correspondence between the reconnection method and the second information. For example, if the reconnection method is a local area network (LAN) connection, the second information is the LAN's IP information; if the reconnection method is a hotspot connection, the second information is the hotspot's password and SSID; if the reconnection method is a P2P connection, the second information is the P2P password and ID.
[0166] In this embodiment, both the first information and the second information are used to establish a network connection with the second device. Therefore, the first information and the second information contain the same type of information; that is, the first information can be any one of the following: local area network IP information, hotspot password and SSID, or P2P password and ID.
[0167] In the embodiments of this application, when the reconnection method is determined to be either a local area network (LAN) connection or a peer-to-peer (P2P) connection, either device A or device B can initiate the network connection. That is, when the reconnection method is determined to be a LAN connection, either device A can transmit the LAN's IP information to device B, or device B can transmit the LAN's IP information to device A. Similarly, when the reconnection method is determined to be a P2P connection, either device A can transmit the P2P password and ID to device B, or device B can transmit the P2P password and ID to device A, in order to re-establish the second wireless network connection.
[0168] In the embodiments of this application, when the reconnection method is determined to be hotspot networking, only device B can initiate the network connection. That is, when the reconnection method is determined to be hotspot networking, only device B can transmit the hotspot password and SSID to device A.
[0169] The device connection method provided in this application does not disconnect the GATT connection in Bluetooth Low Energy after two devices are interconnected. Therefore, in the event of an unexpected network disconnection between the two devices, the reason for the abnormal disconnection can be exchanged via GATT to determine whether a reconnection is necessary. If a reconnection is required, encrypted information exchange is performed directly via the GATT connection to meet the conditions for a new network connection. In other words, under secure conditions, previously connected devices A and B can automatically reconnect in the event of an abnormal disconnection, ensuring functional continuity, increasing functional stability, and reducing user intervention.
[0170] This application provides a schematic diagram of the structure of a first device. For example... Figure 8 As shown, the first device 500 includes: an establishment unit 501, a transmission unit 502, and a control unit 503.
[0171] Establishment unit 501 is used to establish a first wireless network connection with the second device;
[0172] Transmission unit 502 is used to transmit first information to a second device based on a first wireless network connection;
[0173] The establishment unit 501 is also used to establish a second wireless network connection with the second device based on the first information;
[0174] Control unit 503 is used to control the first wireless network connection to be in the first connection state;
[0175] The transmission unit 502 is also configured to transmit second information to the second device based on the first wireless network connection in the first connection state in the event of an abnormal second wireless network connection.
[0176] The establishment unit 501 is also used to re-establish a second wireless network connection with the second device based on the second information. Wherein, the first information and the second information contain the same information type; the first wireless network connection is based on a first network protocol, and the second wireless network connection is based on a second network protocol, wherein the first network protocol and the second network protocol are different.
[0177] This application also provides a schematic diagram of the composition structure of an electronic device, such as... Figure 9 As shown, the electronic device 60 proposed in this application embodiment may include a processor 61, a memory 62 configured to store computer programs that can run on the processor, and further, the electronic device 60 may also include a communication interface 63 and a bus 64 for connecting the processor 61, the memory 62 and the communication interface 63.
[0178] In the embodiments of this application, the processor 61 described above can be at least one of the following: Application-Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), Central Processing Unit (CPU), Controller, Microcontroller, and Microprocessor. It is understood that for different devices, the electronic device used to implement the above processor function can also be other types, and the embodiments of this application do not specifically limit it.
[0179] In embodiments of this application, memory 62 is used to store instructions and data. Memory 62 may be connected to processor 61, wherein memory 62 is used to store executable program code, which includes computer operation instructions.
[0180] In embodiments of this application, bus 64 is used to connect communication interface 63, processor 61, and memory 62, as well as the mutual communication between these devices.
[0181] Furthermore, in the embodiments of this application, the processor 61 is configured to establish a first wireless network connection with the second device; transmit first information to the second device based on the first wireless network connection, and establish a second wireless network connection with the second device based on the first information, controlling the first wireless network connection to be in a first connection state; in the event of an abnormal second wireless network connection, transmit second information to the second device based on the first wireless network connection in the first connection state, and re-establish the second wireless network connection with the second device based on the second information; wherein the first information and the second information contain the same information type; the first wireless network connection is based on a first network protocol, the second wireless network connection is based on a second network protocol, and the first network protocol and the second network protocol are different.
[0182] In practical applications, the aforementioned memory 62 can be volatile memory, such as random-access memory (RAM); or non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the above types of memory, and provide instructions and data to the processor 61.
[0183] This application provides an electronic device that establishes a first wireless network connection with a second device. Based on the first wireless network connection, it transmits first information to the second device and establishes a second wireless network connection with the second device based on the first information, controlling the first wireless network connection to be in a first connection state. In the event of an abnormal second wireless network connection, it transmits second information to the second device based on the first wireless network connection in the first connection state and re-establishes the second wireless network connection with the second device based on the second information. The first and second information contain the same information type; the first wireless network connection is based on a first network protocol, and the second wireless network connection is based on a second network protocol, which are different from each other. Thus, based on the established reconnection mechanism, rapid network reconnection is achieved, thereby ensuring the continuity and stability of network functions.
[0184] This application also provides a storage medium storing a program that, when executed by a processor, implements the device connection method described above.
[0185] Specifically, the program instructions corresponding to a device connection method in this embodiment can be stored on storage media such as optical discs, hard disks, and USB flash drives. When the program instructions corresponding to a device connection method in the storage media are read or executed by an electronic device, the following steps are included:
[0186] Establish a first wireless network connection with the second device;
[0187] Based on the first wireless network connection, the first information is transmitted to the second device, and based on the first information, a second wireless network connection is established with the second device, and the first wireless network connection is controlled to be in the first connection state;
[0188] In the event of an abnormal second wireless network connection, second information is transmitted to the second device based on the first wireless network connection in the first connection state, and the second wireless network connection is re-established with the second device based on the second information; wherein, the first information and the second information contain the same type of information; the first wireless network connection is based on the first network protocol, the second wireless network connection is based on the second network protocol, and the first network protocol and the second network protocol are different.
[0189] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0190] This application is described with reference to schematic and / or block diagrams of implementations of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the schematic and / or block diagrams can be implemented by computer program instructions, and combinations of blocks in the schematic and / or block diagrams can be implemented. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the schematic and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0191] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in the implementation flow diagram. Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0192] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0193] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.
Claims
1. A device connection method, the device connection method being applied to a first device, the method comprising: Establish a first wireless network connection with the second device; Based on the first wireless network connection, first information is transmitted to the second device, and a second wireless network connection is established with the second device based on the first information, while controlling the first wireless network connection to be in the first connection state; In the event of an abnormal connection to the second wireless network, abnormal information is transmitted to the second device; wherein, the abnormal information includes: first abnormal information sent to the second device, and second abnormal information received from the second device; based on the abnormal information, the network connection method is determined; based on the network connection method, second information is determined; The second information is transmitted to the second device based on the first wireless network connection in the first connection state, and the second wireless network connection is re-established with the second device based on the second information; wherein the first information and the second information contain the same type of information. The first wireless network connection is based on a first network protocol, and the second wireless network connection is based on a second network protocol. The first network protocol is different from the second network protocol.
2. The method according to claim 1, further comprising: The third information is transmitted to the second device based on the first wireless network connection; Based on the third information, a trust verification is performed with the second device; If the trust verification is successful, the public key is obtained and saved; wherein the public key is used to encrypt the first information and the second information.
3. The method according to claim 1, wherein determining the network connection method based on the abnormal information includes: The first network status corresponding to the first device is determined based on the first abnormal information; The second network status corresponding to the second device is determined based on the second abnormal information; The network connection method is determined based on the first network connection status and the second network connection status; wherein the network connection method includes at least one of the following network connection types: hotspot network type, P2P network type, and local area network type.
4. The method according to claim 3, wherein determining the network connection mode based on the first network connection state and the second network connection state includes: If, based on the first network status and the second network status, it is determined that the first device and the second device belong to the same local area network, the network connection method is determined to be local area network connection; or, If the first network state and the second network state indicate that both the first device and the second device support hotspot establishment capability, the network connection method is determined to be hotspot network connection; or, If, based on the first network status and the second network status, it is determined that the first device and the second device do not belong to the same local area network, and the first device and / or the second device do not support the ability to establish hotspots, then the network connection method is determined to be P2P network connection.
5. The method according to claim 3 or 4, further comprising: When the networking method is a local area network or a P2P network, the first device or the second device initiates a network connection to re-establish the second wireless network connection; When the network connection method is hotspot connection, the first device initiates a network connection to re-establish the second wireless network connection.
6. The method according to any one of claims 1 to 4, wherein controlling the first wireless network connection to be in a first connection state comprises: Receive the first data packet sent by the second device at intervals; In response to receiving the first data packet, a second data packet is sent to the second device to control the first wireless network connection to be in a first connection state.
7. A first device, the first device comprising: Establishment unit, used to establish a first wireless network connection with the second device; The transmission unit is used to transmit first information to the second device based on the first wireless network connection; The establishment unit is further configured to establish a second wireless network connection with the second device based on the first information; A control unit is used to control the first wireless network connection to be in a first connection state. The transmission unit is further configured to transmit abnormal information to the second device in the event of an abnormal connection to the second wireless network; wherein the abnormal information includes: first abnormal information sent to the second device, and second abnormal information received from the second device; determining the network connection method based on the abnormal information; determining second information based on the network connection method; and transmitting the second information to the second device based on the first wireless network connection in the first connection state; The establishment unit is further configured to re-establish a second wireless network connection with the second device based on the second information; The first information and the second information contain the same type of information; the first wireless network connection is based on a first network protocol, the second wireless network connection is based on a second network protocol, and the first network protocol is different from the second network protocol.
8. An electronic device comprising a memory and a processor, the memory storing a computer program executable on the processor, the processor executing the program to implement the device connection method according to any one of claims 1 to 6.
9. A storage medium having a computer program stored thereon, which, when executed by a processor, implements the device connection method according to any one of claims 1 to 6.
Citation Information
Patent Citations
WiFi hotspot reconnection method and apparatus, readable storage medium, and mobile terminal
CN108966364A
Connection establishment method and device based on local area network, terminal equipment and storage medium
CN113873684A