A device connection method, apparatus, device, and storage medium

By establishing a reference communication connection (other than a local area network) between the mobile terminal and home appliances, and obtaining connection establishment information to achieve cross-network segment local area network connection, the problem of communication failure under different local area network segments is solved, and the device connection range is expanded.

CN116017762BActive Publication Date: 2026-04-28CHENGDU XGIMI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHENGDU XGIMI TECH CO LTD
Filing Date
2021-10-21
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

When mobile terminals and home appliances are on different local area network segments, they cannot establish a local area network connection, resulting in communication failure.

Method used

By establishing a reference communication connection other than the local area network (LAN), the communication connection establishment information of the second device is obtained. Using this information and the LAN connection information, the first communication connection is established, thereby realizing LAN connection across network segments.

Benefits of technology

It enables effective connection between mobile terminals and home appliances on different local area network segments, compensating for the shortcomings of local area network communication and expanding the connection range.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116017762B_ABST
    Figure CN116017762B_ABST
Patent Text Reader

Abstract

The application discloses a device connection method, which comprises the following steps: in the case that a first communication connection of a second device fails to be established, a first device acquires first communication connection establishment information of the second device for establishing the first communication connection through a successfully established reference communication connection with the second device; a first communication mode of the first communication connection is a local area network, and a communication mode of the reference communication connection is a second communication mode other than the local area network; and the first device establishes the first communication connection with the second device through the first communication connection establishment information and second communication connection establishment information, wherein the second communication connection establishment information is information of the first device for establishing the first communication connection. The application further discloses a device connection device, a device and a storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to wireless communication technology, and more particularly to a device connection method, apparatus, device, and storage medium. Background Technology

[0002] Currently, using smartphones and other mobile devices to control home appliances is gradually replacing the traditional method of using remote controls. When controlling smart home appliances via a mobile device, communication with the smart appliance is usually achieved through a fixed communication method based on the current connection status.

[0003] In the process of implementing the embodiments of this disclosure, it has been found that at least the following problems exist in the related technology: when a mobile terminal and a home appliance can communicate through a local area network (LAN), the LAN has the characteristics of high transmission rate, long communication distance, large amount of data transmitted, and high real-time performance. However, the home appliance and the mobile phone must be on the same LAN and the same network segment; otherwise, the mobile phone cannot find the home appliance and cannot establish a connection with it. Summary of the Invention

[0004] In view of this, embodiments of this application provide a device connection method, apparatus, device, and storage medium that can obtain and establish a communication connection corresponding to a local area network based on other communication methods outside the local area network, thereby enabling a local area network-based connection between the first device and the second device in the extended network segment.

[0005] The technical solution of this application embodiment is implemented as follows:

[0006] In a first aspect, embodiments of this application provide a device connection method, applied to a first device, comprising:

[0007] If the first device fails to establish a first communication connection with the second device, it obtains the first communication connection establishment information of the second device used to establish the first communication connection by using a successfully established reference communication connection with the second device; the first communication mode of the first communication connection is a local area network, and the communication mode of the reference communication connection is a second communication mode other than a local area network.

[0008] The first device establishes the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information, wherein the second communication connection establishment information is information used by the first device to establish the first communication connection.

[0009] Secondly, embodiments of this application provide a device connection method, applied to a second device, comprising:

[0010] If the second device fails to establish a first communication connection with the first device, it sends first communication connection establishment information to the first device through a successfully established reference communication connection with the first device. The first communication mode of the first communication connection is a local area network (LAN), and the communication mode of the reference communication connection is a second communication mode other than a LAN. The first communication connection establishment information is used by the first device to establish the first communication connection with the second device in conjunction with the second communication connection establishment information. The second communication connection establishment information is the information used by the first device to establish the first communication connection.

[0011] Thirdly, embodiments of this application provide a device connection apparatus applied to a first device, the apparatus comprising:

[0012] The acquisition unit is configured to, in the event that the establishment of a first communication connection with the second device fails, acquire, through a reference communication connection that has been successfully established with the second device, the first communication mode of the first communication connection being a local area network (LAN), and the communication mode of the reference communication connection being a second communication mode other than a LAN.

[0013] The compensation connection unit is used to establish the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information, wherein the second communication connection establishment information is the information of the first device used to establish the first communication connection.

[0014] Fourthly, embodiments of this application provide a device connection apparatus applied to a second device, the apparatus comprising:

[0015] The sending unit is configured to, in the event that the establishment of a first communication connection with the first device fails, send first communication connection establishment information to the first device via a successfully established reference communication connection with the first device, for establishing the first communication connection; the first communication mode of the first communication connection is a local area network (LAN), and the communication mode of the reference communication connection is a second communication mode other than a LAN; the first communication connection establishment information is used by the first device, in conjunction with second communication connection establishment information, to establish the first communication connection with the second device, and the second communication connection establishment information is information from the first device for establishing the first communication connection.

[0016] Fifthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the device connection method of the first device or the steps in the device connection method of the second device.

[0017] Sixthly, embodiments of this application provide a computer-readable storage medium, i.e., a storage medium, on which a computer program is stored, which, when executed by a processor, implements the device connection method of the first device or the device connection method of the second device described above.

[0018] The device connection method, apparatus, device, and storage medium provided in this application embodiment allow a first device to obtain first communication connection establishment information of the second device for establishing the first communication connection when the first communication connection fails to be established, through a successfully established reference communication connection. The first communication mode of the first communication connection is a local area network (LAN), and the communication mode of the reference communication connection is a second communication mode other than a LAN. The first device establishes the first communication connection with the second device through the first and second communication connection establishment information, where the second communication connection establishment information is the information of the first device for establishing the first communication connection. Thus, a communication connection corresponding to a LAN is obtained based on a communication mode other than a LAN, so as to compensate for the communication shortcomings of the LAN through other communication modes, and realize the LAN-based connection between the first device and the second device in the extended network segment. Attached Figure Description

[0019] Figure 1 This is an optional architecture diagram of the wireless communication system provided in an embodiment of this application;

[0020] Figure 2A This is an optional flowchart illustrating the device connection method provided in an embodiment of this application;

[0021] Figure 2B This is an optional flowchart illustrating the device connection method provided in an embodiment of this application.

[0022] Figure 3 This is an optional schematic diagram of the connection between the first device and the second device provided in an embodiment of this application;

[0023] Figure 4 This is an optional flowchart illustrating the device connection method provided in an embodiment of this application;

[0024] Figure 5 This is an optional flowchart illustrating the device connection method provided in an embodiment of this application;

[0025] Figure 6 This is an optional flowchart illustrating the device connection method provided in an embodiment of this application;

[0026] Figure 7 This is an optional flowchart illustrating the device connection method provided in an embodiment of this application;

[0027] Figure 8 This is an optional flowchart illustrating the device connection method provided in an embodiment of this application;

[0028] Figure 9 This is an optional flowchart illustrating the device connection method provided in an embodiment of this application;

[0029] Figure 10 This is an optional flowchart illustrating the device connection method provided in an embodiment of this application;

[0030] Figure 11 This is an optional structural schematic diagram of the device connection device provided in an embodiment of this application;

[0031] Figure 12 This is an optional structural schematic diagram of the device connection device provided in an embodiment of this application;

[0032] Figure 13 This is an optional structural schematic diagram of the electronic device provided in the embodiments of this application. Detailed Implementation

[0033] 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.

[0034] The embodiments of this application can provide a device connection method and apparatus, a device, and a storage medium. In practical applications, the device connection method can be implemented by an information processing device, and the functional entities in the information processing device can be collaboratively implemented by the hardware resources of a computer device (such as headphones, terminal devices), such as computing resources like processors, and communication resources (such as those used to support various communication methods such as optical cables and cellular networks).

[0035] Of course, the embodiments of this application are not limited to providing methods and hardware, and can also be implemented in various ways, such as providing a storage medium (stored with instructions for executing the device connection method provided in the embodiments of this application).

[0036] The device connection method provided in this application embodiment can be applied to... Figure 1 The wireless communication system shown is as follows: Figure 1As shown, the wireless communication system includes a first device 10 and a second device 20. The first device 10 and the second device 20 can establish multiple communication connections and communicate using one of multiple communication methods corresponding to these connections. The communication methods corresponding to the communication connections between the first device and the second device include multiple of the following: local area network (LAN), direct communication, and internet communication. The LAN can include wireless LAN and wired LAN. Wireless LANs include Wireless Fidelity (WiFi) and Zigbee, etc. Direct communication includes Bluetooth, acoustic communication, and device-to-device (D2D) communication based on mobile networks, etc. Internet communication can be implemented using protocols such as Message Queuing Telemetry Transport (MQTT) and Hypertext Transfer Protocol (HTTP) for data communication. When the Internet communication uses the MQTT protocol, the wireless communication system also includes an MQTT server. The first device establishes a connection with the MQTT server through Internet communication, and the second device establishes a connection with the MQTT server through Internet communication, so that the first device and the second device establish a communication connection through the MQTT server when they are connected to Internet communication.

[0037] One of the first and second devices is a control device, and the other is a controlled device. In one example, the first device is a control device capable of controlling the second device, and the second device is a controlled device capable of being controlled by the first device. In another example, the first device is a controlled device capable of being controlled by the second device, and the second device is a control device capable of controlling the first device.

[0038] In this embodiment, if the first communication connection fails to be established, the first device 10 obtains the first communication connection establishment information of the second device 20 used to establish the first communication connection by establishing a successful reference communication connection; the first communication mode of the first communication connection is a local area network, and the communication mode of the reference communication connection is a second communication mode other than a local area network; the first device 10 establishes the first communication connection with the second device 20 through the first communication connection establishment information and the second communication connection establishment information, where the second communication connection establishment information is the information of the first device 10 used to establish the first communication connection.

[0039] In this embodiment, the control device can be a terminal device, which can refer to an access terminal, user equipment (UE), user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent, or user device. The access terminal can be a cellular phone, cordless phone, Session Initiation Protocol (SIP) phone, Wireless Local Loop (WLL) station, Personal Digital Assistant (PDA), handheld device with wireless communication capabilities, computing device or other processing device connected to a wireless modem, in-vehicle device, wearable device, terminal device in a 5th generation (5G) network, or terminal device in a future Public Land Mobile Network (PLMN), etc. The controlled device can include: mobile phones, smart washing machines, air conditioners, refrigerators, projectors, air purifiers, electronic locks, and other home appliances.

[0040] Below, in conjunction with Figure 1 The schematic diagram of the wireless communication system shown illustrates various embodiments of the device connection method, apparatus, device, and storage medium provided in this application.

[0041] This application provides a device connection method, which is applied to a first device. Figure 2A This is a schematic diagram illustrating the implementation flow of the device connection method for the first device according to an embodiment of this application, as shown below. Figure 2A As shown, the method may include the following steps:

[0042] S201A: If the first communication connection fails to be established, the first device obtains the first communication connection establishment information of the second device used to establish the first communication connection by establishing a successful reference communication connection.

[0043] The first communication connection uses a local area network (LAN) as its first communication method, and the reference communication connection uses a second communication method other than a LAN. Here, the reference communication connection includes one or more communication connections, and the second communication method includes one or more communication methods other than a LAN.

[0044] In this embodiment of the application, the local area network may include wireless local area networks and wired local area networks. Wireless local area networks include WiFi, Zigbee, etc. The second communication method includes communication methods outside the local area network, such as direct communication and Internet communication. Direct communication includes Bluetooth, acoustic communication, D2D based on mobile networks, etc., and Internet communication may be implemented by using protocols such as MQTT and HTTP to achieve data communication.

[0045] In one example, the first communication method is WiFi, and the second communication method includes Bluetooth and a data network. In this case, the reference communication connections include: a Bluetooth communication connection and a data network connection.

[0046] In one example, the first communication method is WiFi, and the second communication method is Bluetooth. In this case, the reference communication connection includes: Bluetooth communication connection.

[0047] In one example, the first communication method is WiFi, and the second communication method is a data network. In this case, the reference communication connection includes: a data network connection.

[0048] The first device may be equipped with a control program, and the user can trigger the connection with the second device by operating the control program. Here, the control program receives the user's search device operation and triggers a search device command based on the user's search device operation.

[0049] After receiving the search device command, the first device attempts to establish the following communication connections with the second device: a first communication connection using a local area network (LAN) as the communication method, i.e., a LAN communication connection, and a reference communication connection using a second communication method.

[0050] When the first device establishes a reference communication connection with the second device, but does not establish a first communication connection with the second device, it sends a connection information acquisition request to the second device through the established reference communication connection in order to obtain the first communication connection establishment information of the second device. When the second device receives the connection information acquisition request, it sends the first communication connection establishment information to the first device through the reference communication connection.

[0051] The first communication connection establishment information is the information required for the second device to establish a first connection with the first device. In one example, the first communication connection is a WiFi connection corresponding to WiFi, and the first communication connection establishment information includes at least one of the following: the Service Set Identifier (SSID) of the local area network accessed by the second device, the Internet Protocol (IP) address of the second device in the accessed local area network, the subnet mask of the second device in the accessed local area network, etc.

[0052] In this embodiment, the first device obtains first communication connection establishment information through one or more of the reference communication connections already established with the second device. When the reference communication connections include a direct communication connection and an internet communication connection, the first device can obtain the first communication connection establishment information from the second device through one or both of these connections. When the reference communication connection includes a direct communication connection, the first device obtains the first communication connection establishment information from the second device through the direct communication connection. When the reference communication connection includes an internet communication connection, the first device obtains the first communication connection establishment information from the second device through the internet communication connection.

[0053] S202A: The first device establishes the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information.

[0054] The second communication connection establishment information is the information used by the first device to establish the first communication connection.

[0055] After obtaining the first communication connection establishment information through the reference communication connection, the first device compares its own second communication connection establishment information with the obtained first communication connection establishment information. If the first device determines that the first device and the second device are on the same local area network, the first device establishes a first communication connection with the second device. If the first device determines that the first device and the second device are on different local area networks, the first device abandons the attempt to establish a first communication connection with the second device. In this case, the first device can communicate with the second device through the reference communication connection to control the second device.

[0056] The second communication connection establishment information is the necessary information required for the first device to establish a first communication connection with the second device. In one example, the first communication connection is a WiFi connection corresponding to WiFi. The second communication connection establishment information includes: the SSID of the local area network accessed by the first device, the IP address of the first device in the accessed local area network, the subnet mask of the first device in the accessed local area network, and other information.

[0057] Here, after obtaining the first communication connection establishment information, the first device sends a connection establishment request carrying the second communication connection establishment information to the second device based on the first communication connection information to establish a connection with the second device. This connection establishment request can use a transport protocol such as User Datagram Protocol (UDP) or Transmission Control Protocol (TCP). If the connection establishment request uses TCP, the second device sends an acknowledgment message to the first device. If the first device receives the acknowledgment message sent by the second device, it returns an acknowledgment message to the second device, thereby completing the establishment of the first communication connection between the first device and the second device.

[0058] Here, if the first device and the second device are located on the same local area network, they can be located on different network segments, and in this case, the subnet masks are different.

[0059] It should be noted that when the first device and the second device are located on the same network segment of the same local area network, the first device and the second device can discover each other through the local area network and establish a first communication connection; when the first device and the second device are located on different network segments of the same local area network, the first device and the second device cannot discover each other through the local area network and therefore cannot establish a first communication connection.

[0060] The device connection method provided in this application embodiment involves a first device, in the event that a first communication connection fails to be established, acquiring first communication connection establishment information of the second device used to establish the first communication connection through a successfully established reference communication connection. The first communication mode of the first communication connection is a local area network (LAN), and the communication mode of the reference communication connection is a second communication mode other than a LAN. The first device establishes the first communication connection with the second device through the first and second communication connection establishment information, where the second communication connection establishment information is the information used by the first device to establish the first communication connection. Thus, the connection establishment information required by the second device to establish the first communication connection is obtained based on a communication mode other than a LAN, thereby establishing the first communication connection. This compensates for the communication deficiencies of the LAN through other communication modes, enabling a LAN-based connection between the first device and the second device in the extended network segment.

[0061] This application provides a device connection method, which is applied to a second device. Figure 2B This is a schematic diagram illustrating the implementation flow of the device connection method for the second device according to an embodiment of this application, as shown below. Figure 2B As shown, the method may include the following steps:

[0062] S201B: If the second device fails to establish a first communication connection with the first device, it sends a first communication connection establishment message to the first device through a reference communication connection that was successfully established with the first device.

[0063] The first communication method of the first communication connection is a local area network (LAN), and the communication method of the reference communication connection is a second communication method other than a LAN. The first communication connection establishment information is used by the first device to establish the first communication connection with the second device in combination with the second communication connection establishment information. The first communication connection establishment information is the information of the second device establishing the first communication connection, and the second communication connection establishment information is the information of the first device establishing the first communication connection.

[0064] The first device attempts to establish the following communication connections with the second device: a first communication connection using a local area network (LAN) as the communication method, i.e., a LAN communication connection; and a reference communication connection using a second communication method. The second communication method includes one or more communication methods other than a LAN.

[0065] In this embodiment of the application, the local area network may include wireless local area networks and wired local area networks. Wireless local area networks include WIFI, Zigbee, etc. The second communication method includes communication methods outside the local area network, such as direct communication and Internet communication. Direct communication includes Bluetooth, acoustic communication, D2D based on mobile networks, etc., and Internet communication may be implemented by using protocols such as MQTT and HTTP to achieve data communication.

[0066] In one example, the first communication method is WiFi, and the second communication method includes Bluetooth and a data network. In this case, the reference communication connections include: a Bluetooth communication connection and a data network connection.

[0067] In one example, the first communication method is WiFi, and the second communication method is Bluetooth. In this case, the reference communication connection includes: Bluetooth communication connection.

[0068] In one example, the first communication method is WiFi, and the second communication method is a data network. In this case, the reference communication connection includes: a data network connection.

[0069] When the first device establishes a reference communication connection with the second device, but does not establish a first communication connection with the second device, it sends a connection information acquisition request to the second device through the established reference communication connection in order to obtain the first communication connection establishment information of the second device. When the second device receives the connection information acquisition request, it sends the first communication connection establishment information to the first device through the reference communication connection.

[0070] The first communication connection establishment information is the information required for the second device to establish a first communication connection with the first device. In one example, the first communication connection is a WiFi connection corresponding to WiFi, and the first communication connection establishment information includes at least one of the following: the SSID of the local area network accessed by the second device, the IP address of the second device in the accessed local area network, the subnet mask of the second device in the accessed local area network, etc.

[0071] In this embodiment, the second device sends a first communication connection establishment message to the first device through one or more of the reference communication connections already established with the first device. When the reference communication connections include a direct communication connection and an internet communication connection, the second device can send the first communication connection establishment message to the first device through one or both of these connections. When the reference communication connection includes a direct communication connection, the second device sends the first communication connection establishment message to the first device through the direct communication connection. When the reference communication connection includes an internet communication connection, the second device sends the first communication connection establishment message to the first device through the internet communication connection.

[0072] After receiving the first communication connection establishment information, the first device compares its own second communication connection establishment information with the acquired first communication connection establishment information. If the first device determines that it and the second device are on the same local area network (LAN), the first device establishes a first communication connection with the second device. If the first device determines that it and the second device are on different LANs, the first device abandons the attempt to establish a first communication connection with the second device. In this case, the first device can communicate with the second device through a reference communication connection to control the second device.

[0073] The second communication connection establishment information is the information required for the first device to establish a local area network connection with the second device; in one example, the first communication connection is a WiFi connection corresponding to WiFi, and the second communication connection establishment information includes at least one of the following: the SSID of the local area network accessed by the first device, the IP address of the first device in the accessed local area network, the subnet mask of the first device in the accessed local area network, etc.

[0074] Here, if the first device and the second device are located on the same local area network, they can be located on different network segments, and in this case, the subnet masks are different.

[0075] It should be noted that when the first device and the second device are located on the same network segment of the same local area network, the first device and the second device can discover each other through the local area network and establish a first communication connection; when the first device and the second device are located on different network segments of the same local area network, the first device and the second device cannot discover each other through the local area network and therefore cannot establish a first communication connection.

[0076] The device connection method provided in this application embodiment involves a second device, when failing to establish a first communication connection with a first device, sending first communication connection establishment information to the first device through a successfully established reference communication connection with the first device. The first communication mode of the first communication connection is a local area network (LAN), and the communication mode of the reference communication connection is a second communication mode other than a LAN. The first communication connection establishment information is used by the first device, in conjunction with the second communication connection establishment information, to establish the first communication connection with the second device. The second communication connection establishment information is information used by the first device to establish the first communication connection. This allows the first device to obtain a communication connection corresponding to a LAN based on a communication mode other than a LAN, compensating for the communication shortcomings of the LAN through other communication methods, and enabling a LAN-based connection between the first device and the second device in the extended network segment.

[0077] In some embodiments, the method further includes: the first device discovering the second device from a first channel and a reference channel respectively; the communication mode corresponding to the first channel is the first communication mode, and the communication mode corresponding to the reference channel is the second communication mode; if the first device does not discover the second device from the first channel, the first device determines that the first communication connection has failed to be established; if the first device discovers the second device from the reference channel, the first device establishes the reference communication connection with the second device.

[0078] Here, the communication method of the first channel is a local area network (LAN), which can be called a LAN channel; the communication method of the reference channel is a second communication method, which may include one or more of the second and third channels. Specifically, the communication method of the second channel is direct communication, which can be called a direct communication channel; the communication method of the third channel is internet communication, which can be called an internet communication channel. In other words, the second communication method includes one or more of direct communication and internet communication.

[0079] When the first device receives a device search command, it performs device discovery to determine whether the second device is included among the connectable devices. Here, upon receiving the device search command, the first device detects whether the second device is included among the connectable devices corresponding to each communication method based on the first channel and the reference channel, in order to determine whether the first device can establish a corresponding communication connection with the second device.

[0080] If the first device does not find any connectable devices based on the first channel, or if the found connectable devices do not include the second device, then it is determined that the second device is not a connectable device based on the local area network, and the first device cannot establish a first communication connection with the second device.

[0081] When the first device discovers that the second device is a connectable device based on the reference channel, it determines that the second device is a connectable device based on the second communication method, and the first device establishes a reference communication connection with the second device.

[0082] In some embodiments, the reference channel includes: a second channel for direct communication and a third channel for internet communication. When the first device discovers the second device through the reference channel, establishing the reference communication connection between the first device and the second device includes:

[0083] The first device establishes a second communication connection with the second device; the communication mode of the second communication connection is direct communication; the first device establishes a third communication connection with the second device; the communication mode of the third communication connection is Internet communication.

[0084] Here, when the first device receives a device search command, it triggers the first channel, the second channel, and the third channel to discover the second device in order to determine whether the second device is a connectable device based on the following communication methods: local area network, direct communication, and Internet communication.

[0085] When the first device discovers that the second device is a connectable device based on direct communication via a direct communication channel, the first device establishes a direct communication connection with the second device. When the first device discovers that the second device is a connectable device based on internet communication via an internet communication channel, the first device establishes an internet communication connection with the second device.

[0086] In this embodiment of the application, the communication methods supported by the second device may include: local area network (LAN), direct communication, and internet communication. In one example, such as... Figure 3 As shown, taking WiFi as the local area network, Bluetooth as the direct communication method, and MQTT as the Internet communication method as an example, the second device 300 includes WiFi service 301, Bluetooth service 302 and MQTT service 303. Among them, the communication method supported by the local area network service is WiFi, the communication method supported by the Bluetooth service is Bluetooth, and the communication method supported by the MQTT service is MQTT.

[0087] In one example, when the first device obtains the first communication connection establishment information through a direct communication connection, it can obtain the first communication connection establishment information from the direct communication service; in this case, the direct communication service obtains the first connection establishment information from the local area network service. When the first device obtains the first communication connection establishment information through an internet communication connection, it can obtain the first communication connection establishment information from the internet communication service; in this case, the internet communication service obtains the first connection establishment information from the local area network service.

[0088] In some embodiments, the method further includes:

[0089] When the first device discovers the second device through the first channel, the first device establishes the first communication connection with the second device.

[0090] In this embodiment of the application, when the first device discovers that the second device is a connectable device based on the local area network channel, it establishes a first communication connection with the second device.

[0091] In this embodiment of the application, for a channel in which the second device is detected to be a connectable device, the first device establishes a corresponding communication connection with the second device based on the communication method corresponding to the channel.

[0092] In the embodiments of this application, such as Figure 4 As shown, the connection established between the first device 41 and the second device 42 includes: a local area network communication connection 401, a direct communication connection 402, and an Internet communication connection 403.

[0093] In this embodiment of the application, when multiple communication connections are established between the first device and the second device, the first device and the second device communicate based on one of the multiple communication connections. The communication connection can be selected based on the following methods:

[0094] Method 1: Random selection;

[0095] Method 2: Based on the communication connection corresponding to the highest priority communication method.

[0096] In this embodiment of the application, when multiple communication connections are established between the first device and the second device, the selection method of the communication connection for communication between the first device and the second device is not limited in any way.

[0097] In some embodiments, the second communication method includes direct communication and internet communication. The reference communication connection includes a second communication connection with direct communication as the communication method and a third communication connection with internet communication as the communication method. In S202A implemented by the electronic device, by obtaining the first communication connection establishment information of the second device for establishing the first communication connection through the successfully established reference communication connection, it can be implemented as follows: determining the priority of direct communication and internet communication; selecting a target communication connection from the second communication connection and the third communication connection according to the obtained priority; the communication method of the target communication connection is the communication method with higher priority among direct communication and internet communication; the first device obtains the first communication connection establishment information through the target communication connection.

[0098] Here, when the second communication method includes direct communication and internet communication, the reference communication connection includes a second communication connection and a third communication connection. The first device selects the communication connection with the higher priority of the communication method from the reference communication connections based on the priority of direct communication and the priority of internet communication, and obtains the first communication connection establishment information from the second device based on the target communication connection. At this time, the second device sends the first communication connection establishment information to the first device based on the target communication connection.

[0099] In one example, taking Bluetooth as the direct communication method and MQTT as the Internet communication method, Bluetooth has a higher priority than MQTT. The first device uses Bluetooth to obtain the first communication connection establishment information from the second device, and the second device sends the first communication connection establishment information to the first device through the second communication connection.

[0100] In one example, taking Bluetooth as the direct communication method and MQTT as the Internet communication method, Bluetooth has a lower priority than MQTT. Therefore, the first device uses the MQTT communication connection to obtain the first communication connection establishment information from the second device, and the second device sends the first communication connection establishment information to the first device through the third communication connection.

[0101] In some embodiments, before the first device establishes the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information, the method further includes:

[0102] The first device detects whether the first device has established the first communication connection with the second device;

[0103] If the detection result indicates that the first communication connection with the second device has not been established, the first device determines to establish the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information.

[0104] Here, after the first device obtains the first communication connection establishment information, but before establishing the first communication connection based on the first communication connection information, it is determined whether the first device has already established a first communication connection with the second device. In this embodiment, the information of the first device or the second device accessing the local area network may change. When the information of the first device or the second device accessing the local area network changes, the first device and the second device may be located in the same network segment. At this time, the first device and the second device can discover each other and establish a first communication connection based on the changed information. In this case, the first device does not need to establish a first communication connection with the second device based on the obtained first communication connection establishment information. When the first device and the second device have not established a first communication connection, the first device establishes a first communication connection with the second device through the obtained first communication connection establishment information.

[0105] In some embodiments, the second communication method includes: direct communication and Internet communication, and the method further includes:

[0106] When the first device communicates with the second device using the communication connection corresponding to the third communication method, it is detected whether the communication connection corresponding to the third communication method meets the corresponding communication connection interruption condition; the third communication method is any one of the local area network, the direct communication, and the Internet communication.

[0107] If the communication connection corresponding to the third communication method meets the corresponding communication connection interruption condition, the first device uses the communication connection corresponding to the fourth communication method to communicate with the second device. The fourth communication method is one of the following, other than the third communication method: the local area network, the direct communication, and the Internet communication. The third communication method has a higher priority than the fourth communication method.

[0108] The third communication method is any one of the following: local area network, direct communication, and Internet communication. The fourth communication method is a communication method with lower priority than the third communication method, other than the third communication method, among the following: local area network, direct communication, and Internet communication.

[0109] In this embodiment of the application, when the first device and the second device communicate using a communication connection corresponding to a high-priority communication method, if the current communication connection meets the corresponding communication connection interruption condition, then the first device and the second device cannot continue to communicate using the current communication connection.

[0110] Here, the communication connection interruption conditions for different communication connections may be the same or different.

[0111] In one example, for different communication connections, the communication connection interruption condition includes: no heartbeat packet is received within a set time threshold. The time threshold can be 5 milliseconds (ms), 10 ms, 15 ms, etc. The time thresholds for different communication connections can be the same or different.

[0112] In one example, the communication connection interruption conditions corresponding to the first communication connection include: the local area network signal strength is less than a first signal threshold, and the data transmission rate is less than a first rate threshold; the communication connection interruption conditions corresponding to the second communication connection include: the distance between the first device and the second device is greater than a distance threshold, and the data transmission rate is less than a second rate threshold; the communication connection interruption conditions corresponding to the third communication connection include: the first device disconnects from the Internet, the second device disconnects from the Internet, and the data transmission rate is less than a third rate threshold. In this embodiment, no limitations are imposed on the communication connection interruption conditions corresponding to each communication connection.

[0113] The thresholds, such as the first signal threshold, first rate threshold, distance threshold, second rate threshold, and third rate threshold, involved in the embodiments of this application can be data set based on actual experience or data obtained based on experimental tests. The embodiments of this application do not impose any limitations on the magnitude of each threshold. In one example, the second rate threshold is less than the third rate threshold, and the third rate threshold is less than the first rate threshold; for example, the first transmission rate is 50 kilobits per second (kbps), the second rate threshold is 5 kbps, and the third rate threshold is 10 kbps.

[0114] When the first device and the second device can no longer communicate based on the current communication connection, they will use a communication connection corresponding to the fourth communication method, which has a relatively lower priority, to achieve communication degradation. The priorities for LAN, direct communication, and internet communication are different.

[0115] In this embodiment of the application, the priority of a communication connection corresponds to the priority of its corresponding communication method. For a communication connection, if the priority of its corresponding communication method is high, then the priority of the communication connection is high; if the priority of its corresponding communication method is low, then the priority of the communication connection is low.

[0116] In one example, the priority order of LAN, direct communication, and Internet communication from high to low is: LAN, direct communication, and Internet communication. When the third communication method is LAN, the fourth communication method is: direct communication; when the third communication method is LAN, the fourth communication method is: Internet communication; when the third communication method is direct communication, the fourth communication method is: Internet communication.

[0117] In some embodiments, the method further includes:

[0118] When the first device communicates with the second device using the communication connection corresponding to the fifth communication mode, it checks whether the communication connection corresponding to the sixth communication mode meets the corresponding communication connection recovery condition. The fifth communication mode is any one of the local area network, the direct communication, and the Internet communication, and the sixth communication mode is any one of the local area network, the direct communication, and the Internet communication other than the fifth communication mode. The priority of the fifth communication mode is lower than the priority of the sixth communication mode. If the communication connection corresponding to the sixth communication mode meets the corresponding communication connection recovery condition, the first device communicates with the second device using the communication connection corresponding to the sixth communication mode.

[0119] In this embodiment of the application, when a high-priority communication connection meets the corresponding connection interruption condition, and the first device and the second device communicate using a communication connection corresponding to a low-priority communication method, the first device detects whether the high-priority communication connection meets the corresponding communication connection recovery condition. When the high-priority communication connection meets the corresponding communication connection recovery condition, it indicates that the high-priority communication connection is available.

[0120] Here, the communication connection recovery conditions for different communication connections may be the same or different.

[0121] In one example, the communication recovery conditions for different communication connections include: receiving a heartbeat packet based on the corresponding communication connection.

[0122] In one example, the communication connection recovery conditions for the first communication connection include: the local area network signal strength is greater than a second signal threshold, and the data transmission rate is greater than a fourth rate threshold; the communication connection recovery conditions for the second communication connection include: the distance between the first device and the second device is less than a distance threshold, and the data transmission rate is greater than a fifth rate threshold; the communication connection recovery conditions for the third communication connection include: the first device establishes a connection with the Internet, the second device establishes a connection with the Internet, and the data transmission rate is greater than a sixth rate threshold. In this embodiment, no limitations are imposed on the communication connection recovery conditions for each communication connection.

[0123] The thresholds, such as the second signal threshold, fourth rate threshold, distance threshold, fifth rate threshold, and sixth rate threshold, involved in the embodiments of this application can be data set based on actual experience or data obtained based on experimental tests. The embodiments of this application do not impose any limitations on the magnitude of each threshold. In one example, the fifth rate threshold is less than the sixth rate threshold, and the sixth rate threshold is less than the fourth rate threshold; for example, the fourth transmission rate is 50 kilobits per second (kbps), the fifth rate threshold is 5 kbps, and the sixth rate threshold is 10 kbps.

[0124] When the first device detects that communication can be conducted based on a high-priority communication connection, it switches the communication connection from the current one to the high-priority one, using the communication connection corresponding to the sixth communication mode, thus upgrading the communication. The priorities for LAN, direct communication, and internet communication are different.

[0125] In one example, the priority order of LAN, direct communication and Internet communication from high to low is: LAN, direct communication and Internet communication. When the fifth communication method is direct communication, the sixth communication method is LAN. When the fifth communication method is Internet communication, the fourth communication method is direct communication. When the third communication method is Internet communication, the fourth communication method is LAN.

[0126] In some embodiments, the second communication method includes: direct communication and Internet communication, and the method further includes:

[0127] If the first device cannot connect to the second device via the seventh communication connection, it locates the fault information of the seventh communication connection via the eighth communication connection. The seventh communication connection is one of the first, second, and third communication connections, and the eighth communication connection is another of the first, second, and third communication connections except for the seventh communication connection. The second communication connection uses direct communication, and the third communication connection uses Internet communication. The first device outputs the fault information.

[0128] In this embodiment, when there is a successfully established seventh communication connection and an unsuccessfully established eighth communication connection among the three communication connections supported by the first device and the second device, connection information for the eighth communication connection can be obtained from the second device using the seventh communication connection. Based on the obtained connection information, fault information reflecting the unsuccessful establishment of the eighth communication connection is determined and output, allowing the user to know the reason why the seventh communication connection was not established. The fault information characterizes the reason why the eighth communication connection was not established.

[0129] In this embodiment, the fault information corresponding to different communication connections may be different. In one example, the fault information corresponding to the first communication connection includes: the second device is not connected to the local area network (LAN), the second device is not connected to the LAN, the first device and the second device are not in the same LAN, or the first device and the second device are connected to the same LAN but are not in the same network segment. In one example, the fault information corresponding to the second communication connection includes: the second device is not connected to the LAN, or the first device and the second device are far apart. In one example, the fault information corresponding to the third communication connection includes: the second device is not connected to the Internet, or the MQTT service is not enabled.

[0130] In this embodiment of the application, the first device determines the communication mode of the eighth communication connection and obtains connection information from the second device based on the communication mode of the eighth communication connection.

[0131] In one example, the eighth communication connection is a local area network (LAN) communication connection. The first device obtains the connection information from the second device used to establish the LAN communication connection via direct communication or internet communication, and determines a fault information indicating that the LAN communication connection was not successfully established based on the obtained connection information. The obtained connection information may include: a first identifier indicating the LAN open status of the second device, a second identifier indicating whether the second device is connected to the LAN, the LAN identifier (e.g., SSID) of the LAN the second device is connected to, the IP address of the second device in the connected LAN, and the subnet mask of the second device in the connected LAN. In this case, the fault information determined by the first device based on the obtained connection information includes one of the following: the second device is not connected to the LAN; the second device is not connected to the LAN; the first device and the second device are connected to different LANs; or the first device and the second device are connected to the same LAN but on different network segments.

[0132] In one example, the eighth communication connection is a direct communication connection. The first device obtains the connection information from the second device used to establish the direct communication connection via a local area network (LAN) or the internet. Based on the obtained connection information, it determines a fault message indicating that the direct communication connection was not successfully established. The obtained connection information may include: a third identifier indicating the second device's direct communication activation status, a fourth identifier indicating whether the second device has established a direct communication connection, the location information of the second device, and the signal strength of the wireless LAN accessed by the second device. In this case, the fault message determined by the first device based on the obtained connection information includes one of the following: the second device has not activated direct communication, or the distance between the first and second devices is too great.

[0133] In one example, the eighth communication connection is an internet communication connection. The first device obtains the connection information from the second device used to establish the internet communication connection via a local area network or direct communication. Based on the obtained connection information, it determines a fault message indicating that the internet communication connection was not successfully established. The obtained connection information includes: the internet communication status of the second device, the MQTT service status of the second device, etc. In this case, the fault message determined based on the connection information includes one of the following: the second device has not enabled internet communication, or the MQTT service has not been enabled.

[0134] In this embodiment, connection information of unsuccessfully established communication connections is obtained through successfully established communication connections, and fault information representing unsuccessful establishment is determined based on the obtained connection information, so that users can intuitively locate the reason why the communication connection was not established.

[0135] In this embodiment of the application, no limitations are imposed on the fault information corresponding to each communication connection.

[0136] The following describes the device connection method provided in this application embodiment, taking a mobile phone as the first device and a projection device as the controlled device as the second device, WiFi as the first communication method and Bluetooth and MQTT-based Internet communication as the second communication methods.

[0137] When a mobile phone and a projector are connected only via a local area network (LAN), i.e., a wireless LAN, the following technical issues arise:

[0138] 1. Slow connection establishment speed;

[0139] 2. Poor network conditions and unstable connection;

[0140] 3. The mobile phone and the projector are on the same local area network but different network segments, and the mobile phone cannot find the projector.

[0141] 4. If the mobile phone cannot connect to the projection device, the mobile phone cannot know the specific reason for the connection failure;

[0142] 5. The projection device cannot be remotely controlled if the devices are not on the same local area network.

[0143] In this embodiment, the mobile phone and the projection device can establish a connection using a multi-mode connection scheme. In this scheme, the mobile phone connects simultaneously via local area network, MQTT, and Bluetooth (BLE), and automatically selects the most suitable communication method based on the current network conditions. If the current communication method is unstable, the communication method between the mobile phone and the projection device switches to another method, thereby ensuring the best user experience for both devices.

[0144] The device connection method provided in this application includes the following aspects:

[0145] Firstly, it provides three communication methods between mobile phones and projection devices: Communication method 1, wireless LAN; Communication method 2, MQTT; Communication method 3, BLE.

[0146] Wireless LANs offer advantages such as high transmission speed, long communication distance, large data transmission capacity, and high real-time performance. However, they also have disadvantages such as the projection device and mobile phone needing to be on the same LAN and network segment, and unstable communication if the network bandwidth is occupied by other services. Suitable application scenarios include: screen mirroring, image transfer, file transfer, and gaming.

[0147] MQTT has the advantages of being usable as long as mobile phones and projection devices are connected to the Internet (data network) and having no communication distance restrictions, but it also has the disadvantages of not being able to communicate directly with mobile phones and projection devices, relying on MQTT services, and having low real-time performance. Applicable scenarios include: remote operation.

[0148] BLE offers advantages such as fast connection speed, independence from network conditions and third-party services, and high real-time performance, but also disadvantages such as short communication distance and small data transmission volume. Its applicable scenarios include: nearby device discovery, fast connection, and simple commands.

[0149] In this embodiment, the advantages of the three communication methods are combined to establish a connection, while compensating for their respective disadvantages.

[0150] The process of connecting a mobile phone to a projection device includes:

[0151] S11. The phone discovers connectable devices;

[0152] The mobile phone runs a control program that controls the projection device. After the control program is started, the mobile phone simultaneously searches for connectable devices from the wireless LAN channel, MQTT channel, and BLE channel.

[0153] The process by which a mobile phone searches for connectable devices from a Wi-Fi network is as follows: Figure 5 As shown, it includes:

[0154] S501, The mobile phone receives the search command.

[0155] Search commands are used to indicate the search for connectable devices.

[0156] S502: The phone determines whether a hotspot is enabled or whether it is connected to WiFi.

[0157] If the phone is connected to a hotspot or WiFi, execute S5031; otherwise, execute S5032 and the search will terminate.

[0158] S5031, Mobile phone sends broadcast.

[0159] Broadcasts emitted by mobile phones can only be heard by devices on the same segment of the same Wi-Fi network. These broadcasts can include UDP broadcasts.

[0160] For projection device 51, which is on the same router as the mobile phone but on a different network segment, the broadcast sent by the mobile phone cannot reach the projection device 51.

[0161] For projection device 52, which is on the same network segment and under the same router as the mobile phone, projection device 52 performs the following steps:

[0162] S521, Broadcast received;

[0163] S522, Reply to UDP message.

[0164] The projection device 52 sends a UDP message back to the mobile phone as a broadcast reply, and the mobile phone will receive the UDP message replied by the projection device 52.

[0165] S504: How does the mobile phone determine if it has received a reply to the broadcast?

[0166] If the mobile phone receives a reply to the broadcast (i.e., a UDP message), execute S505; otherwise, continue executing S5031.

[0167] S505: The mobile phone adds the projection device to the device list.

[0168] Here, the devices in the device list are the connectable devices discovered by the phone.

[0169] S506, Return to device list.

[0170] S507, the mobile phone displays the connectable devices in the device list.

[0171] The implementations of S5031 to S506 can be integrated into the mobile phone's software development kit (gmSDK) 50.

[0172] The process by which a mobile phone searches for connectable devices from an MQTT channel is as follows: Figure 6 As shown, it includes:

[0173] S601, The mobile phone receives the search command.

[0174] S602: The mobile phone determines whether it is connected to the Internet.

[0175] If the phone is connected to the internet, execute S6031; otherwise, execute S6032 and the search will terminate.

[0176] S6031. Use your mobile phone to obtain the online status of the projection device.

[0177] Here, when the mobile phone obtains the online status of the projection device 62 from the MQTT server 61, the MQTT server 61 includes: device online service 611 and MQTT broker 612, and the device online service 611 includes an online device list 6111.

[0178] The projection device 62 includes an MQTT service 621 that interacts with the MQTT server 61. When the MQTT service 621 publishes an online / offline message to the MQTT broker 612, and when the device online service 611 subscribes to the projection device's online information from the MQTT broker 612, the MQTT broker 612 notifies the device online service 611 that the projection device 62 is online or offline based on the online / offline message published by the MQTT service 621, and records the online status of the projection device 62 in the online device list 6111.

[0179] The mobile phone obtains the online status of the projection device 62 from the online device list 6111, and the online device list 6111 returns the online status of the projection device 62 to the mobile phone, so that the mobile phone can obtain the online status of the projection device.

[0180] S604. Is the device online?

[0181] The mobile phone determines whether the projection device is online based on the online status information returned by the MQTT server. If online, execute S6051 to confirm the device can be connected. If offline, execute S6052 to confirm the device cannot be connected.

[0182] If the projector is online, the phone will determine that the projector is connectable, meaning the projector is among the connectable devices. If the projector is offline, the phone will determine that the projector is not connectable, meaning the projector is among the connectable devices.

[0183] For projection devices, the local MQTT service publishes online / offline messages to the MQTT broker on the MQTT server. The MQTT broker then forwards these messages to the device online service on the MQTT server. The device online service synchronizes the projection device's online information to the online device list. The device online service receives online status requests from mobile phones to retrieve the projection device's online status, queries the online device list for its online status, and returns the retrieved status to the mobile phone.

[0184] The process by which a mobile phone searches for connectable devices from a BLE channel is as follows: Figure 7 As shown, it includes:

[0185] S701, The mobile phone receives the search command.

[0186] S702, enable Bluetooth peripheral service on your phone.

[0187] When the mobile phone enables Bluetooth peripheral service, the projector 71 executes S703 based on Bluetooth service 711 and sends a BLE broadcast. At this time, the mobile phone executes S704.

[0188] S704, mobile phone receives BLE broadcast.

[0189] S705: How does a mobile phone determine if a data packet belongs to a projection device?

[0190] The mobile phone determines whether the received BLE broadcast is a data packet from the projection device. If the received BLE broadcast is a data packet from the projection device, it executes S7061 to determine that the device can be connected, which means that the connectable devices include the projection device. Otherwise, it executes S7062 to determine that the projection device is not a connectable device, which means that the connectable devices do not include the projection device.

[0191] S12. The mobile phone establishes a connection with the connectable device.

[0192] For any channel that a projection device can connect to, the mobile phone establishes a corresponding communication connection with the projection device.

[0193] When the mobile phone determines that the projection device can be connected based on the wireless LAN channel, the mobile phone obtains the IP address of the projection device and performs a direct UDP broadcast based on the IP address. If the mobile phone receives a reply from the projection device in response to the UDP broadcast, the wireless LAN communication connection is successfully established.

[0194] When the mobile phone determines that the projection device can be connected based on the MQTT channel, and the projection device is online in the device online service, the mobile phone, as a client of the MQTT server, connects to the MQTT server and completes message subscription, then the MQTT-based communication connection between the mobile phone and the projection device is considered to be successfully established.

[0195] Once the mobile phone determines that the projection device can be connected via Bluetooth, and discovers a projection device that can be connected via BLE, the mobile phone directly establishes a BLE connection with the projection device, that is, establishes a Bluetooth-based communication connection with the projection device.

[0196] For channels that cannot be connected to by the projection device, the mobile phone compensates for the necessary information for establishing the corresponding communication connection by establishing a communication connection.

[0197] Assuming successful connections are established using all three communication methods, the local area network (LAN) provides the best experience. For Wi-Fi, the phone needs to obtain the projector's IP address within the LAN. Even if the phone and projector are on the same LAN but on different network segments, the phone cannot obtain the projector's IP address through device discovery. In this case, the projector's IP address can be obtained using a successfully established MQTT-based or BLE-based communication connection.

[0198] The process by which the mobile phone obtains the IP address of the projection device using a successfully established MQTT-based or BLE-based communication connection is as follows: Figure 8 As shown, it includes:

[0199] S801, Mobile phone searches for devices on the local area network.

[0200] S802, the mobile phone determines whether it is on a different network segment than the projection device.

[0201] If the mobile phone determines that it is on a different network segment than the projection device, it executes S8031 and S8032; otherwise, it executes S8033.

[0202] S8031, the mobile phone determines whether an MQTT connection has been established.

[0203] If an MQTT connection has already been established, execute S8041; otherwise, execute S8043 and terminate the search.

[0204] S8032, the mobile phone determines whether a BLE connection has been established.

[0205] If a BLE connection has already been established, execute S8042; otherwise, execute S8043 and terminate the search.

[0206] Here, if neither an MQTT connection nor a BLE connection is established, the search terminates and connection compensation ends.

[0207] S8033, Detects connectable devices on the local area network.

[0208] S8041, The mobile phone obtains the IP address of the projection device via MQTT.

[0209] The mobile phone obtains the IP address of the projection device from the MQTT service in the projection device through an MQTT connection with the projection device.

[0210] S8042, The mobile phone obtains the IP address of the projection device via BLE.

[0211] The mobile phone obtains the IP address of the projection device from the BLE service in the projection device through a BLE connection with the projection device.

[0212] In this embodiment of the application, the projection device 81 includes: MQTT service 811, local area network connection service 812, and BLE service 813.

[0213] MQTT service 811 is used to send the IP address of the projection device to the mobile phone via MQTT, enabling the mobile phone to obtain the IP address of the projection device through MQTT. BLE service 813 is used to send the IP address of the projection device to the mobile phone via BLE, enabling the mobile phone to obtain the IP address of the projection device through BLE.

[0214] If the mobile phone obtains the IP address of the projection device, it executes S805.

[0215] S805: The mobile phone determines whether a wireless LAN connection has been established.

[0216] If a wireless LAN connection has already been established, the process ends; otherwise, proceed to S806.

[0217] S806: The mobile phone and the projection device establish a wireless local area network connection.

[0218] After the mobile phone establishes a wireless LAN connection with the projection device, it receives UDP messages sent by the projection device and sends UDP messages to the projection device.

[0219] In this embodiment, the projection device provides wireless LAN service, MQTT service and BLE service respectively. The mobile phone establishes a wireless LAN connection with the wireless LAN service in the projection device, establishes an MQTT connection with the MQTT service in the projection device, and establishes a BLE connection with the BLE service in the projection device.

[0220] S13. The mobile phone selects the main communication method for communicating with the projection device based on the current communication scenario.

[0221] (1) When the three communication connections of wireless LAN, MQTT and BLE are successfully established, the mobile phone selects the primary communication method according to the priority of the three communication methods. The priority order of the three communication methods of wireless LAN, MQTT and BLE is as follows: high priority: local area network, medium priority: BLE, low priority: MQTT.

[0222] The mobile phone selects the highest priority communication method, Wi-Fi, as the primary communication method based on the priority of the three communication methods.

[0223] (2) Automatic switching of communication methods

[0224] Communication mode downgrade: When a mobile phone controls a projection device using a high-priority communication method, the communication connection may be interrupted or unstable due to the following reasons: router failure, internet connection interruption, leaving the BLE Bluetooth communication range, or network jitter. In this case, the mobile phone will switch the communication mode from high priority to low priority to ensure continued control of the projection device.

[0225] like Figure 9 As shown, during the execution of S901, which is to control the device based on the local area network, the phone detects that S902, the wireless local area network communication connection is lost. At this time, the phone cannot communicate with the wireless local area network service 911 in the projection device 92. Then, the phone executes S903, which switches the communication mode to BLE mode, and executes S904, which is to control the device based on BLE mode.

[0226] When the mobile phone executes S904 to control the projection device based on BLE (i.e., via Bluetooth communication), it detects that the BLE communication connection is lost in S905. At this time, the mobile phone cannot communicate with the Bluetooth service 912 of the projection device 91. Then, the mobile phone executes S906 to switch the communication method to MQTT and executes S907 to control the device based on MQTT.

[0227] Here, when the mobile phone executes S907, it communicates with the MQTT service 913 in the projection device 91 through the MQTT cloud service (MQTT cloud server) 92 to control the projection device.

[0228] Communication method upgrade: When a mobile phone controls a projection device using a low-priority communication method, if the communication connection corresponding to a high-priority communication method is restored, the mobile phone will switch the communication method from low priority to high priority to improve the control experience.

[0229] like Figure 10 As shown, during the process of controlling the projection device via MQTT communication (S1001), the mobile phone detects that the BLE connection has been restored (S1002). Then, it executes S1003, switches the communication mode to BLE, and executes S1004, controls the projection device via BLE communication (S1004), which uses the BLE communication connection to communicate with the Bluetooth service to control the projection device.

[0230] If the phone detects that S1005, the local area network connection has been restored, during the execution of S1004, the phone will execute S1006, switch the communication mode to local area network mode, and then execute S1007, control based on local area network mode. That is, the phone will communicate with the wireless local area service in the projection device based on the wireless local area communication connection to control the projection device.

[0231] When the mobile phone is controlling the device via a local area network (LAN), it interacts with the LAN connection service 911 in the projection device 91 using UDP messages.

[0232] Secondly, based on the characteristics of the three communication methods, the reasons why the mobile phone cannot communicate with the projection device can be determined.

[0233] 1. Analysis of Wireless LAN Connection Failure

[0234] When the local area network (LAN) cannot be connected (including cases where it cannot be connected even after compensation), the current SSID, IP address, and subnet mask of the projection device can be obtained from other communication methods and compared with the SSID, IP address, and subnet mask of the mobile phone. This will determine whether the mobile phone and the projection device are on the same LAN and the same network segment, thus revealing the reason why the LAN cannot be connected.

[0235] 2. Bluetooth connection failure analysis

[0236] When Bluetooth fails to connect, the phone obtains information from other communication methods, such as the projector's Bluetooth status and Wi-Fi signal strength, and analyzes this information along with the phone's Bluetooth status, Wi-Fi signal strength, and location information. This analysis determines whether Bluetooth is not enabled or whether the phone and projector are too far apart, thus identifying the reason for the connection failure.

[0237] 3. MQTT connection failed.

[0238] When MQTT fails to connect, the mobile phone can obtain information from other communication methods to determine whether the projection device is connected to the MQTT online service, thus identifying the reason for the connection failure.

[0239] To implement the above-described device connection method, this application provides a device connection apparatus 1100, applied to a first device, such as... Figure 11 As shown, the device 1100 includes:

[0240] The acquisition unit 1101 is used to acquire, in the event that the establishment of the first communication connection with the second device fails, the first communication connection establishment information of the second device used to establish the first communication connection through a reference communication connection that has been successfully established with the second device; the first communication mode of the first communication connection is a local area network, and the communication mode of the reference communication connection is a second communication mode other than a local area network.

[0241] The compensation connection unit 1102 is used to establish the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information, wherein the second communication connection establishment information is the information of the first device used to establish the first communication connection.

[0242] In some embodiments, the device 1100 further includes:

[0243] The discovery unit is used to discover the second device from the first channel and the reference channel respectively; the communication mode corresponding to the first channel is the first communication mode, and the communication mode corresponding to the reference channel is the second communication mode;

[0244] The determining unit is configured to determine that the first communication connection has failed to be established if the first device fails to detect the second device from the first channel.

[0245] The first establishment unit is configured to establish the reference communication connection with the second device when the first device discovers the second device from the reference channel.

[0246] In some embodiments, the first establishing unit is further configured to: the reference channel includes: a second channel with a direct communication mode and a third channel with an Internet communication mode.

[0247] A second communication connection is established with the second device; the communication mode of the second communication connection is direct communication, and the communication mode of the second channel included in the reference channel is direct communication;

[0248] A third communication connection is established with the second device; the communication mode of the third communication connection is Internet communication, and the communication mode of the third channel included in the reference channel is a data connection.

[0249] In some embodiments, the apparatus 1100 further includes a second establishing unit, configured to establish the first communication connection with the second device when the first device discovers the second device from the first channel.

[0250] In some embodiments, the acquiring unit 1101 is further configured to:

[0251] When the second communication method includes direct communication and Internet communication, the priority of direct communication and Internet communication is determined; the reference communication connection includes a second communication connection with direct communication as the communication method and a third communication connection with Internet communication as the communication method.

[0252] Based on the obtained priority, a target communication connection is selected from the second communication connection and the third communication connection; the communication mode of the target communication connection is the higher priority communication mode between the direct communication and the Internet communication.

[0253] The first communication connection establishment information is obtained through the target communication connection.

[0254] In some embodiments, the device 1100 further includes:

[0255] The judgment unit is used to detect whether the first device has already established the first communication connection with the second device before the first device establishes the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information.

[0256] If the detection result indicates that the first communication connection with the second device has not been established, it is determined that the first communication connection is established with the second device through the first communication connection establishment information and the second communication connection establishment information.

[0257] In some embodiments, the device 1100 further includes: a first switching unit, configured to:

[0258] When the second communication method includes direct communication and Internet communication, and the communication connection corresponding to the third communication method is used to communicate with the second device, it is detected whether the communication connection corresponding to the third communication method meets the corresponding communication connection interruption condition; the third communication method is any one of the local area network, the direct communication, and the Internet communication.

[0259] If the communication connection corresponding to the third communication method meets the corresponding communication connection interruption condition, the communication connection corresponding to the fourth communication method is used to communicate with the second device. The fourth communication method is one of the following: local area network, direct communication, and Internet communication, excluding the third communication method. The third communication method has a higher priority than the fourth communication method.

[0260] In some embodiments, the device 1100 further includes: a second switching unit, configured to:

[0261] When the second communication method includes direct communication and Internet communication, and the communication connection corresponding to the fifth communication method is used to communicate with the second device, it is detected whether the communication connection corresponding to the sixth communication method meets the corresponding communication connection recovery conditions; the fifth communication method is any one of the local area network, the direct communication, and the Internet communication, and the sixth communication method is any one of the local area network, the direct communication, and the Internet communication other than the fifth communication method, and the priority of the fifth communication method is lower than the priority of the sixth communication method;

[0262] If the communication connection corresponding to the sixth communication mode meets the corresponding communication connection recovery conditions, the communication connection corresponding to the sixth communication mode is used to communicate with the second device.

[0263] In some embodiments, the device 1100 further includes:

[0264] The positioning unit is used to locate the fault information of the seventh communication connection through the eighth communication connection when the second communication method includes direct communication and Internet communication, and the second device cannot be connected through the seventh communication connection. The seventh communication connection is one of the first communication connection, the second communication connection, and the third communication connection, and the eighth communication connection is one of the first communication connection, the second communication connection, and the third communication connection other than the seventh communication connection. The communication method of the second communication connection is direct communication, and the communication method of the third communication connection is Internet communication.

[0265] The output unit is used to output the fault information.

[0266] To implement the above-described device connection method, this application provides a device connection apparatus 1200, applied to a second device, such as... Figure 12 As shown, the device 1200 includes:

[0267] The sending unit 1201 is configured to, in the event that the establishment of a first communication connection with the first device fails, send first communication connection establishment information to the first device through a successfully established reference communication connection with the first device, for establishing the first communication connection; the first communication mode of the first communication connection is a local area network (LAN), and the communication mode of the reference communication connection is a second communication mode other than a LAN; the first communication connection establishment information is used by the first device, in conjunction with second communication connection establishment information, to establish the first communication connection with the second device, and the second communication connection establishment information is information from the first device for establishing the first communication connection.

[0268] It should be noted that the various logic units included in the device connection device provided in this application embodiment can be implemented by a processor in an electronic device; of course, they can also be implemented by specific logic circuits; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field-programmable gate array (FPGA), etc.

[0269] The description of the system embodiments above is similar to that of the method embodiments above, and has similar beneficial effects. For technical details not disclosed in the system embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0270] It should be noted that, in the embodiments of this application, if the above-described page display method is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.

[0271] This application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the device connection method implemented by the first device or the steps in the device connection method implemented by the second device.

[0272] Correspondingly, embodiments of this application provide a storage medium, namely a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the device connection method implemented by the first device provided in the above embodiments, or implements the device connection method implemented by the second device provided in the above embodiments.

[0273] It should be noted that the descriptions of the storage medium embodiments above are similar to those of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0274] It should be noted that, Figure 13 This is a schematic diagram of a hardware entity of an electronic device (first device or second device) according to an embodiment of this application, such as... Figure 13 As shown, the electronic device 1300 includes: a processor 1301, at least one communication bus 1302, at least one external communication interface 1304, and a memory 1305. The communication bus 1302 is configured to enable communication between these components. In one example, the electronic device 1300 further includes: a user interface 1303, which may include a display screen; and the external communication interface 1304 may include standard wired and wireless interfaces.

[0275] The memory 1305 is configured to store instructions and applications executable by the processor 1301, and can also cache data to be processed or already processed by the processor 1301 and various modules in the electronic device (e.g., image data, audio data, voice communication data and video communication data), which can be implemented by flash memory or random access memory (RAM).

[0276] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in some embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.

[0277] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0278] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0279] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0280] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0281] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.

[0282] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0283] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A device connection method, characterized in that, The method includes: If the first device fails to establish a first communication connection with the second device, it obtains the first communication connection establishment information of the second device used to establish the first communication connection through a successfully established reference communication connection with the second device. The first communication mode of the first communication connection is a local area network (LAN), and the communication mode of the reference communication connection is a second communication mode other than a LAN. If the first device does not detect the second device from the first channel, the first device determines that the first communication connection has failed to establish. The first channel corresponds to the first communication mode. The first device establishes the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information, where the second communication connection establishment information is the information used by the first device to establish the first communication connection. When the first device discovers the second device through the first channel, the first device establishes the first communication connection with the second device.

2. The method according to claim 1, characterized in that, The method further includes: The first device discovers the second device from both the first channel and the reference channel; the reference channel corresponds to the second communication method. When the first device discovers the second device from the reference channel, the first device establishes the reference communication connection with the second device.

3. The method according to claim 2, characterized in that, The reference channel includes: a second channel with direct communication and a third channel with internet communication; the step of establishing the reference communication connection between the first device and the second device when the first device discovers the second device through the reference channel includes: The first device establishes a second communication connection with the second device; the communication mode of the second communication connection is direct communication. The first device establishes a third communication connection with the second device; the communication method of the third communication connection is Internet communication.

4. The method according to claim 1, characterized in that, The second communication method includes: direct communication and internet communication. The reference communication connection includes a second communication connection with direct communication and a third communication connection with internet communication. The step of obtaining the first communication connection establishment information of the second device for establishing the first communication connection through a successfully established reference communication connection includes: Determine the priority between direct communication and internet communication; Based on the obtained priority, a target communication connection is selected from the second communication connection and the third communication connection; the communication mode of the target communication connection is the higher priority communication mode between the direct communication and the Internet communication. The first communication connection establishment information is obtained through the target communication connection.

5. The method according to claim 1, characterized in that, Before the first device establishes the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information, the method further includes: The first device detects whether the first device has established the first communication connection with the second device; If the detection result indicates that the first communication connection with the second device has not been established, the first device determines to establish the first communication connection with the second device through the first communication connection establishment information and the second communication connection establishment information.

6. The method according to claim 1, characterized in that, The second communication method includes: direct communication and Internet communication, and the method further includes: When the first device communicates with the second device using a communication connection corresponding to the third communication method, the first device detects whether the communication connection corresponding to the third communication method meets the corresponding communication connection interruption condition; the third communication method is any one of the local area network, the direct communication, and the Internet communication. If the communication connection corresponding to the third communication method meets the corresponding communication connection interruption condition, the first device uses the communication connection corresponding to the fourth communication method to communicate with the second device. The fourth communication method is one of the following, other than the third communication method: the local area network, the direct communication, and the Internet communication. The third communication method has a higher priority than the fourth communication method.

7. The method according to claim 1, characterized in that, The second communication method includes: direct communication and Internet communication, and the method further includes: When the first device communicates with the second device using the communication connection corresponding to the fifth communication mode, it detects whether the communication connection corresponding to the sixth communication mode meets the corresponding communication connection recovery conditions; the fifth communication mode is any one of the local area network, the direct communication, and the Internet communication, and the sixth communication mode is any one of the local area network, the direct communication, and the Internet communication other than the fifth communication mode, and the priority of the fifth communication mode is lower than the priority of the sixth communication mode; When the communication connection corresponding to the sixth communication mode meets the corresponding communication connection recovery conditions, the first device uses the communication connection corresponding to the sixth communication mode to communicate with the second device.

8. The method according to claim 1, characterized in that, The second communication method includes: direct communication and Internet communication, and the method further includes: If the first device cannot connect to the second device through the seventh communication connection, it locates the fault information of the seventh communication connection through the eighth communication connection. The seventh communication connection is one of the first communication connection, the second communication connection, and the third communication connection. The eighth communication connection is one of the first communication connection, the second communication connection, and the third communication connection other than the seventh communication connection. The communication mode of the second communication connection is direct communication, and the communication mode of the third communication connection is Internet communication. The first device outputs the fault information.

9. A device connection method, characterized in that, The method includes: If the second device fails to establish a first communication connection with the first device, it sends first communication connection establishment information to the first device through a successfully established reference communication connection with the first device. The first communication mode of the first communication connection is a local area network (LAN), and the communication mode of the reference communication connection is a second communication mode other than a LAN. The first communication connection establishment information is used by the first device to establish the first communication connection with the second device in conjunction with the second communication connection establishment information, whereby the second communication connection establishment information is the information used by the first device to establish the first communication connection. Wherein, if the second device is not detected by the first device through the first channel, the first communication connection between the second device and the first device fails to be established; the first channel corresponds to the first communication method; If the second device is discovered by the first device through the first channel, the second device establishes the first communication connection with the first device.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the device connection method according to any one of claims 1 to 8, or the steps of the device connection method according to claim 9.

11. A storage medium storing an executable program, characterized in that, When the executable program is executed by the processor, it implements the device connection method according to any one of claims 1 to 8, or the device connection method according to claim 9.

Citation Information

Patent Citations

  • Method and device for establishing wireless connection, equipment and storage medium

    CN112654020A

  • Network distribution method and device of intelligent equipment, electronic equipment and computer readable medium

    CN112770308A