Communication method, terminal equipment and computer readable storage medium

By switching to long-distance connections when short-distance connection resources are insufficient, the problem of limited number of concurrent connections of devices is solved and higher concurrent connection capabilities are achieved.

CN120692137APending Publication Date: 2025-09-23HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410340157.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-22
Publication Date
2025-09-23

AI Technical Summary

Technical Problem

In complex distributed business scenarios, when an initiating device establishes concurrent connections with multiple receiving devices, there is a problem of limited number of concurrent connections, especially when short-distance connection resources are limited, which cannot meet the connection needs of the devices.

Method used

By using a long-distance connection method to establish interconnection with the receiving device when the current communication conditions do not meet the short-distance connection requirements, the number of concurrent connections is limited due to the limitation of short-distance connection resources.

Benefits of technology

When short-distance connection resources are insufficient, it switches to long-distance connection mode, thereby increasing the number of concurrent connections of devices and meeting the interconnection needs of multiple devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120692137A_ABST
    Figure CN120692137A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of terminals, and provides a communication method, terminal equipment and a computer readable storage medium, the method is applied to first equipment, a first operation is received, and the first operation is used for starting a distributed service; in response to the first operation, displaying an icon of a second device, the second device being a device which is found based on a short-distance communication mode and supports distributed services, short-distance connection and long-distance connection; in response to a second operation, determining a current communication condition, the second operation including an operation acting on selecting an icon of the second device, the second operation instructing the first device to share data with the second device; and when the current communication condition does not meet the short-distance connection requirement, establishing a first long-distance connection with the second device. The method can solve the problem that the number of concurrent connections of equipment is limited.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a communication method, a terminal device, and a computer-readable storage medium. Background Art

[0002] With the increasing number of personal smart terminals and home Internet of Things (IOT) terminal devices, such as mobile phones, tablets, PCs, smart cars, smart screens, wearable devices, cameras, sweeping robots, smart curtains, etc., the interconnection and data sharing between terminal devices have become an important demand of users. In some complex distributed business scenarios, such as screen projection, file sharing, etc., when the initiating device discovers multiple receiving devices that support distributed services (such as screen projection services) through broadcast messages, the initiating device needs to establish connections with these receiving devices through Bluetooth (bluetooth) or wireless fidelity direct (wireless fidelity direct, Wifi-direct) and other methods. However, in some cases where the initiating device needs to establish concurrent connections with multiple receiving devices, the initiating device has the problem of limited number of concurrent connections. Summary of the Invention

[0003] To this end, the present application provides a communication method, a terminal device, and a computer-readable storage medium that can solve the problem of limited number of concurrent device connections.

[0004] To achieve the above objectives, this application adopts the following technical solutions:

[0005] In a first aspect, a communication method is provided, applied to a first device, the method comprising:

[0006] A first operation is received, where the first operation is used to start a distributed service; in response to the first operation, an icon of a second device is displayed, where the second device is a device that supports distributed services, short-range connections, and long-range connections and is discovered based on a short-range communication method; in response to a second operation, current communication conditions are determined, where the second operation includes an operation acting on the icon of the second device, where the second operation instructs the first device to share data with the second device; when the current communication conditions do not meet the short-range connection requirements, a first long-range connection is established with the second device.

[0007] Among them, the first device may refer to a terminal device, the communication method may be executed by the terminal device, or by a module applied in the terminal device (such as a processor, chip, or chip system, etc.), or by a logic module or software that can realize all or part of the terminal device functions.

[0008] In the present application, the first device responds to the second operation to determine whether the current communication conditions meet the short-distance connection requirements. When the current communication conditions do not meet the short-distance connection requirements, it means that the first device is temporarily unable to establish interconnection with the second device through a short-distance connection. In order for the first device to be able to connect to more external devices (for example, the second device) concurrently, the first device can use a long-distance connection to establish a first long-distance connection with the second device, thereby avoiding the problem of limited number of concurrent connections of devices due to the current communication conditions not meeting the short-distance connection requirements.

[0009] In one possible implementation, the method also includes: before displaying the icon of the second device: sending broadcast information, the broadcast information including a first identifier, a first request information and a second request information, the first identifier being the identifier of the first device, the first request information being used to inquire whether distributed services are supported, and the second request information being used to inquire whether short-distance connections and / or long-distance connections are supported; receiving first response information, the first response information including a second identifier, a first indication information and a second indication information, the second identifier being the identifier of the second device, the first indication information indicating that the second device supports distributed services, and the second indication information indicating that the second device supports short-distance connections and / or long-distance connections; displaying the icon of the second device, including: displaying the icon of the second device according to the first response information.

[0010] Before displaying the icon of the second device, the first device will inquire the second device through broadcast information whether it supports distributed services and whether it supports short-distance connection and / or long-distance connection; wherein, the second device is a device near the first device; thereafter, the first device determines whether the second device supports short-distance connection and long-distance connection based on the first response information replied by the second device, thereby determining the connection method with the second device.

[0011] In a possible implementation, the first response information further includes a third identifier, and the third identifier is used to establish the first long-distance connection with the second device.

[0012] In some cases, the second device sends the third identifier to the first device through the first response information, and the first device does not need to obtain the third identifier through a new message or control signaling, thereby reducing resource consumption.

[0013] In a possible implementation, the broadcast information further includes third indication information, where the third indication information instructs the second device to send a third identifier.

[0014] In some cases, in order for the first device to quickly establish a long-distance connection with the second device when necessary to ensure communication quality, the first device will carry a third indication message when sending a broadcast message to instruct the second device to send a third identifier (for example, the second device can carry a third identifier when replying to the first response message) so that the first device can establish a long-distance connection with the second device based on the third identifier.

[0015] In a possible implementation, the broadcast information further includes first channel information, where the first channel information is information about a short-range connection channel currently used by the first device.

[0016] In some cases, when sending broadcast information, the first device carries the first channel information in the broadcast information so that other nearby devices (eg, the second device) can determine whether a short-range connection can be established with the first device through channel multiplexing.

[0017] In one possible implementation, determining the current communication conditions includes: determining the current number of connections, where the current number of connections is the number of short-range connections established by the first device; wherein the current communication conditions do not meet the short-range connection requirements, including: the current number of connections is equal to a number threshold, where the number threshold is the maximum number of short-range connections supported by the first device.

[0018] In some cases, when the current number of connections reaches a number threshold, the first device can no longer establish a connection with other nearby devices (for example, the second device) through a short-distance connection; at this time, after receiving the second operation, the first device will determine the current number of connections; when the current number of connections reaches the number threshold, it means that the current communication conditions do not meet the short-distance connection requirements, and the first device cannot currently use the short-distance connection to establish a connection with the second device; it can be seen that the first device determines an available connection method (for example, a long-distance connection method) for the second device by judging the current number of connections, thereby avoiding the situation where the first device cannot connect due to the number threshold limit.

[0019] In one possible implementation, determining the current number of connections further includes: determining a current role of the first device before determining the current number of connections; determining the current number of connections includes: determining the current number of connections when the current role allows the first device to connect to the second device.

[0020] In some cases, even if the current number of connections does not reach the number threshold, the first device is temporarily unable to establish a connection with other nearby devices due to the limitation of the current role; therefore, before determining the current number of connections, the first device can first determine the current role of the first device; when the current role allows the first device to connect to the second device, the current number of connections is determined, thereby avoiding the situation where the connection cannot be established due to role restrictions.

[0021] In one possible implementation, determining the current communication condition includes determining a current role of the first device; wherein the current communication condition does not meet the short-range connection requirement, including that the current role does not allow the first device to connect to the second device.

[0022] In some cases, due to the limitations of the current role, the current communication conditions of the first device do not meet the short-distance connection requirements; therefore, the first device can determine whether the current communication conditions meet the short-distance connection requirements by judging its own current role, so that the first device can further determine the connection method with the second device.

[0023] In one possible implementation, before determining the current role of the first device, the method also includes: determining the current number of connections, where the current number of connections is the number of short-range connections established by the first device; determining the current role of the first device, including: when the current number of connections is less than a number threshold, determining that the current communication conditions meet the short-range connection requirements, where the number threshold is the maximum number of short-range connections supported by the first device.

[0024] In some cases, even if the current role of the first device allows the first device to establish a connection with other nearby devices (for example, the second device), due to the limitation on the current number of connections, the first device is temporarily unable to establish a connection with other receiving devices; therefore, before determining the current role of the first device, the first device can first determine the current number of connections; when the current number of connections is less than the number threshold, it indicates that the current communication conditions meet the short-distance connection requirements, and then determine whether the current role allows connection to the second device, thereby avoiding the situation where the connection cannot be established due to the current connection number limitation.

[0025] In a possible implementation, the method further includes: when the current communication condition meets the short-range connection requirement, establishing a first short-range connection with the second device.

[0026] In some scenarios, when current communication conditions meet the short-distance connection requirements, the first device and the second device establish an interconnection through the short-distance connection to reduce the resource cost of data sharing.

[0027] In a possible implementation, the method further includes: when the transmission resources of the first short-distance connection do not meet the transmission requirements, establishing a second long-distance connection with the second device.

[0028] In some scenarios, although the first device has established a first short-distance connection with the second device, when the transmission resources of the first short-distance connection do not meet the transmission requirements, the first device can quickly switch from the short-distance connection to the long-distance connection and establish a second long-distance connection with the second device, thereby ensuring the normal transmission of data between the first device and the second device.

[0029] In one possible implementation, establishing a second long-distance connection with a second device includes: sending control information to the second device through the first short-distance connection without receiving a third identifier from the second device, the control information including a first identifier and instruction information, the instruction information being used to instruct the second device to send a third identifier, and the third identifier being also used to establish a second long-distance connection with the second device; receiving second response information from the second device, the second response information including a second identifier and a third identifier, the second identifier being the identifier of the second device; and establishing a second long-distance connection with the second device based on the third identifier.

[0030] In some scenarios, the first device and the second device have established a short-distance communication link, for example, a Bluetooth communication link has been established through the short-distance connection; the first device can send control information to the second device through the first short-distance communication link to obtain the third identifier of the second device, thereby ensuring that when the transmission resources of the first short-distance connection do not meet the transmission requirements, the first device can quickly establish a long-distance connection with the second device; it can be seen that the first device obtains the third identifier through the first short-distance communication link, and there is no need to obtain the third identifier again through Bluetooth broadcasting, the interaction method is simple, and resource consumption is small.

[0031] In a possible implementation, the second device is a device corresponding to a contact of the first device.

[0032] In some cases, users may want to share data (such as files, videos, etc.) with their friend devices. At this time, the first device can carry contact information when broadcasting information, so that other nearby devices (such as the second device) can determine whether they are friend devices of the first device (that is, the device corresponding to the contact of the first device) based on the contact information in the broadcast information.

[0033] In a second aspect, another communication method is provided, which is applied to a second device, and the method includes:

[0034] Receive broadcast information of the first device, the broadcast information includes a first identifier, a first request information and a second request information, the first identifier is the identifier of the first device, the first request information is used to inquire whether distributed services are supported, and the second request information is used to inquire whether short-distance connection and / or long-distance connection are supported. The distributed service is a service started by the first device in response to the first operation; when the broadcast information does not include contact information, send a first response information to the first device, the first response information includes a second identifier, a first indication information, a second indication information and a third identifier, the second identifier is the identifier of the second device, the first indication information indicates that the second device supports distributed services, the second indication information indicates that the second device supports short-distance connection and / or long-distance connection, the third identifier is used to establish a first long-distance connection with the first device, and the contact information is used to determine whether the second device is the device corresponding to the contact.

[0035] Among them, the second device may refer to a terminal device, and the communication method may be executed by the terminal device, or by a module applied in the terminal device (such as a processor, chip, or chip system, etc.), or by a logic module or software that can realize all or part of the terminal device functions.

[0036] In the above method, the second device receives the broadcast information sent by the first device; when the broadcast information does not include contact information, the second device can reply to the first response information based on the broadcast information without having to determine whether it is a friend device of the first device, so as to feedback to the first device that it supports short-distance connection and long-distance connection, thereby facilitating the first device to determine the connection method with itself (i.e., the second device).

[0037] In one possible implementation, the broadcast information also includes first channel information, which is information about the short-distance connection channel currently used by the first device; before sending the first response information to the first device, the method also includes: when the second channel information is inconsistent with the first channel information, obtaining a third identifier, where the second channel information is information about the short-distance connection channel currently used by the second device.

[0038] When the broadcast information includes the first channel information, the second device can determine whether the second channel information is consistent with the first channel information; when the second channel information is inconsistent with the first channel information, it means that the second device cannot reuse the channel corresponding to the first channel information, and may need to establish a long-distance connection or use other channels to establish a short-distance connection; at this time, the second device can obtain a third identifier, for example, obtain the third identifier from a remote server, so as to establish a long-distance connection with the first device.

[0039] In a possible implementation, the broadcast information further includes third indication information, the third indication information instructs the second device to send a third identifier, the third identifier is used to establish a first long-distance connection with the first device, and the first response information further includes the third identifier.

[0040] In some cases, in order for the first device to quickly establish a long-distance connection with the second device when necessary to ensure normal data transmission, the first device will carry a third indication message when sending a broadcast message to instruct the second device to send a third identifier; the second device can carry the third identifier through the first response message; this makes it easier for the first device to establish a long-distance connection with the second device.

[0041] In one possible implementation, the above method also includes: when the broadcast information includes contact information, when the second device is the device corresponding to the contact information, sending first response information to the first device; or, when the second device is not the device corresponding to the contact information, determining not to send the first response information to the first device.

[0042] In some cases, users may want to share data (such as files, videos, etc.) with their friend devices. At this time, the first device can carry contact information when broadcasting information, so that other nearby devices (such as the second device) can determine whether they are friend devices of the first device based on the contact information in the broadcast information; when the second device is a friend device of the first device (that is, the second device is the device corresponding to the contact information), it replies with a first response message to the first device; when the second device is not a friend device of the first device (that is, the second device is not the device corresponding to the contact information), it determines not to reply with the first response message to the first device.

[0043] In a possible implementation, the method further includes: when the second channel information is consistent with the first channel information, determining not to acquire the third identifier; and establishing a first short-range connection with the first device.

[0044] In some cases, when a first device sends a broadcast message, it includes the first channel information in the broadcast message, so that other nearby devices (e.g., a second device) can determine whether they can establish a short-range connection with the first device through channel multiplexing. When the broadcast message includes the first channel information, the second device can determine whether the second channel information is consistent with the first channel information. When the second channel information is consistent with the first channel information, it indicates that the second device can reuse the channel corresponding to the first channel information to establish a short-range connection with the first device. At this time, the second device does not need to obtain the third identifier temporarily. Since the second device does not need to obtain the third identifier from the remote server temporarily, some network resources can be saved for other business data transmission.

[0045] In a possible implementation manner, the method further includes: when the transmission resources of the first short-distance connection do not meet the transmission requirements, establishing a second long-distance connection with the first device.

[0046] In some scenarios, although the first device has established a first short-distance connection with the second device, when the transmission resources of the first short-distance connection do not meet the transmission requirements, the first device can quickly switch from the short-distance connection to the long-distance connection and establish a second long-distance connection with the second device, thereby ensuring the communication quality between the first device and the second device.

[0047] In one possible implementation, establishing a second long-distance connection with a second device includes: when the first device does not save the third identifier, receiving control information of the first device through the first short-distance connection, the control information including the first identifier and instruction information, the instruction information being used to instruct the second device to send the third identifier, the third identifier being used to establish a second long-distance connection with the first device; sending second response information to the first device, the second response information including the second identifier and the third identifier; and establishing a second long-distance connection with the first device through the third identifier.

[0048] In some scenarios, the first device and the second device have established a short-distance communication link, for example, a Bluetooth communication link has been established through the short-distance connection; the first device can send control information to the second device through the first short-distance communication link to obtain the third identifier of the second device, thereby ensuring that when the transmission resources of the first short-distance connection do not meet the transmission requirements, the first device can quickly establish a long-distance connection with the second device; it can be seen that the first device obtains the third identifier through the first short-distance communication link, and there is no need to obtain the third identifier again through Bluetooth broadcasting, the interaction method is simple, and resource consumption is small.

[0049] In a third aspect, an embodiment of the present application provides a terminal device, which includes a processor and a memory, the memory being used to store computer programs, and the processor being used to call and run computer programs from the memory, so that the terminal device executes the method described in the first aspect and various possible implementations of the first aspect.

[0050] In a fourth aspect, an embodiment of the present application provides a terminal device, which includes a processor and a memory, the memory being used to store computer programs, and the processor being used to call and run computer programs from the memory, so that the terminal device executes the method described in the second aspect and various possible implementations of the second aspect.

[0051] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor executes the method described in the first aspect and various possible implementations of the first aspect.

[0052] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor executes the method described in the second aspect and various possible implementations of the second aspect.

[0053] In the seventh aspect, an embodiment of the present application provides a computer program product, which includes: computer program code, which, when run by a terminal device, enables the terminal device to execute the method described in the first aspect and various possible implementations of the first aspect.

[0054] In an eighth aspect, an embodiment of the present application provides a computer program product, which includes: a computer program code, which, when executed by a terminal device, enables the terminal device to execute the method described in the second aspect and various possible implementations of the second aspect.

[0055] In the ninth aspect, an embodiment of the present application provides a chip system, which includes a processing circuit and a storage medium, in which computer program instructions are stored; when the computer program instructions are executed by the processing circuit, the method described in the first aspect and various possible implementations of the first aspect is implemented.

[0056] In the tenth aspect, an embodiment of the present application provides a chip system, which includes a processing circuit and a storage medium, in which computer program instructions are stored; when the computer program instructions are executed by the processing circuit, the method described in the second aspect and various possible implementations of the second aspect is implemented.

[0057] Optionally, the processing circuit in the above chip system can be replaced by a processor, and the storage medium can be replaced by a memory. Optionally, the chip system can also include a communication interface, which is used to realize communication between the chip system and the receiving device.

[0058] The beneficial effects of the technical solutions in the third to tenth aspects of the present application may be the same as the beneficial effects of the technical solutions in the first or second aspects, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1A to Figure 1B Schematic diagram of application scenarios provided by embodiments of the present application;

[0060] Figure 2 A schematic diagram of the hardware structure of a terminal device 100 provided in an embodiment of the present application;

[0061] Figure 3 A schematic diagram of the software architecture of a terminal device 100 provided in an embodiment of the present application;

[0062] Figure 4 A schematic diagram of the software architecture of the first device provided in an embodiment of the present application;

[0063] Figure 5 A flow chart of a communication method 500 provided in an embodiment of the present application;

[0064] Figure 6A A schematic diagram of a first device discovering a receiving device provided in an embodiment of the present application;

[0065] Figure 6B A schematic diagram of another method of a first device discovering a receiving device provided in an embodiment of the present application;

[0066] Figure 7A A schematic diagram of a network connection of a first device provided in an embodiment of the present application;

[0067] Figure 7B A schematic diagram of a process of a first device accessing an external network provided in an embodiment of the present application;

[0068] Figure 8A A schematic diagram of a network in which a first device and a second device are located is provided in an embodiment of the present application;

[0069] Figure 8B A schematic diagram of a network in which a first device and a second device are located is provided in another embodiment of the present application;

[0070] Figure 9 A flow chart of another communication method 500 provided in an embodiment of the present application;

[0071] Figure 10 A schematic diagram of establishing a second long-distance connection between a first device and a second device provided in an embodiment of the present application;

[0072] Figure 11A A schematic diagram of the architecture of a far-field P2P hole punching method provided in an embodiment of the present application;

[0073] Figure 11B A schematic diagram of the architecture of a far-field P2P relay method provided in an embodiment of the present application;

[0074] 12A to 12D A schematic diagram of a screen projection scenario provided in an embodiment of the present application;

[0075] 13A to 13D A schematic diagram of another screen projection scenario provided in an embodiment of the present application;

[0076] 14A to 14F A schematic diagram of another screen projection scenario provided in an embodiment of the present application;

[0077] FIG. 15A to FIG. 15B A schematic diagram of another screen projection scenario provided in an embodiment of the present application;

[0078] 16A to 16D A schematic diagram of a picture sharing scenario provided in an embodiment of the present application;

[0079] 17A to 17D A schematic diagram of another picture sharing scenario provided in an embodiment of the present application;

[0080] Figure 18 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0081] In order to clearly describe the technical solutions of the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application; it should be noted that the embodiments described in the present application are only part of the embodiments of the present application, not all of the embodiments.

[0082] In the description of this application, unless otherwise specified, " / " represents "or." For example, A / B can represent either A or B. In the description of this application, "and / or" is simply a term used to describe an association relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exists simultaneously, or B exists alone. "At least one" refers to one or more, and "more than one" refers to two or more. In the specification and claims of this application, the terms "first" and "second" are used to distinguish different objects or to distinguish different processing of the same object, rather than to describe a specific order of objects. For example, "first terminal" and "second terminal" are used to distinguish different terminal devices, rather than to describe a specific order of terminal devices. Those skilled in the art will understand that terms such as "first" and "second" do not limit quantity or execution order, and that terms such as "first" and "second" do not necessarily imply differences.

[0083] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described in this application as "exemplary" or "for example" should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.

[0084] To facilitate understanding of this application, some technical terms involved in this application are explained below.

[0085] 1. Wireless fidelity peer-to-peer (Wifi P2P)

[0086] Wi-Fi P2P, also known as Wi-Fi Direct, is a technology launched by the Wi-Fi Alliance that allows direct connections between devices based on existing Wi-Fi technology. This technology allows one-to-one or one-to-many communication without the need for a local area network or wireless access point (AP). In other words, Wi-Fi P2P technology allows devices on a wireless network to connect to each other without a router.

[0087] 2. P2P group owner (P2P GO)

[0088] A P2P GO is a role that functions similarly to an AP in a basic service set (BSS) infrastructure. A P2P group has only one GO, and a GO can support one or more clients.

[0089] 3. P2P client

[0090] The P2P client is another role, also known as the group client (GC), which functions similarly to the station (STA) in the BSS infrastructure.

[0091] It should be noted that in a P2P connection, one device plays the role of GO (i.e., acts as an AP), while other devices play the role of GC, where GO can be understood as the master device and GC can be understood as the slave device. After establishing P2P, GO and multiple GCs will form a group, which can be permanent or temporary. In a permanent group, GO is played by a designated device, and the configuration information and group information will not usually change after they are generated. When used subsequently, the configuration information and group information can be directly used to reduce connection time. In a temporary group, the role allocation of GO and GC is usually determined by negotiation between the two devices. Since the information in a temporary group is temporary, it must be recreated for each subsequent use, and the connection time is longer than that of a permanent group.

[0092] 4. Wireless Access Point AP

[0093] An AP bridges the gap between wired and wireless networks, adding wireless functionality to existing wired networks by bridging traffic from the wireless network to the wired network. A wireless access point can function as a standalone device or as a component of a router. For example, a wireless local area network (WLAN) system includes an AP for accessing external networks, such as a home router.

[0094] 5. Site STA

[0095] In a WLAN system, a STA is typically a client. This can be a computer with a wireless network card or a smartphone with a Wi-Fi module, and can be either mobile or stationary. For example, a WLAN system includes an AP and STAs. The STAs associate with the AP and access the network through the AP.

[0096] 6. Dynamic Host Configuration Protocol (DHCP)

[0097] DHCP, also known as Dynamic Host Configuration Protocol, is a network protocol used in Internet Protocol (IP) networks. It is located at the application layer of the Open System Interconnect (OSI) model and uses the User Datagram Protocol (UDP). It has two main uses: one is for intranets or Internet service providers to automatically assign IP addresses to users; the other is for intranet administrators to centrally manage all computers.

[0098] 7. Address Resolution Protocol (ARP)

[0099] ARP is a protocol for obtaining a physical address based on an IP address. When a host sends a message, it broadcasts an ARP request containing the target IP address to all hosts on the local network and receives a reply, thereby determining the target host's physical address. Upon receiving the reply, the host stores the IP address and the target host's physical address in its local ARP cache for a specified period of time so that it can query the ARP cache directly on subsequent requests, saving resources. ARP relies on mutual trust between hosts on the network. Hosts on the local network can autonomously send ARP replies. Upon receiving the reply, other hosts will record the reply in their local ARP cache without verifying its authenticity. In this scenario, an attacker can send a forged ARP reply to a host, causing it to fail to reach the intended host or to reach the wrong host, thereby committing ARP spoofing. ARP commands can be used to query the local ARP cache for the correspondence between IP addresses and media access control addresses (MAC addresses), as well as to add or delete static correspondences. Related protocols include RARP and proxy ARP. The Neighbor Discovery Protocol (NDP) is a key protocol of Internet Protocol version 6 (IPv6); the NDP replaces ARP in IPv6.

[0100] The following combination Figure 1A and Figure 1B Two practical application scenarios are introduced to introduce the technical problems that need to be solved by this application.

[0101] In one scenario, Wifi Direct technology, also known as near-field Wifi P2P technology, allows devices to connect to each other without going through an AP. It should be noted that in a P2P group, devices typically have two roles: GO and GC. A GO device has the same functionality as an AP, while a GC device connects to the GO. Devices that support Wifi Direct can be referred to as GOs or GCs. A GO can be understood as a master device, while a GC is a slave device. Figure 1A As shown, in the P2P group, terminal devices 1 to 7 all support the Wi-Fi direct connection function, among which terminal device 1 plays the role of GO and supports a maximum of 4 concurrent connections, that is, terminal device 1 can connect to up to 4 GC devices at the same time. For example, terminal device 1 establishes connections with terminal devices 2 to 5 respectively; terminal device 1 and terminal device 6 can no longer establish a connection (see Figure 1AThe reason is that the Wi-Fi hardware resources of terminal device 1 are limited (for example, the number of radio frequency resources in the Wi-Fi chip is limited), resulting in no more hardware resources to support it to establish connections with more terminal devices. In addition, due to the limitation of roles, terminal devices playing the GC role cannot establish connections with each other. For example, terminal device 4 playing the GC role cannot directly establish a connection with terminal device 7 playing the GC role (see Figure 1A shown in 102).

[0102] In another scenario, according to the Bluetooth technology regulations, when a pair of Bluetooth devices communicate, one must be the master and the other the slave in order to communicate normally. During communication, the master device must search and initiate pairing. After the link is successfully established, both parties can send and receive data. Usually, a master Bluetooth device can establish connections with 7 slave Bluetooth devices at the same time; for example, Figure 1B As shown, the master Bluetooth device can establish connections with 7 slave Bluetooth devices at the same time, that is, the master Bluetooth device establishes connections with slave Bluetooth devices 1 to 7 respectively; after connecting with more than 7 slave Bluetooth devices, the master Bluetooth device 1 can no longer establish connections with other slave Bluetooth devices (for example, slave Bluetooth device 8) (see Figure 1B 103 shown); The reason is that the number of radio frequency resources of the Bluetooth chip in the master Bluetooth device is limited. When the maximum number of connections supported by the radio frequency resources is exceeded, it cannot establish connections with more slave Bluetooth devices unless the connected slave Bluetooth devices are disconnected. In addition, since Bluetooth communication also has role restrictions, a Bluetooth device playing the slave role (i.e., a slave Bluetooth device) cannot establish connections with other slave Bluetooth devices unless the Bluetooth device playing the slave role switches to a Bluetooth device playing the master role (i.e., a master Bluetooth device). Only then can it establish connections with other slave Bluetooth devices. For example, slave Bluetooth device 4 cannot directly establish a connection with slave Bluetooth device 9 (see Figure 1B 104) shown.

[0103] Through the examples of the above two scenarios, it is found that whether it is Bluetooth technology, Wi-Fi direct connection technology, or other short-range communication technologies not listed, there may be a problem of limited number of concurrent connections of devices during short-range connection (also known as near-field connection or short-range connection). For this reason, this application proposes a communication method that can solve the problem of limited number of concurrent connections of devices.

[0104] In this communication method, when the current communication conditions of the first device (also referred to as the initiating device) (for example, the current number of connections of the device or the current role, etc.) do not meet the short-distance connection requirements, it can be interconnected with the second device (also referred to as the receiving device) by initiating a long-distance connection (also referred to as a far-field connection or a long-distance connection) to solve the problem of limited number of concurrent device connections caused by short-distance connections.

[0105] It should be noted that since long-distance connections are not limited by the current number of connections and current roles, when the first device is temporarily unable to use short-distance connections to interconnect external devices (for example, the second device), long-distance connections can be used to interconnect more external devices, thereby achieving true high-concurrency connections.

[0106] In some embodiments, the first device (or second device) may be a terminal device or a user equipment (UE).

[0107] The terminal device may be a mobile phone, smart screen, smart TV, tablet computer, wearable device, virtual reality (VR) device, augmented reality (AR) device, display, projector, car playback system, or other device with Wi-Fi and Bluetooth capabilities. The embodiments of the present application do not impose any restrictions on the specific type of the terminal device.

[0108] In order to better understand the embodiments of the present application, the structure of the terminal device of the embodiments of the present application is introduced below.

[0109] like Figure 2 , which shows a schematic diagram of the hardware structure of a terminal device 100. The terminal device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) connector 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, and a display screen 170.

[0110] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), a controller, a digital signal processor (DSP), a baseband processor, etc. The different processing units may be independent devices or integrated into one or more processors.

[0111] The processor 110 can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of instruction fetching and execution.

[0112] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 may be a cache memory. This memory can store instructions or data that have been used or are frequently used by processor 110. When processor 110 needs to use the instruction or data, it can directly access it from this memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0113] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface. The processor 110 may be connected to a wireless communication module, a display, or other modules through at least one of the above interfaces.

[0114] It is understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is merely an illustrative illustration and does not constitute a structural limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may also adopt a different interface connection method from the above embodiments, or a combination of multiple interface connection methods.

[0115] The USB connector 130 is an interface that complies with USB standard specifications and can be used to connect the terminal device 100 and peripheral devices. The charging management module 140 is used to receive charging input from the charger. The charger can be a wireless charger or a wired charger. The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the display screen 170 and the wireless communication module 160. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0116] The wireless communication function of the terminal device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0117] The mobile communication module 150 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for the terminal device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. In some embodiments, at least some functional modules of the mobile communication module 150 may be provided in the same device as at least some modules of the processor 110.

[0118] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio device (such as a speaker, etc.), or displays images, videos, contact lists, and Bluetooth operation interfaces through the display 170. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0119] The wireless communication module 160 can provide wireless communication solutions applied to the terminal device 100, including wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth (BT), near field communication technology (NFC), etc.

[0120] In some embodiments, antenna 1 of terminal device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that terminal device 100 can communicate with a network and other terminal devices via wireless communication technologies. The wireless communication technologies may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), etc.

[0121] The terminal device 100 can implement display functions through a GPU, a display screen 170 , and an application processor, etc. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0122] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, audio, video, and other files can be saved on the external memory card or transferred from the terminal device 100 to the external memory card.

[0123] The internal memory 121 can be used to store computer executable program code, which includes instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, at least one application required for a function (for example, screen projection function or picture sharing application), etc. The data storage area can store data created during the use of the terminal device 100 (for example, contact information, external device information to be connected, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional methods or data processing of the terminal device 100 by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor.

[0124] The terminal device 100 can display a list of available devices around (or nearby) found during the Bluetooth search process through the display screen 170.

[0125] The display screen 170 is used to display interface information such as Bluetooth search, contact list, and picture sharing. For example, the display screen 170 can be used to display pictures and other information. The display screen 170 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. In some embodiments, the terminal device 100 may include one or more display screens 190. In some embodiments, the display screen may be a foldable or scroll-shaped display screen.

[0126] It is understood that the structure shown in the embodiment of the present application does not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may also include Figure 2 More or fewer components, or combining some components, or splitting some components, or a different arrangement of components. Figure 2 The components in the present invention may be implemented in hardware, software, or a combination of software and hardware.

[0127] The software system of the terminal device 100 can adopt a layered architecture or a service architecture. In the embodiment of the present invention, the Android operating system with a layered architecture is used as an example to illustrate the software architecture of the terminal device 100. It should be understood that the solution provided in this application can also be applied to other types of operating systems such as the Harmony system, Apple operating system, and Windows operating system.

[0128] Figure 3 FIG. 1 shows a schematic diagram of the software architecture of the terminal device 100 provided in an embodiment of the present application. Figure 3 As shown, the layered architecture of the terminal device 100 divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the software architecture components, from top to bottom, are the application (APP) layer, the application framework (FW) layer, the Android runtime (ART) and native C / C++ libraries, the hardware abstraction layer (HAL), and the kernel layer.

[0129] The application layer, also known as the application layer, can include a series of application packages. For example, the application layer package can include a gallery application,

[0130] Screen projection application, video application and setting application, etc. When the above application packages are running, they can access the various service modules provided by the application framework layer through the application programming interface (API) and execute corresponding intelligent services.

[0131] The application framework layer (framework, FWK) provides application programming interface (application programming interface, API) and programming framework for the application layer. The application framework layer includes some predefined functions. Figure 3 As shown, the application framework layer may include a window manager, content provider, view system, resource manager, notification manager, activity manager, input manager, etc. Among them, the window manager is used to manage all windows in the system; the content provider is used to store and obtain data (such as videos, pictures, etc.) and make these data accessible to applications; the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The display interface can be composed of one or more views. For example, the display interface including the SMS notification icon may include a view for displaying text and a view for displaying pictures; the resource manager provides various resources for applications, such as pictures, video files, etc.; the notification manager is responsible for managing the prompt information in the status bar at the top of the phone.

[0132] The Android runtime consists of the core libraries and the Android runtime. The Android runtime is responsible for converting source code into machine code. It primarily utilizes ahead-of-time (AOT) and just-in-time (JIT) compilation technologies.

[0133] The core library is mainly used to provide basic Java class library functions, such as basic data structures, mathematics, IO, tools, databases, networks, etc. The core library provides an API for users to develop Android applications.

[0134] The native C / C++ library includes multiple functional modules, such as the surface manager and the media framework. The surface manager manages the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The media framework supports playback and recording of various common audio and video formats, as well as static image files.

[0135] The hardware abstraction layer runs in user space, encapsulates kernel layer drivers, and provides a calling interface to the upper layer; the hardware abstraction layer includes: display module, Bluetooth module, Wi-Fi module, etc.

[0136] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, Bluetooth driver, Wi-Fi driver, etc., to drive the display, Bluetooth and Wi-Fi.

[0137] The following takes the first device as an example Figure 2 and Figure 3 As an example, the terminal device with the structure shown in the figure is combined with Figure 4 The software architecture diagram of the first device shown is illustrative, illustrating the overall process of the first device executing the above-mentioned communication method.

[0138] The software architecture includes a fusion module (or a far-near fusion layer), a short-range communication module (or a near-field communication module), and a long-range communication module (or a far-field communication module). The fusion module can be located at the application layer or the framework layer. In actual applications, it can be designed according to the actual scenario, and this application does not limit it. Here, the communication method proposed in this application is illustrated by taking the fusion module at the application layer as an example. The fusion module is used to control the startup and switching of the short-range communication module and the long-range communication module. It should be noted that applications such as screen projection, picture sharing, and file sharing also run on the application layer.

[0139] The above-mentioned fusion module includes a fusion discovery module, an intelligent decision-making module and a fusion transmission module, wherein the fusion discovery module includes a near-field discovery module, which is generally used by the first device to discover other nearby receiving devices. For example, the near-field discovery module is used to start the short-range communication module to discover other nearby receiving devices (for example, the second device); for another example, the short-range communication module sends broadcast information to other nearby receiving devices through the broadcast discovery function, and receives response information (for example, the first response information) replied by other receiving devices; the short-range communication module can determine whether other devices (for example, the second device) support short-range connection and / or long-range connection through the response information; wherein, for a detailed introduction to short-range connection and long-range connection, please refer to the relevant introduction below, which will not be repeated here.

[0140] The above-mentioned intelligent decision-making module has functions such as near field assisting far field, far field assisting near field and link rating. The intelligent decision-making module is used to control the activation of functions such as near field assisting far field, far field assisting near field and link rating and the switching between modules; among them, near field assisting far field can also be understood as short-distance connection assisting long-distance connection. When the bandwidth of the long-distance connection is insufficient, the intelligent decision-making module can activate the near-field assisting far field function, so that the connection status of the first device and the nearby device (for example, the second device) is switched back from long-distance connection to short-distance connection.

[0141] Far field assisting near field can also be understood as long-distance connection assisting short-distance connection. For example, when the current communication conditions of the short-distance connection (such as the number of connections, current role, etc.) do not meet the requirements, the intelligent decision-making module can activate the far-field assisted near-field function, so that the first device and the nearby device (such as the second device) establish interconnection through a long-distance connection; or, when the transmission resources of the short-distance connection do not meet the transmission requirements, the intelligent decision-making module can also activate the far-field assisted near-field function, so that the connection status of the first device and other nearby receiving devices (such as the second device) is switched back from short-distance connection to long-distance connection.

[0142] The link rating function is mainly used to evaluate the transmission resources of the current connection link (for example, signal quality, time-frequency domain resources, load, etc.). For example, the intelligent decision-making module can activate the link rating function to evaluate the signal quality or load of the current short-distance connection, and determine the preferred connection method suitable for the current communication needs based on the evaluation results, and feed back the preferred connection method to the intelligent decision-making module; the intelligent decision-making module can activate the corresponding near-field assisted far-field function or far-field assisted near-field function according to the preferred connection method, so as to facilitate the first device to establish interconnection with other nearby receiving devices through a better connection method, thereby providing users with high-quality communication.

[0143] The above-mentioned integrated transmission module has functions such as multi-channel parallel and switching, among which the switching function is used to control the switching of the short-distance communication module and the long-distance communication module; in some scenarios, the first device initially establishes a long-distance connection with the nearby device, but after a period of time, it is detected that the far-field data transmission volume is large and the bandwidth is insufficient. At this time, the first device can also start the multi-channel parallel function to establish a near-field connection. For example, the first device and the second device have established both a long-distance connection and a short-distance connection, thereby realizing multi-channel parallel (also called dual-channel parallel).

[0144] In some embodiments, for example, the intelligent decision-making module determines to start the far-field assisting near-field function. At this time, the intelligent decision-making module sends an indication message X1 to the fusion transmission module to instruct the fusion transmission module to switch the connection mode; at this time, the fusion transmission module controls the long-distance communication module to start, so that the connection state of the first device switches from a short-distance connection to a long-distance connection.

[0145] For another example, the intelligent decision-making module determines to start the near-field assist far-field function. At this time, the intelligent decision-making module sends an indication message X2 to the fusion transmission module to instruct the fusion transmission module to switch the connection mode; at this time, the fusion transmission module controls the short-distance communication module to start, so that the connection status of the first device is switched from a long-distance connection to a short-distance connection.

[0146] In other embodiments, after the first device turns on the Bluetooth and Wi-Fi functions, the fusion discovery module will start the short-range communication module; the short-range communication module sends broadcast information through the broadcast discovery function to discover other nearby receiving devices; after discovering the nearby receiving device, the signaling interaction and data transmission resource negotiation between the first device and the nearby device (for example, the second device) are performed through the constrained application protocol (COAP) or the bluetooth low energy (BLE) signaling function; the first device establishes a secure connection with the nearby device (for example, the second device) through the connection & authentication module; after the first device establishes a secure connection with the nearby receiving device (for example, the second device), the data transmission module is started to send and receive data.

[0147] In some scenarios, when the first device starts the long-distance communication module, the long-distance communication module can control the first device to establish a long-distance connection with the second device; wherein, the long-distance communication module includes a remote procedure call (RPC) service and a long-distance P2P module (also known as a far-field P2P module), and the RPC service is used to realize the interaction and communication between the fusion module and the long-distance communication module; the long-distance P2P module includes a signaling channel, a P2P connection intelligent decision-making function and a P2P data transmission function, wherein the signaling channel is used for signaling interaction between the first device and the external device; the P2P connection intelligent decision-making function is used to determine the connection method required for the first device to establish a connection with a nearby receiving device (for example, the second device).

[0148] For example, the connection methods include P2P crossing method and P2P relay method. Among them, the P2P crossing method, also known as the P2P hole punching method, means that when the first device and the second device establish a long-distance connection, an intermediate server is required as a guide to achieve the connection between the first device and the second device (that is, to achieve a long-distance connection between the first device and the second device). For details, please refer to the relevant description of the embodiments below; the P2P relay method, also known as the P2P transit method, means that when the first device and the second device establish a long-distance connection, an intermediate server is required as a transit server to forward the data of the first device to the second device through the intermediate server. Accordingly, the second device receives the data sent by the first device through the intermediate server. For details, please refer to the relevant description of the embodiments below.

[0149] It should be noted that the intermediate server is a general server used to establish a long-distance connection between the first device and the second device; in addition, the intermediate server can be provided by a third-party manufacturer, by the manufacturer of the first device, or by the manufacturer of the second device, and this application does not limit this.

[0150] After the first device and the second device are connected through the intermediate server (ie, after the first device and the second device establish a long-distance connection), the first device can start security authentication, authorization and P2P data transmission functions and start transmitting data to the second device.

[0151] It should be noted that the long-distance communication module and the short-distance communication module can be in the framework layer or in the application layer. This application does not limit this. Here, taking the long-distance communication module and the short-distance communication module in the framework layer as an example, the process of the first device executing the above-mentioned communication method is introduced.

[0152] The software architecture diagram also includes short-range services (or near-field services), radio interface layer (RIL), Wifi / Bluetooth module, modem 0, modem 1, Wifi and Bluetooth. Among them, the short-range service combines with the RPC service to control the operation of modem 0, modem 1, Wifi and Bluetooth. The RIL is used to provide communication interfaces for the long-range communication module and the short-range communication module, and the Wifi / Bluetooth module is used to provide communication interfaces for Wifi / Bluetooth.

[0153] It should be noted that the software architecture of the first device is not limited to Figures 2 to 4 The hardware and software system structure shown in the figure can be adjusted according to the specific application scenario in actual application. Figures 2 to 4 The software and hardware system structures shown in the figure may be modified, and this application does not limit this.

[0154] The communication method provided in the embodiments of the present application is described below with reference to the accompanying drawings.

[0155] like Figure 5 As shown, it is a flow chart of a communication method 500 provided in an embodiment of the present application. Before introducing the communication method provided in the present application, a brief description of the execution subject involved in the embodiment of the present application is first given. In the present application, the first device and the second device can be terminal devices; the above-mentioned communication method can be executed by the terminal device, or by a module (such as a processor, chip, or chip system, etc.) applied to the terminal device, or by a logic module or software that can realize all or part of the functions of the terminal device.

[0156] The present embodiment of the present application uses the first device (or second device) as an example terminal device to illustrate the method 500 provided in the present application, but the present application does not limit the execution subject. It should be noted that the first device and the second device both support Bluetooth, Wi-Fi, and cellular communications; before the first device and the second device of the present application execute the communication method, Bluetooth, Wi-Fi, and / or mobile data traffic are enabled.

[0157] The above method 500 includes steps 501 to 504, which are described in detail below.

[0158] Step 501: A first device receives a first operation, where the first operation is used to start a distributed service.

[0159] Among them, the first device usually refers to an initiating device, a main device or a shared device. The first device usually needs to share (or share or send) its own resources (such as video resources, file resources, picture resources, etc.) to other nearby receiving devices (such as the second device).

[0160] The above-mentioned first operation may refer to an operation performed by the user on the display interface of the first device. The first operation may be a gesture operation, a mouse click operation, or a remote control command operation, etc. This application does not limit this. The gesture operation may be a finger single-click operation or a double-click operation, or a floating gesture operation, etc. It should be noted that the floating gesture operation may refer to a gesture operation performed when the user's gesture is in a floating state, such as a floating swipe operation, a floating slow swipe operation, etc.

[0161] The above-mentioned distributed services usually run on the application layer and / or framework layer of the first device, including but not limited to screen projection service, picture sharing service, file sharing service and keyboard and mouse crossing service.

[0162] In some embodiments, if a user wants to use a distributed service, he needs to start the distributed service through a first operation on the first device. For example, if the user wants to start the screen projection service, the user needs to find the icon of the screen projection service on the setting interface of the first device and click on the icon to start the screen projection service.

[0163] Step 502: In response to the first operation, the first device displays an icon of the second device, where the second device is a device that supports distributed services, short-range connections, and long-range connections and is discovered based on a short-range communication method.

[0164] Among them, the second device usually refers to a receiving device or a slave device or a device to be shared. The second device may refer to a device that needs to establish a connection and share resources after being discovered based on a short-range communication method; the second device is usually near the first device, and can establish a short-range connection with the first device through Bluetooth, Wi-Fi direct connection, etc., or establish a long-range connection with the first device through a far-field P2P method (or a long-range P2P method).

[0165] Among them, short-distance connection may refer to a method in which the first device establishes a connection with the second device through a short-distance (or short-distance or near-field) wireless connection method, and long-distance connection may refer to a method in which the first device establishes a connection with the second device through a far-field P2P method; among them, the short-distance wireless connection method includes but is not limited to the Wifi direct connection method and the Bluetooth method, and the far-field P2P method includes but is not limited to the far-field P2P hole punching method and the far-field P2P transit (or relay) method. For the far-field P2P hole punching method and the far-field P2P transit method, please refer to the relevant description of the embodiments below, which will not be repeated here.

[0166] In some embodiments, after receiving the first operation, the first device responds to the first operation by discovering multiple nearby devices through short-range communication (for example, Bluetooth broadcasting or receiving heartbeat packets, etc.), and receives response information from multiple devices. For example, among the multiple devices discovered, some devices support distributed services, some devices do not support distributed services, some devices support short-range connections or long-range connections, and some devices support both short-range and long-range connections.

[0167] For example, in some examples, multiple devices discovered first can reply with response information to the first device, and use the response information to feedback to the first device whether they support distributed services, as well as the status of short-distance connection and / or long-distance connection. The first device can display devices that meet the requirements as needed. For example, the first device only displays devices that support distributed services, short-distance connection and long-distance connection.

[0168] In some other examples, it is specified that among the multiple discovered devices, devices that support distributed services, short-distance connections, and long-distance connections reply with response information. For example, if the second device supports both distributed services and short-distance connections and long-distance connections, the second device can reply to the first device with a response information; after receiving the response information, the first device displays the second device on the display screen (or display interface).

[0169] Step 503: The first device determines the current communication condition in response to a second operation, where the second operation includes an operation on an icon of the second device, and the second operation instructs the first device to share data with the second device.

[0170] The second operation may also refer to an operation performed by the user on the display interface of the first device. Similar to the first operation, the second operation may also be a gesture operation or a mouse click, or a remote control command operation, etc. This application does not limit this. For example, the second operation may be a gesture operation, and the user selects the icon of the second device through the gesture operation to trigger the first device to establish an interconnection with the second device.

[0171] The current communication conditions include, but are not limited to, the number of equivalent connections of the first device and the current role. The user selects, through a second operation, a second device with which the first device needs to share data (or shared resources); for example, the first device supports two connection modes with external devices, one short-distance connection mode and the other long-distance connection mode. When responding to the second operation, the first device needs to determine the current communication conditions to further determine which connection mode to use to establish a connection with the second device.

[0172] It should be noted that the current number of connections is the number of short-range connections that the first device has established, and the number threshold is the maximum number of short-range connections supported by the first device. For example, if the short-range connection is a Bluetooth connection, the maximum number of external devices that the first device can connect to via Bluetooth is 7 (i.e., the number threshold is 7); if the first device has established connections with 5 external Bluetooth devices via Bluetooth, the current number of connections is 5, and the number of remaining available connections is 2; in theory, the first device can establish a connection with the second device either through Bluetooth or through a long-distance connection; under normal circumstances, the first device can first establish a connection with the second device via Bluetooth, and when the Bluetooth link signal is poor or the near-field load is too high, the long-distance connection can be selected; of course, it is also possible to first establish a connection with the second device via a long-distance connection, and then use Bluetooth to establish a connection when the bandwidth used for the long-distance connection is insufficient.

[0173] The above-mentioned shared data (or mutually sent data) includes but is not limited to picture data, file data, video data, audio data and control data.

[0174] Step 504: When the current communication condition does not meet the short-distance connection requirement, establish a first long-distance connection with the second device.

[0175] The above-mentioned short-distance connection requirements include but are not limited to the requirements for the current number of connections and the requirements for the current role, wherein the requirements for the current number of connections may refer to the requirement that the current number of connections is not greater than the number threshold; the requirements for the current role may refer to the requirement that the current role is allowed to connect to the outside.

[0176] When the first device determines that the current communication conditions do not meet the short-range connection requirements, it indicates that the first device is temporarily unable to establish a connection with the second device via a short-range connection. In this case, the first device can establish a first long-range connection with the second device via a long-range connection. The first long-range connection refers to the process of establishing a connection between the first device and the second device via a far-field P2P connection. Once the long-range connection is established, the first and second devices can proceed with subsequent service discovery, security authentication, and data transmission.

[0177] To summarize, in method 500, the first device responds to the second operation to determine whether the current communication conditions meet the short-distance connection requirements. When the current communication conditions do not meet the short-distance connection requirements, it indicates that the first device is temporarily unable to establish interconnection with the second device through a short-distance connection. In order for the first device to be able to connect to more external devices (for example, the second device) concurrently, the first device can use a long-distance connection to establish a first long-distance connection with the second device, thereby avoiding the problem of limited number of concurrent device connections due to the current communication conditions not meeting the short-distance connection requirements.

[0178] In method 500, the short-range communication mode may include but is not limited to a short-range wireless communication mode and a mode of sending a heartbeat packet; wherein the short-range wireless communication mode includes but is not limited to a Bluetooth broadcast mode and a local area network mode.

[0179] For example, in some embodiments, Figure 6A As shown, the first device can discover a nearby receiving device (for example, a second device) through short-range wireless communication; for example, in the case where the first device and the second device are connected to the same router (that is, the first device and the second device are in the same local area network), the first device can use the local area network method to send broadcast information to nearby terminal devices in the same network segment to request to establish interconnection with the discovered terminal device (for example, the second device); for another example, the first device can also send broadcast information to nearby terminal devices through Bluetooth broadcasting to request to establish interconnection with the discovered terminal device (for example, the second device).

[0180] In other embodiments, when the first device needs to establish a distributed service with a nearby device with the same account, the first device may determine a method for establishing a connection with the device by receiving a heartbeat packet sent by the nearby device with the same account.

[0181] It should be noted that the device with the same account may refer to a device whose account information (eg, account name, account password, etc.) is consistent with the account information of the first device.

[0182] For example, the second device is one of the devices with the same account near the first device. The second device can notify the first device of its current status information (such as online status, capability information, etc.) by broadcasting a heartbeat packet via Bluetooth (or sending a heartbeat packet via Bluetooth). The heartbeat packet includes the capability information of the second device, wherein the capability information includes but is not limited to whether it supports distributed services, short-distance connections, and long-distance connections. For example, the second device broadcasts a heartbeat packet via Bluetooth, the first device receives the heartbeat packet, and parses the heartbeat packet to obtain capability information; when the capability information indicates that the second device supports distributed services, short-distance connections, and long-distance connections, it means that the first device can determine that the second device supports both short-distance connections and long-distance connections; at this time, the first device can determine the method of establishing a connection with the second device based on whether the current communication conditions meet the short-distance connection requirements.

[0183] For example, when the current communication conditions meet the short-range connection requirements, the first device can establish a short-range connection (e.g., a first short-range connection) with the second device; when the current communication conditions do not meet the short-range connection requirements or the transmission resources of the short-range connection (e.g., the first short-range connection) do not meet the transmission requirements, the first device can establish a long-range connection with the second device. Of course, the first device and the second device can also have both short-range and long-range connections and transmit data in a dual-path parallel manner.

[0184] It should be noted that because the first device and the second device belong to the same account, the first device has the third identifier of the second device. For example, the first device locally stores the third identifier of the second device. When the first device needs to establish a long-distance connection with the second device, it can directly establish the long-distance connection with the second device based on the third identifier. The method for establishing short-distance and long-distance connections between the first device and the second device can be referred to in the following embodiments and will not be described in detail here.

[0185] In some embodiments, as Figure 6B As shown, after the first device discovers multiple nearby receiving devices through short-distance communication, on the one hand, it can establish interconnection with the receiving devices through short-distance connection, and on the other hand, it can establish interconnection with the receiving devices through long-distance connection. For example, the first device establishes interconnection with receiving device 1 (or receiving device 2, etc.) through short-distance connection, and the first device establishes interconnection with receiving device n-1 (or receiving device n, etc.) through long-distance connection, where n is a positive integer greater than 1.

[0186] In other embodiments, Figure 7A As shown, after the first device discovers two receiving devices (i.e., the second device and the third device), it can establish interconnection with the second device and the third device respectively through short-distance connection; it should be noted that the first device, the second device and the third device are in the same local area network (or the same router), and the first device to the third device communicate with the server in the cloud service cluster through the router; for example, in actual applications, the first device (or the second device or the third device) is added to the home local area network through the wired or wireless resources of the home router, and the router then connects the home local area network to the external Internet through the community broadband access, thereby realizing daily Internet access needs.

[0187] For example, Figure 7BAs shown in the figure, taking the first device in the home LAN as an example, the process of the first device accessing the external network (for example, the metropolitan area network) is briefly introduced; the first device accesses the broadband remote access server (BRAS) in the service control layer through the passive optical network (PON) system in the access aggregation layer; the BRAS authenticates the first device, establishes a session, and manages and charges the user's Internet access; among them, the access aggregation layer includes the PON system and the switch (SW) for managing user access; the service control layer includes the BRAS and the service router (SR) for processing service distribution and calling, etc.; the core layer includes the core router (CR); the metropolitan area network and the backbone network constitute the backbone of the entire transmission network, which is responsible for connecting home users, government and enterprise users and data centers in various places.

[0188] It should also be noted that the first device and the nearby receiving device (eg, the second device) may be located in different networks; for example, Figure 8A As shown, the first device is accessed through base station 1 and connected to the core network and backbone network respectively through the bearer network; the second device is accessed through base station 2 and connected to the core network and backbone network respectively through the bearer network. In other words, the first device and the second device can use mobile data traffic to access the Internet; when the first device and the second device need to establish a long-distance connection, they can use mobile data traffic to communicate with each other.

[0189] For example, Figure 8B As shown, the first device is connected to server 1 in the cloud service cluster through a base station router; the second device is accessed through the base station and connected to server 2 in the cloud service cluster via the core network; server 1 and server 2 can communicate with each other; in other words, the first device can access the Internet through Wi-Fi, and the second device can access the Internet using mobile data traffic; when the first device and the second device need to establish a long-distance connection, the first device can negotiate with server 2 through server 1 to establish a long-distance connection with the second device; for example, user 1's tablet uses Wi-Fi to log in to APP1, and user 1's mobile phone uses mobile data traffic to log in to APP2. Although the tablet and the mobile phone use different communication networks, the tablet and the mobile phone can still establish a connection through a far-field P2P method to enable communication between APP1 and APP2.

[0190] like Figure 9 As shown, in some embodiments, the communication method 500 further includes: step 505 and step 506, which are specifically as follows:

[0191] It should be noted that step 505 and step 506 are performed before the first device displays the icon of the second device.

[0192] Step 505: The first device sends a broadcast message, and accordingly, the second device receives the broadcast message, wherein the second device is a device near the first device; the broadcast message includes a first identifier, a first request message, and a second request message, the first identifier is the identifier of the first device, the first request message is used to inquire whether distributed services are supported, and the second request message is used to inquire whether short-distance connections and / or long-distance connections are supported.

[0193] The broadcast information may be Bluetooth broadcast information, or Wifi UDP broadcast information, or of course, broadcast information of other short-distance connection methods, which is not limited in this application.

[0194] The above-mentioned first identifier, also known as the first device identifier, is used to uniquely identify the first device. It can be a string of characters, such as a numeric string, an alphabetic string, or a mixed string (including numbers, letters, and special characters); for example, the first identifier is 0001041005 or 5157RQ0194.

[0195] The first request information (or the second request information) may be carried by fields in the broadcast information. For example, certain fields in the broadcast information may be used to carry the first request information.

[0196] It should be noted that short-distance connection can also be described as near-field connection or short-distance connection; long-distance connection can also be described as far-field connection or long-distance connection or far-field P2P connection; of course, short-distance connection and long-distance connection can also have other descriptions with similar essential meanings, and this application does not limit this.

[0197] In some embodiments, a first device may send a broadcast message to surrounding (or nearby) devices via broadcasting. After receiving the broadcast message, the nearby devices may parse the broadcast message. For example, a second device is a device near the first device. After receiving the broadcast message, the second device may determine whether it supports distributed services based on the first request message, and whether it supports short-range and / or long-range connections based on the second request message. If the second device supports distributed services, short-range connections, and long-range connections at the same time, the second device may inform the first device of the service capabilities it supports by replying a response message (e.g., a first response message) to the first device.

[0198] Step 506: The first device receives the first response information, and accordingly, the second device sends the first response information, which includes a second identifier, first indication information and second indication information, the first indication information indicates that the second device supports distributed services, the second indication information indicates that the second device supports short-distance connection and / or long-distance connection, and the second identifier is the identifier of the second device.

[0199] Among them, the information structure of the first response information can use the data structure form of Table 1. For example, the second identifier in the first response information can be carried through the device identifier (DeviceId) field, the first indication information can be carried through the first indication field, and the second indication information can be carried through the second indication field; of course, when the first response information uses the data structure of Table 1 to reply to the response information, in addition to some required fields, it can also carry other fields (for example, account identification fields, etc.), and this application does not limit this.

[0200] It should be noted that the function and composition of the second identifier are similar to those of the first identifier. Please refer to the relevant description of the first identifier and will not be repeated here.

[0201] Table 1

[0202]

[0203]

[0204] In some embodiments, when the second device sends a first response message to the first device, it can reply according to the content indicated by the broadcast information; for example, the first response message may include a second identifier, first indication information and second indication information to reply to the first device that it supports distributed services, supports short-distance connections and / or long-distance connections.

[0205] It should be noted that the first indication information and the second indication information can be carried in different fields or in the same field, and this application does not limit this. Similarly, the first request information and the second request information can also be carried in different fields or in the same field, and this application does not limit this.

[0206] In other embodiments, the first device may further include a third identifier when replying to the first response information, wherein the third identifier may refer to a token value assigned by the second device on the business cloud (or on a remote cloud server); the third identifier is used to establish a first long-distance connection between the first device and the second device; although the broadcast information sent by the first device does not explicitly instruct the second device to send the third identifier, the method of carrying the third identifier when replying by the second device is advantageous: when the first device needs to establish a long connection with the second device, it can retrieve the locally saved third identifier without having to obtain the third identifier through a new message or control signaling, thereby reducing resource consumption.

[0207] It should be noted that when the broadcast information does not include contact information, the receiving device (for example, the second device) that receives the broadcast information can send a first response message to the first device if it determines that it supports distributed services and supports short-distance connections and long-distance connections; in other words, the receiving device (for example, the second device) that replies to the response information (for example, the first response information) to the first device may be a friend device (or contact device) of the first device, or it may not be a friend device of the first device; wherein, the friend device (or contact device) may refer to the device corresponding to the contact of the first device; the contact information includes at least one contact information, and the contact information is used to determine whether the nearby receiving device (for example, the second device) is the device corresponding to the contact; the contact information can be a hash value of the contact identifier, or it can be information in other data forms, and this application does not limit this.

[0208] It should be noted that in some cases, users may want to share data (such as files, videos, etc.) with their friend devices. At this time, the first device can carry contact information when broadcasting information, so that nearby devices (such as the second device) can determine whether they are friend devices of the first device (that is, the device corresponding to the contact of the first device) based on the contact information in the broadcast information.

[0209] For example, in step 505, when the broadcast information includes contact information, the second device determines based on the contact information that if it is the device corresponding to the contact of the first device, it sends a first response message to the first device; if not, the second device may not send the first response message to the first device, or may indicate that it is not a friend device of the first device when replying to the first response message, so that when the first device displays the second device, it can determine a suitable display area for the second device according to whether the second device is a friend device (for example, if the second device is a friend device, the second device will be displayed in the friend device area; if the second device is not a friend device, the second device will be displayed in the other device area; please refer to the interface embodiment below).

[0210] In some other embodiments, in order for the first device to quickly establish a long-distance connection with the second device when necessary to ensure the quality of communication, the first device will carry a third indication message when sending a broadcast message to indicate that the second device can carry its corresponding third identifier when replying to the first response message; accordingly, when the second device receives the broadcast message, it will carry the third identifier in the first response message according to the third indication message; in this way, the first device can store the third identifier carried in the first response message locally for easy use when establishing a long-distance connection.

[0211] In some embodiments, after the first device receives the first response information, step 502 may further be performed through step 507:

[0212] Step 507: The first device displays the icon of the second device according to the first response information.

[0213] Among them, the icon of the second device is used to start the connection between the first device and the second device to achieve the purpose of resource sharing of distributed services; the icon of the second device can be started by a user gesture operation or by clicking a mouse.

[0214] In some embodiments, when the broadcast information does not include contact information, after receiving the first response information, the first device directly displays the icon of the second device in the "available devices" area.

[0215] In other embodiments, when the broadcast information does not include contact information, the second device may carry a hash value of its own account name when replying to the first response information; when the first device receives the first response information, it determines whether the second device is a friend device based on the second identifier and the hash value of the account name. If so, the icon of the second device is displayed in the "Friend Device" area; if not, the icon of the second device is displayed in the "Other Devices" area.

[0216] Optionally, in some embodiments, the first device may further determine whether the second device is a device with the same account as the first device based on the hash value of the second identifier and the account name. If so, the first device may display the icon of the second device in the "My Devices" area. For example, the first device may compare the account name of the second device with its own account name. If the two names are the same, the first device indicates that the second device is a device with the same account as the first device.

[0217] In other embodiments, the first device can establish a connection (e.g., a short-distance connection or a long-distance connection, etc.) with a nearby device with the same account (e.g., a second device). For details, please refer to the relevant description above and will not be repeated here; the first device can display the icon of the second device with the same account in the "My Device" area; in some cases, when the user selects the icon of the second device in the "My Device" area, the first device can obtain a third identifier locally and establish a long-distance connection with the second device through the third identifier; in other cases (e.g., when the current communication conditions meet the short-distance connection requirements), when the user selects the icon of the second device in the "My Device" area, the first device can establish a short-distance connection with the second device.

[0218] In some other embodiments, when the broadcast information includes contact information, when the second device receives the broadcast information, it determines whether it is a friend device of the first device based on the contact information; when the second device is a friend device of the first device, the second device replies to the first response information, and the first response information may include the account name of the second device; after the first device receives the first response information, it can determine whether the second device is its own (i.e., corresponding to the first device) friend device or its own device with the same account based on the account name of the second device. If it is a device with the same account as the first device, the icon of the second device will be displayed in the "My Device" area; if it is a friend device of the first device, the icon of the second device will be displayed in the "Friend Device (or Contact Device)" area; if it is neither, the icon of the second device will be displayed in the "Other Devices" area.

[0219] It should be noted that, regarding the manner in which the first device displays the icon of the second device, reference may be made to the interface embodiments below, which will not be elaborated here.

[0220] In some embodiments, the broadcast information in the above step 506 further includes first channel information, wherein the first channel information is information about a short-range connection channel currently used by the first device.

[0221] In some embodiments, the first channel information may refer to Bluetooth broadcast channel information, and of course may also refer to other short-range communication channel information, which is not limited in this application.

[0222] In some cases, when sending broadcast information, the first device may carry the first channel information in the broadcast information so that other nearby devices (eg, the second device) can determine whether a short-range connection can be established with the first device through channel multiplexing.

[0223] Accordingly, after receiving the broadcast information including the first channel information, the second device first determines whether the channel of the short-distance connection currently being used by itself (i.e., the channel of the short-distance connection indicated by the second channel information) is the same as the channel of the short-distance connection indicated by the first channel information; if they are the same, it means that the first device and the second device can establish a short-distance connection through channel multiplexing without establishing a long-distance connection; at this time, the second device determines not to obtain the third identifier first, and does not need to carry the third identifier when replying to the first response information; since the second device does not need to obtain the third identifier from the remote server first, some network resources can be saved for other business data transmission; if they are not the same, it means that the first device and the second device cannot establish a short-distance connection through channel multiplexing, and may need to establish a long-distance connection; however, it should be noted that the first device and the second device can also establish a short-distance connection through other channels, and this application does not limit this;

[0224] For example, the first device establishes an interconnection with the second device through a long-distance connection. At this time, the second device needs to obtain a third identifier from the remote server and carry the third identifier when replying to the first response information.

[0225] When the first device receives response information (e.g., first response information) from other nearby receiving devices (e.g., second device), it needs to judge the current communication conditions and, based on the specific circumstances of the current communication conditions, determine which connection method to use to establish interconnection with each receiving device.

[0226] In step 503, the first device determines the current communication condition, including: determining the current number of connections, wherein the current number of connections is the number of short-range connections established by the first device, and the number threshold is the maximum number of short-range connections supported by the first device.

[0227] In some cases, after the current number of connections of the first device reaches the number threshold, it can no longer establish a connection with other nearby devices through a short-distance connection; at this time, after receiving the second operation, the first device will determine the current number of connections; when the current number of connections has reached the number threshold (that is, the current number of connections is equal to the number threshold), it means that the previous communication conditions of the first device do not meet the short-distance connection requirements, and the short-distance connection cannot be used to establish a connection with the second device; when the current number of connections is less than the number threshold, it means that the previous communication conditions of the first device meet the short-distance connection requirements, and the short-distance connection can be used to establish a connection with the second device; it can be seen that the first device can determine the available connection method for the second device by judging the current number of connections, thereby avoiding the situation where the connection cannot be established.

[0228] For example, the first device can establish connections with up to 7 external Bluetooth devices via Bluetooth. If the current number of connections has reached 7, the current communication conditions of the first device no longer meet the requirements for establishing a Bluetooth connection with the second device. At this time, it is necessary to establish interconnection with the second device through a long-distance connection.

[0229] In some embodiments, even if the current number of connections does not reach the threshold, the first device may be temporarily unable to establish a connection with other nearby devices due to restrictions on the first device's current role. In this case, the first device will first determine the first device's current role before determining the current number of connections. The current number of connections will be determined only when the current role allows the first device to connect to the second device. Alternatively, the current number of connections will not be determined when the current role does not allow the first device to connect to the second device, thereby avoiding the situation where a connection cannot be established due to role restrictions. For example, in a Wi-Fi Direct scenario, if the first device's role is GC, the first device is not allowed to connect to the second device.

[0230] In some other embodiments, the first device may first determine whether the current role of the first device allows it to connect to an external device; for example, when the first device determines that its current role does not allow the first device to connect to the second device, it is determined that the current communication conditions do not meet the short-distance connection requirements. If the first device establishes an interconnection with the second device, a long-distance connection is required; for another example, when the first device determines that its current role allows the first device to connect to the second device, it is determined that the current communication conditions meet the short-distance connection requirements.

[0231] For example, the current role of the first device is GC, and the role of the second device is also GC. At this time, the current role of the first device does not allow it to establish interconnection with the second device through a short-distance connection (for example, Bluetooth or Wi-Fi direct connection). At this time, the first device can establish interconnection with the second device through a long-distance connection (for example, far-field P2P).

[0232] In some cases, even if the current role of the first device allows the first device to establish a connection with other nearby devices (for example, the second device), due to the limitation on the current number of connections, the first device is temporarily unable to establish a connection with other nearby devices; therefore, before determining the current role of the first device, the first device will first determine the current number of connections; when the current number of connections is less than the number threshold, it means that the current communication conditions meet the short-distance connection requirements, and then determine whether the current role allows connection to the second device, thereby avoiding the situation where the connection cannot be established due to the limitation on the current number of connections.

[0233] For example, the current role of the first device is GO, and the role of the second device is GC. The current role of the first device allows interconnection with the second device via Wi-Fi Direct; however, the number of devices that the first device can connect to via Wi-Fi Direct has reached the upper limit.

[0234] If the number of connections currently made by the first device using Wi-Fi Direct does not reach the threshold, it indicates that the current communication conditions meet the short-range connection requirements, and the first device can then establish a connection with the second device via Wi-Fi Direct.

[0235] It should be noted that in some scenarios, when the current communication conditions meet the short-range connection requirements, the first device can prioritize establishing a first short-range connection with the second device through a short-range connection to reduce the resource cost of data sharing. The first short-range connection can be a Bluetooth connection, a Wi-Fi direct connection, or other short-range connection methods, which are not limited in this application.

[0236] In other scenarios, although the first device and the second device have established a first short-distance connection (for example, a Bluetooth connection), when the transmission resources of the first short-distance connection do not meet the transmission requirements, the first device can quickly switch from the short-distance connection to the long-distance connection and establish a second long-distance connection with the second device, thereby ensuring the communication quality between the first device and the second device.

[0237] The transmission resources include but are not limited to signal strength, payload, data size (eg, video file size, image size, etc.), transmission rate, transmission time, and channel quality. The second long-distance connection may refer to a far-field P2P connection.

[0238] For example, when the transmission rate of the first short-distance connection is less than the rate threshold (for example, 100Kb / s), the first device can switch from the short-distance connection to the long-distance connection, and establish a second long-distance connection with the second device through a third identifier to ensure the communication quality between the first device and the second device.

[0239] For example, when a first device transmits high-definition video data to a second device through a first short-distance connection, since the high-definition video data file is too large, if a short-distance connection is used, not only will the transmission time be long, but it may also be interrupted. At this time, the first device can establish a long-distance connection with the second device based on the third identifier. In this way, the first device can not only transmit high-definition video data to the second device through the first short-distance connection, but also transmit high-definition video data to the second device through the long-distance connection. This dual-path parallel data transmission method not only has high transmission efficiency, but also high reliability.

[0240] Of course, when the amount of data transmitted from the first device to the second device is large, the first device may also switch from the short-distance connection to the long-distance connection to transmit a larger amount of data through the communication link of the long-distance connection.

[0241] In some embodiments, the first device and the second device have established a short-distance communication link (for example, a Bluetooth communication link, a Wi-Fi direct communication link), but when the short-distance connection is suddenly interrupted (for example, while the first device is transmitting data to the second device, the first device is taken away by the user, and the short-distance connection between the first device and the second device may be interrupted) or the transmission resources of the short-distance connection do not meet the transmission requirements (for example, the file shared by the first device to the second device is too large and the transmission time is too long), the first device can establish an interconnection with the second device through a long-distance connection.

[0242] In some cases, the first device does not receive the third identifier from the second device (that is, the second device does not send the third identifier to the first device). At this time, the first device can obtain the third identifier of the second device through the communication link of the first short-distance connection, so that when the short-distance connection is suddenly interrupted or the transmission resources of the short-distance connection do not meet the transmission requirements, the first device can quickly establish a long-distance connection with the second device to ensure normal data transmission.

[0243] For example, Figure 10 As shown, the first device obtains the third identifier through the communication link of the first short-distance connection, and establishes a second long-distance connection with the second device according to the third identifier when the short-distance connection is suddenly interrupted or the transmission resources of the short-distance connection do not meet the transmission requirements or two-way parallel data transmission is required:

[0244] Step 1001: The first device sends control information to the second device through the communication link of the first short-distance connection, wherein the control information includes a first identifier and instruction information, the instruction information is used to instruct the second device to send a third identifier, and the third identifier is also used to establish a second long-distance connection with the second device.

[0245] Among them, the communication link of the first short-range connection can be a Bluetooth control link (or Bluetooth data channel) established between the first device and the second device through a Bluetooth connection, or it can be a Wifi control link (or Wifi data channel) established between the first device and the second device through a Wifi direct connection.

[0246] The above control information can be some short-range communication signaling such as Bluetooth or Wi-Fi, or some protocol layer request information. In actual applications, it can also be some other messages or information forms, which is not limited in this application.

[0247] The first device sends control information to the second device through an established short-distance communication link. The control information carries instruction information, which is used to instruct the second device to send a third identifier to the first device. The third identifier can be replied in the form of a response message or sent through signaling. This application does not limit this.

[0248] Step 1002: The first device receives second response information from the second device, where the second response information includes a second identifier and a third identifier, where the second identifier is the identifier of the second device.

[0249] After the first device sends the control information to the second device, the second device obtains the third identifier from the local device or the server side according to the instruction information, and sends the third identifier to the first device through the second response information.

[0250] Step 1003: The first device establishes a second long distance connection with the second device according to the third identifier.

[0251] It should be noted that after the first device obtains the third identifier, it can immediately establish a second long-distance connection with the second device, or it can establish the second long-distance connection after the first short-distance connection is interrupted. This application does not limit this.

[0252] In actual applications, switching rules can be set in advance. For example, when the short-distance connection is interrupted, the first device can use the third identifier to establish a long-distance connection with the second device; or when the transmission resources of the short-distance connection do not meet the transmission requirements or two-way parallel data transmission is required, the first device can establish a long-distance connection with the second device to assist the short-distance connection to complete the data transmission through the long-distance connection; in other words, no matter which of the following scenarios is true: the short-distance connection is suddenly interrupted, the transmission resources of the short-distance connection do not meet the transmission requirements or two-way parallel data transmission is required, the first device establishes a second long-distance connection with the second device through the third identifier, which can be used as a separate transmission method to complete the data transmission between the first device and the second device, or it can assist the short-distance connection (that is, the short-distance connection can be continuous) to complete the data transmission between the first device and the second device in a two-way parallel manner.

[0253] As an example, the first device receives and parses the second response information, and stores the third identifier in the second response information locally; when it is necessary to establish a second long-distance connection with the second device, the long-distance connection with the second device can be quickly established through the third identifier; wherein, the long-distance connection can be a far-field P2P hole-punching connection method (i.e., a far-field P2P hole-punching method) or a far-field P2P transit connection method (i.e., a far-field P2P transit method).

[0254] For example, Figure 10As shown, the first device and the second device can establish a second long-distance connection through a far-field P2P relay, specifically including (the prerequisite is that the first device and the second device can communicate with the relay server respectively):

[0255] Step 1004: The first device sends a request message X1 to the relay server. The request message X1 includes a first identifier and a second identifier. The request message X1 is used to request the relay server to forward the shared data from the first device to the second device.

[0256] It should be noted that, since the first device and the second device have established a short-distance connection, the first device has the identifier of the second device (ie, the second identifier).

[0257] Step 1005: The relay server receives the request message X1 and sends an indication message R1 to the second device. The indication message R1 includes a first identifier and is used to notify the second device that it is ready to receive data sent by the first device via the relay server. After receiving the indication message R1, the second device can allocate storage resources, time-frequency domain resources, and other resources for receiving the data sent by the first device via the relay server.

[0258] It can be seen that when the transmission resources of the first short-distance connection do not meet the transmission requirements, the first device can send control information to the second device through the communication link of the first short-distance connection to obtain the third identifier of the second device; since the third identifier is obtained by the first device through the established communication link of the first short-distance connection, there is no need to obtain the third identifier through Bluetooth broadcasting, the interaction method is simple and resource consumption is small.

[0259] Due to the existence of some middleware on the current Internet (such as network address translation plug-ins and firewalls), the first device and the second device cannot communicate directly; if the first device and the second device need to establish a long-distance connection, they need to use a server to punch a hole or transit to achieve the interconnection between the first device and the second device.

[0260] The following combination Figure 11A and Figure 11B Two long-distance connection methods are introduced, one of which is the far-field P2P hole punching method (or far-field P2P traversal method), and the other is the far-field P2P transit method (or far-field P2P relay method). It should be noted that the far-field P2P hole punching method is not limited to Figure 11A The way shown, Figure 11AOnly the far-field P2P hole punching method for two devices in different network address translation (NAT) is given. The far-field P2P hole punching method for two devices in the same NAT or in multi-level NAT can also realize mutual communication between the first device and the second device, and this application does not limit this.

[0261] like Figure 11A , which shows a schematic diagram of the architecture of a far-field P2P hole punching method; Figure 11A In the example, the first device and the second device both have intranet addresses and are located on different routers (i.e., different NATs). The first device is located on router 1, and the second device is located on router 2. The first device (or the second device) can communicate with the server (i.e., an example of an intermediate server). The distributed service (or shared application or P2P application) and the server running on the first and second devices both use X port 0001 (e.g., UDP port 0001). The first device and the second device each initiate X communication with the server. The address mapping is as follows: Figure 11A As shown; for example, a first device establishes a communication connection (eg, a communication session) with a second device.

[0262] When the first device sends information S1 to the public network address 2 of the second device, a relay request R1 is sent to the public network address 3 of the server; the relay request R1 includes a second identifier, and the server can locate the second device according to the second identifier; the relay request R1 is used to request the second device to send information S2 to the public network address 1 of the first device. The information S2 sent by the second device to the first device will cause the router 1 to open a new communication session (for example, a new UDP communication session) between the intranet address of the first device and the public network address 2 of the second device, so that the first device can send the information S1 to the second device through the new communication session; similarly, when the second device sends information S3 to the public network address 1 of the first device, a relay request R2 is sent to the public network address 3 of the server; the relay request R2 includes a first identifier, and the server can locate the first device according to the first identifier; the relay request R2 is used to request the first device to send information S4 to the public network address 2 of the second device; the information S4 sent by the first device to the second device will cause the router 2 to open a new communication session (for example, a new UDP communication session) between the intranet address of the second device and the public network address 1 of the first device, so that the second device can send the information S3 to the second device through the new communication session. After the new communication session is opened in both directions, the first device and the second device can communicate directly, that is, the first device and the second device achieve traversal (or the first device and the second device successfully punch a hole), successfully establishing a long-distance connection. Subsequent data transmission between devices no longer needs to be transferred through the server, and data transmission delay is small and efficiency is high.

[0263] like Figure 11BAs shown, a schematic diagram of the architecture of a far-field P2P relay method is shown; wherein the far-field P2P relay method refers to forwarding (or relaying) data of the first device and the second device through a server S with a public Internet Protocol (IP) address as a relay server (i.e., an example of an intermediate server), wherein the server S is a server in the cloud service cluster. Since the first device and the second device do not communicate directly, the first device and the second device need to establish connections with the server S respectively first. For example, the first device is connected to the server S through the router 1 to form a communication link 1; the first device sends a forwarding request R2 to the server S through the communication link 1; the forwarding request R2 includes a third identifier and request information 1, wherein the request information 1 is used to instruct the server S to forward the data from the second device through the communication link 1; the second device is connected to the server S through the router 2 to form a communication link 2; the server S receives the forwarding request R3 sent by the server S through the communication link 2, the forwarding request R3 includes a first identifier and request information 2, and the request information 2 is used to instruct the second device to receive the data of the first device forwarded by the server S through the communication link 2; since the server S establishes communication links 1 and communication links 2 with the first device and the second device respectively, the second device can receive the data of the distributed service forwarded by the first device through the server S through the communication link 2. Accordingly, the first device can also receive the data sent by the second device through the server S through the communication link 1. At this point, the first device and the second device have established a long-distance connection through the server S. This first device establishes a long-distance connection (for example, a first long-distance connection) with the second device through server relay, which not only enables fast and secure data transmission, but also improves the stability of the network connection.

[0264] The communication method 500 is introduced in detail above. Now, in combination with the interface embodiment, taking the first device as mobile phone 1 and the second device as mobile phone 2 as an example, the application of method 500 in screen projection scenarios and picture sharing scenarios is introduced.

[0265] like Figure 12A As shown, user A can turn on Wifi, Bluetooth and mobile data traffic in the status control bar 1201 of mobile phone 1 (i.e., an example of the first device); after turning on Wifi, Bluetooth and mobile data traffic, as shown in FIG. Figure 12B As shown, user A can click the "Settings" icon 1202 on the main interface of mobile phone 1, and then mobile phone 1 enters the settings interface 1203, as shown in FIG. Figure 12C When the user clicks on the screen projection option 1204 on the setting interface 1203, the mobile phone 1 receives the click operation from the setting interface 1203 and enters the screen projection interface 1205 in response to the click operation, as shown; Figure 12DAs shown; User A can set permissions on the screen projection interface 1205. For example, in the far-field connection mode option, the traffic mode used by the mobile phone 1 when establishing a long-distance connection can be set: one is to use cellular or Wi-Fi; the other is to use both cellular and Wi-Fi (i.e., cellular & Wi-Fi); wherein cellular can be understood as the mobile phone 1 using mobile data traffic to establish a long-distance connection with other nearby devices (e.g., the second device), and Wi-Fi can be understood as the mobile phone 1 using Wi-Fi to establish a long-distance connection with other nearby devices (e.g., the second device); for another example, in the search permission option, only contacts or everyone can be set. When user A sets it to "only contacts", when the mobile phone 1 sends a broadcast message to the nearby devices, the contact information can be carried. For details, please refer to the relevant description of the broadcast message carrying contacts in the introduction of step 506 above; accordingly, when the mobile phone 1 receives a response message from the nearby receiving device (e.g., the second device), the friend device can be displayed in the "friend device" area, and the non-friend device can be displayed in the "other devices" area. For details, please refer to the relevant description of the first device displaying the second device in the introduction of step 506 above.

[0266] For example, Figure 12D As shown, user A sets the "Cellular & Wifi" option 1206 in the far-field connection mode option of the projection interface 1205, and sets the "Contacts Only" option 1207 in the search permission option, and then clicks the "Start Search" button. At this time, mobile phone 1 starts to execute the step of sending broadcast information in the above method 500; because the user selected the "Contacts Only" option, mobile phone 1 can carry contact information when sending broadcast information; during the search process, the projection interface 1205 can display information such as the "Searching" time (for example, 12 seconds); when mobile phone 1 searches for a device that meets the requirements (that is, a device that supports distributed services, short-distance connections and long-distance connections), that is, mobile phone 1 receives a response message (for example, a first response message) sent by a nearby receiving device (for example, a second device), at this time, mobile phone 1 can establish an interconnection with the device that meets the requirements and display the device that meets the requirements on the screen. Figure 13A On the "device display interface 1301" shown, as shown Figure 13A It should be noted that when mobile phone 1 establishes a long-distance connection with a device that meets the requirements, since the user has selected the "Cellular & Wifi" option, mobile phone 1 can establish a long-distance connection with the device that meets the requirements via cellular mode or via Wifi mode. Mobile phone 1 can use the appropriate traffic mode to establish a long-distance connection with the device that meets the requirements based on the current network environment.

[0267] It should also be noted that, when it is limited that only friend devices that meet the requirements can reply to the response information, the mobile phone 1 can display the devices that meet the requirements separately from the friend devices that meet the requirements, for example, Figure 13A As shown, the icon of my device is displayed in the "My Device" area of ​​the device display interface 1301, and the icon of the friend device is displayed in the "Friend Device" area, where "My Device" is a device with the same account near the mobile phone 1; when it is not limited to only the friend devices that meet the requirements to reply to the response information, the mobile phone 1 can display my device, friend devices and non-friend devices separately when displaying the devices that meet the requirements, for example, Figure 13B As shown, in addition to displaying the icon of "My Device" and the icon of "Friend's Device" on the device display interface 1301, icons of other devices are also displayed in the "Other Devices" area, where the "Other Devices" area displays icons of devices other than friend's devices and my device. For details, please refer to the relevant description of the first device displaying the second device part in steps 506 and 507 above.

[0268] In some other embodiments, Figure 13C As shown, user A selects the "Everyone" option 1302 in the permission setting option of the screen projection interface 1205, and then clicks the "Start Search" button to search; when mobile phone 1 searches for multiple receiving devices that meet the requirements, regardless of whether these receiving devices are friend devices, mobile phone 1 will display the icons of these devices in the "Available Devices" area, as shown in the figure. Figure 13D As shown, please refer to the relevant description of the first device displaying the second device part in step 507 above for details.

[0269] For example, Figure 13D As shown, user A selects device 002 (such as Figure 13D ), and click the "Request Screen Cast 1304" button to connect the screen; at this time, the mobile phone 1 executes steps 503 and 504 in the above method 500; at the same time, the device display interface 1301 displays a status message 1401 of "Connecting...", as shown in FIG. Figure 14A When the device display interface 1301 shows the "connected" status information 1402, it means that the mobile phone 1 and the 002 device have established a connection, such as Figure 14BAs shown; however, with this display method, the user only knows that mobile phone 1 and device 002 have established an interconnection, but cannot know the connection method currently being used by mobile phone 1 and device 002; therefore, in an optional implementation method, after mobile phone 1 establishes an interconnection with device 002, the currently used connection method can be displayed in real time on the device display interface 1301, for example, short-distance connection or long-distance connection or dual-path parallel, so that the user can know the connection method currently being used by mobile phone 1 and device 002 in a timely manner.

[0270] For example, user A selects mobile phone 1 to establish interconnection with device 002. Figure 14C As shown, after mobile phone 1 establishes a connection with device 002, a message 1403 of "short distance connection..." can be dynamically displayed on the device display interface 1301 to inform the user that mobile phone 1 and device 002 are currently using a short distance connection for data transmission; for another example, taking user A selecting mobile phone 1 to establish interconnection with multiple devices (e.g., device 001, device 002, device 101, etc.), as shown in FIG. Figure 14D As shown, after mobile phone 1 establishes connections with multiple devices, the connection mode currently being used by mobile phone 1 and different devices can be dynamically displayed on the device display interface 1301. For example, the message 1404 "Long distance connection..." is dynamically displayed on the device display interface 1301, which can tell user A that mobile phone 1 and device 001 are currently using a short distance connection for data transmission; for another example, the message 1405 "Dual connection..." is dynamically displayed on the device display interface 1301, which can tell user A that mobile phone 1 and device 102 are currently using a short distance connection and a long distance connection at the same time to transmit data in a dual-path parallel manner.

[0271] It should be noted that the interconnection between mobile phone 1 and at least one device (for example, device 002) may be established through a short-distance connection, or through a long-distance connection, or it may be that during the screen projection process, the short-distance connection and the long-distance connection assist each other in establishing the interconnection in a dual-path parallel manner; the specific method used to establish the interconnection between mobile phone 1 and device 002 needs to be determined based on the current communication conditions or transmission resources, etc. For details, please refer to the relevant descriptions in steps 503 and 1003 above, which will not be repeated here.

[0272] For another example, still taking the example of establishing a connection between mobile phone 1 and device 002, Figure 14E As shown, when the device display interface 1301 displays the status message 1406 of "Connection Failed", it means that the mobile phone 1 has failed to establish a connection with the 002 device. At this time, the device display interface 1301 may also display a "Message Notification" dialog box 1407, and the user A may select "Re-request" or "Stop Request". Figure 14EIf user A selects "re-request", at this time, the mobile phone 1 executes steps 504 and 504 in method 500; at the same time, the device display interface 1301 reappears Figure 14A If user A selects "Stop Request", the device display interface 1301 returns to Figure 13D In the interface shown, user A can reselect the device to be projected (for example, device 102) on the device display interface 1301.

[0273] For example, Figure 14F As shown, mobile phone 1 has successfully established a connection with device 002. On the video interface 1408, the area of ​​"Currently connected device" will display the icon of device 002. If user A wants to disconnect the screen projection with device 002, he can long press the "icon of device 002" in the area of ​​"Currently connected device" to open the status switch bar 1409, and select the "Disconnect" option on the status switch bar 1409 to disconnect mobile phone 1 from device 002. If you want to reconnect after disconnection, you can Figure 13D Select the "Request Screen Casting 1304" button on the device display interface 1301 shown to reconnect (i.e., mobile phone 1 re-executes steps 503 and 504 to determine the connection method with device 002).

[0274] Accordingly, if Figure 15A As shown, when mobile phone 1 sends a screen casting connection to device 002 (i.e., an example of the second device), a message reminder 1502 of "Mobile phone 1 requests screen casting?" will be displayed on the display interface 1501 of device 002; if user B of device 002 accepts the screen casting request, mobile phone 1 and device 002 will establish a screen casting connection; the video content played on mobile phone 1 will be synchronously displayed on the display interface 1501 of device 002, as shown in FIG. Figure 15B As shown; if user B of device 002 does not accept the screen projection request, the screen projection connection between mobile phone 1 and device 002 fails.

[0275] For example, Figure 16A As shown, user A clicks on the picture sharing option 1601 on the setting interface 1203 of mobile phone 1. At this time, mobile phone 1 receives the click operation from the setting interface 1203 and enters the picture sharing interface 1602 in response to the click operation. Figure 16BAs shown; User A can set permissions on the picture sharing interface 1602, for example, set the far-field connection mode to cellular, set the search permission to contacts only, and then click the "Start Search" button. At this time, when mobile phone 1 sends broadcast information to nearby devices, it can carry contact information. For details, please refer to the relevant description of the part about carrying contacts in the broadcast information in the introduction of step 506 above; during the search process, the "Searching" time and other information will be displayed on the picture sharing interface 1602; when mobile phone 1 searches for a device that meets the requirements (that is, a device that supports distributed services, short-distance connections and long-distance connections), that is, mobile phone 1 receives a response message (for example, a first response message) sent by a nearby receiving device (for example, a second device), at this time, mobile phone 1 can establish an interconnection with the device that meets the requirements and display the device that meets the requirements on the Figure 16C As shown in the "Device Display Interface 1603", since the user has selected the "Cellular" option, the mobile phone 1 can establish a long-distance connection with the device that meets the requirements via the cellular mode.

[0276] For example, Figure 16C As shown, in addition to displaying the icons of "My Devices" and "Friends' Devices" on the device display interface 1603, mobile phone 1 also displays icons of other devices in the "Other Devices" area. For details, please refer to the relevant description of the first device displaying the second device in steps 506 and 507 above. For example, user A selects device 101 and device 102 on the device display interface 1603 to establish interconnection for picture sharing; at this time, mobile phone 1 executes steps 503 and 504 in the above method 500; at the same time, the icons of device 101 and device 102 after selection turn gray and are selected, as shown in FIG. Figure 16C The user can click the "enter picture selection" button 1604, at this time, the phone 1 jumps from the device display interface 1603 to the picture selection interface 1606, as shown in FIG. Figure 16D As shown; User A selects the picture to be shared on the picture selection interface 1606. After selecting the picture, you can click the "Start Sharing" button 1607 to share the picture. The "+" in the "Friends Device" area can add the device to be shared, such as Figure 16D shown.

[0277] Accordingly, if Figure 17A As shown, taking the case where device 101 receives a picture sharing request sent by mobile phone 1 as an example, first, user C can turn on Wifi, Bluetooth and mobile data traffic in the status control bar 1701 of device 101 (i.e., another example of the second device); after turning on Wifi, Bluetooth and mobile data traffic, as shown in FIG. Figure 17BAs shown, the main interface 1702 of the 101 device displays the received picture sharing message reminder 1703; if user C chooses "Accept", the mobile phone 1 and the 101 device are successfully connected (for example, a short-distance connection or a long-distance connection, etc.); at this time, the mobile phone 1 can share pictures with the 101 device; if user C chooses "Reject", the picture sharing between the mobile phone 1 and the 101 device fails; for example, when user C chooses "Accept", the picture information 1704 shared by the mobile phone 1 appears on the main interface 1702, as shown in FIG. Figure 17C As shown, user C can view or save the received picture; in some cases, for example, if the network signal is not good, the 101 device may fail to receive the picture; Figure 17D As shown, the 101 device will display the failed picture information in the form of a message reminder 1705 on the main interface 1702, and user C can choose to "receive" or "give up"; if user C chooses "receive", the 101 device will continue to receive the pictures shared by mobile phone 1; if user C chooses "give up", the 101 device will interrupt the connection with mobile phone 1, and the picture sharing will fail or end.

[0278] It should be noted that the communication method proposed in this application is not limited to scenarios such as screen projection and picture sharing, but is applicable to scenarios such as keyboard and mouse crossing, file sharing, and multi-screen collaboration. This application does not limit the application scenarios where the above communication method is applicable.

[0279] The above details examples of the communication methods provided by this application. It is understood that, to implement the aforementioned functions, the terminal device includes hardware structures and / or software modules corresponding to each function. Those skilled in the art should readily appreciate that, in conjunction with the units and algorithmic steps of the various examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application. This application may divide the communication method into functional units based on the aforementioned method examples. For example, each function may be divided into separate functional units, or two or more functions may be integrated into a single unit. These integrated units may be implemented in either hardware or software functional units. It should be noted that the division of units in this application is illustrative and represents only one logical functional division; actual implementation may employ different division methods.

[0280] Figure 18 The present application provides a schematic structural diagram of a terminal device. Figure 18The dashed line indicates that the unit or module is optional. The terminal device 1800 can be used to implement the method described in the above method embodiment. The terminal device 1800 can be a server or a chip (system).

[0281] The terminal device 1800 includes one or more processors 1801, which can support the terminal device 1800 to implement Figure 5 The method in the corresponding method embodiment. Processor 1801 can be a general-purpose processor or a dedicated processor. For example, processor 1801 can be a central processing unit (CPU). The CPU can be used to control terminal device 1800, execute software programs, and process data of software programs. Terminal device 1800 can also include a communication unit 1805 to implement signal input (reception) and output (transmission).

[0282] The terminal device 1800 may be a chip (system) including a memory and a processor, wherein the processor is configured to execute a computer program stored in the memory to implement the methods shown in the above embodiments.

[0283] The communication unit 1805 may be an input and / or output circuit of the chip (system), or the communication unit 1805 may be a communication interface of the chip (system), and the chip (system) may serve as a component of the terminal device 1800 .

[0284] For another example, the communication unit 1805 may be a transceiver of the terminal device 1800, or the communication unit 1805 may be a transceiver circuit of the terminal device 1800. The terminal device 1800 may include one or more memories 1802, on which a program 1804 is stored. The program 1804 can be executed by the processor 1801 to generate instructions 1803, so that the processor 1801 performs the method described in the above method embodiment according to the instructions 1803. Optionally, data may also be stored in the memory 1802. Optionally, the processor 1801 may also read data stored in the memory 1802. The data may be stored at the same storage address as the program 1804, or the data may be stored at a different storage address than the program 1804.

[0285] The processor 1801 and the memory 1802 may be provided separately or integrated together, for example, integrated on a system-on-chip (SOC) of a terminal device. The specific manner in which the processor 1801 executes the communication method may refer to the relevant description in the method embodiment.

[0286] It should be understood that each step of the above method embodiment can be completed by hardware logic circuits or software instructions in the processor 1801. The processor 1801 can be a CPU, a digital signal processor (DSP), a field programmable gate array (FPGA), or other programmable logic devices, such as discrete gates, transistor logic devices, or discrete hardware components.

[0287] The present application also provides a computer program product that, when executed by a processor 1801, implements any method embodiment of the present application. The computer program product may be stored in a memory 1802, for example, a program 1804. The program 1804 undergoes preprocessing, compilation, assembly, and linking to be converted into an executable object file that can be executed by the processor 1801.

[0288] The present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer, implements any method embodiment of the present application. The computer program may be a high-level language program or an executable target program.

[0289] The computer-readable storage medium is, for example, memory 1802. Memory 1802 may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SynchLinkDRAM, SLDRAM), and direct RAM bus random access memory (DRRAM).

[0290] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and equipment and the technical effects produced can refer to the corresponding processes and technical effects in the aforementioned method embodiments, and will not be repeated here.

[0291] In several embodiments provided in this application, the disclosed systems, devices, and methods can be implemented in other ways. For example, some features of the method embodiments described above can be ignored or not executed. The device embodiments described above are merely schematic, and the splitting of units is only a logical function splitting. There may be other splitting methods in actual implementation, and multiple units or components may be combined or integrated into another system. In addition, the coupling between the units or the coupling between the components may be direct coupling or indirect coupling, and the above coupling includes electrical, mechanical or other forms of connection.

[0292] The above embodiments are intended only to illustrate the technical solutions of the present application and are not intended to limit the same. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the above embodiments or replace some of the technical features therein with equivalents, and that such modifications or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application and are therefore intended to be included within the scope of protection of the present application.

[0293] Finally, the above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application shall be covered by the scope of protection of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection of the claims.

Claims

1. A communication method, characterized in that: Applied to a first device, the method includes: receiving a first operation, where the first operation is used to start a distributed service; In response to the first operation, displaying an icon of a second device, where the second device is a device that supports distributed services, short-range connections, and long-range connections and is discovered based on a short-range communication method; determining a current communication condition in response to a second operation, the second operation comprising an operation acting on an icon of the second device, the second operation instructing the first device to share data with the second device; When the current communication condition does not meet the short-distance connection requirement, a first long-distance connection is established with the second device.

2. The method according to claim 1, characterized in that The method further comprises: Before displaying the icon of the second device: Sending broadcast information, where the broadcast information includes a first identifier, first request information, and second request information, where the first identifier is an identifier of the first device, the first request information is used to inquire whether distributed services are supported, and the second request information is used to inquire whether the short-distance connection and / or the long-distance connection is supported; receiving first response information, where the first response information includes a second identifier, first indication information, and second indication information, where the second identifier is an identifier of the second device, the first indication information indicates that the second device supports the distributed service, and the second indication information indicates that the second device supports the short-distance connection and / or the long-distance connection; The displaying the icon of the second device includes: An icon of the second device is displayed according to the first response information.

3. The method according to claim 2, characterized in that The first response information further includes a third identifier, and the third identifier is used to establish the first long-distance connection with the second device.

4. The method according to claim 3, characterized in that The broadcast information further includes third indication information, where the third indication information instructs the second device to send the third identifier.

5. The method according to any one of claims 2 to 4, characterized in that The broadcast information further includes first channel information, where the first channel information is information about a short-range connection channel currently used by the first device.

6. The method according to any one of claims 1 to 5, characterized in that The determining of the current communication condition includes: Determine a current number of connections, where the current number of connections is the number of short-distance connections established by the first device; The current communication condition does not meet the short-distance connection requirement, including that the current number of connections is equal to a number threshold.

7. The method according to claim 6, characterized in that The method of determining the current number of connections further includes: Before determining the current number of connections, determining a current role of the first device; Determining the current number of connections includes: When the current role allows the first device to connect to the second device, the current connection quantity is determined.

8. The method according to any one of claims 1 to 5, characterized in that The determining of the current communication condition includes: determining a current role of the first device; The current communication condition does not meet the short-distance connection requirement, including: the current role does not allow the first device to connect to the second device.

9. The method according to claim 8, characterized in that Before determining the current role of the first device, the method further includes: Determine a current number of connections, where the current number of connections is the number of short-distance connections established by the first device; The determining the current role of the first device includes: When the current number of connections is less than a number threshold, it is determined that the current communication condition meets the short-distance connection requirement.

10. The method according to any one of claims 1 to 9, characterized in that The method further comprises: When the current communication condition meets the short-distance connection requirement, a first short-distance connection is established with the second device.

11. The method according to claim 10, characterized in that The method further comprises: When the transmission resources of the first short-distance connection do not meet the transmission requirements, a second long-distance connection is established with the second device.

12. The method according to claim 10, characterized in that The establishing a second long distance connection with the second device includes: In a case where the third identifier is not received from the second device, control information is sent to the second device through the first short-range connection, where the control information includes the first identifier and instruction information, where the instruction information is used to instruct the second device to send the third identifier, where the third identifier is used to establish the second long-range connection with the second device; receiving second response information from the second device, where the second response information includes a second identifier and the third identifier, and the second identifier is an identifier of the second device; The second long-distance connection is established with the second device according to the third identifier.

13. The method according to any one of claims 1 to 12, characterized in that The second device is a device corresponding to the contact of the first device.

14. A communication method, characterized in that: Applied to the second device, the method includes: receiving broadcast information from a first device, where the broadcast information includes a first identifier, first request information, and second request information, where the first identifier is an identifier of the first device, the first request information is used to inquire whether a distributed service is supported, and the second request information is used to inquire whether a short-distance connection and / or a long-distance connection is supported, where the distributed service is a service initiated by the first device in response to a first operation; In the case where the broadcast information does not include contact information, a first response message is sent to the first device, the first response message including a second identifier, first indication information, second indication information and a third identifier, the second identifier being an identifier of the second device, the first indication information indicating that the second device supports the distributed service, the second indication information indicating that the second device supports the short-distance connection and / or the long-distance connection, the third identifier being used to establish a first long-distance connection with the first device, and the contact information being used to determine whether the second device is the device corresponding to the contact.

15. The method according to claim 14, characterized in that The broadcast information further includes first channel information, where the first channel information is information about a short-range connection channel currently used by the first device; Before sending the first response information to the first device, the method further includes: When the second channel information is inconsistent with the first channel information, the third identifier is acquired, where the second channel information is information about a short-distance connection channel currently used by the second device.

16. The method according to claim 14, characterized in that The broadcast information further includes third indication information, where the third indication information instructs the second device to send a third identifier, and the first response information further includes the third identifier.

17. The method according to any one of claims 14 to 16, characterized in that The method further comprises: In the case where the broadcast information includes the contact information, when the second device is the device corresponding to the contact information, the first response information is sent to the first device; or, when the second device is not the device corresponding to the contact information, it is determined not to send the first response information to the first device.

18. The method according to claim 15, characterized in that The method further comprises: When the second channel information is consistent with the first channel information, determining not to acquire the third identifier; A first short-range connection is established with the first device.

19. The method according to claim 18, characterized in that The method further comprises: When the transmission resources of the first short-distance connection do not meet the transmission requirements, a second long-distance connection is established with the first device.

20. The method according to claim 19, characterized in that The establishing a second long distance connection with the second device includes: receiving, in a case where the third identifier is not received from the second device, control information from the first device through the first short-range connection, the control information including the first identifier and instruction information, the instruction information being used to instruct the second device to send the third identifier, the third identifier being used to establish the second long-range connection with the first device; Sending second response information to the first device, where the second response information includes the second identifier and the third identifier; The second long-distance connection is established with the first device through the third identifier.

21. A terminal device, characterized in that: The terminal device includes a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the terminal device executes the method described in any one of claims 1 to 13, or the terminal device executes the method described in any one of claims 14 to 20.

22. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, enables the processor to execute the method according to any one of claims 1 to 13, or enables the processor to execute the method according to any one of claims 14 to 20.

23. A chip system, characterized in that: The chip system includes a memory and a processor, and the processor is configured to execute a computer program stored in the memory to implement the method as claimed in any one of claims 1 to 13, or to implement the method as claimed in any one of claims 14 to 20.