Communication method, terminal device, and computer-readable storage medium

By detecting the current communication conditions, if the short-distance connection requirements are not met, the first device and the second device establish a long-distance connection, which solves the problem of limited number of concurrent connections between the initiating device and multiple receiving devices and achieves more efficient data transmission.

WO2025195177A1PCT designated stage Publication Date: 2025-09-25HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/080762
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-03-22
Filing Date
2025-03-05
Publication Date
2025-09-25

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, it cannot meet the connection needs of multiple devices.

Method used

By detecting the current communication conditions, if the short-distance connection requirements are not met, the first device establishes a long-distance connection with the second device to solve the problem of limited number of concurrent connections.

Benefits of technology

When short-distance connection resources are insufficient, the number of concurrent device connections can be increased through long-distance connections, avoiding the situation where connection cannot be made due to resource limitations, and ensuring the efficiency and reliability of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025080762_25092025_PF_FP_ABST
    Figure CN2025080762_25092025_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of terminals. Provided are a communication method, a terminal device and a computer-readable storage medium. The method is applied to a first device, and comprises: receiving a first operation, wherein the first operation is used for enabling a distributed service; in response to the first operation, displaying an icon of a second device, wherein the second device is a device which supports the distributed service, a short-distance connection and a long-distance connection and is discovered on the basis of a short-distance communication mode; in response to a second operation, determining the current communication condition, wherein the second operation comprises an operation acting to select the icon of the second device, and the second operation indicates that the first device shares data with the second device; and when the current communication condition does not meet a short-distance connection requirement, establishing a first long-distance connection with the second device. The method can solve the problem of the number of concurrent connections of devices being limited.
Need to check novelty before this filing date? Find Prior Art

Description

Communication method, terminal device, and computer-readable storage medium

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on March 22, 2024, with application number 202410340157.2 and application name “Communication Method, Terminal Device and Computer-readable Storage Medium”, the entire contents of which are incorporated by reference into this application. Technical Field

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

[0003] 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[0037] 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).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[0059] 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

[0060] Figures 1A and 1B are schematic diagrams of application scenarios provided by embodiments of the present application;

[0061] FIG2 is a schematic diagram of the hardware structure of a terminal device 100 provided in an embodiment of the present application;

[0062] FIG3 is a schematic diagram of a software architecture of a terminal device 100 provided in an embodiment of the present application;

[0063] FIG4 is a schematic diagram of the software architecture of the first device provided in an embodiment of the present application;

[0064] FIG5 is a flow chart of a communication method 500 provided in an embodiment of the present application;

[0065] FIG6A is a schematic diagram of a first device discovering a receiving device according to an embodiment of the present application;

[0066] FIG6B is a schematic diagram of another method in which a first device discovers a receiving device according to an embodiment of the present application;

[0067] FIG7A is a schematic diagram of a network connection of a first device provided in an embodiment of the present application;

[0068] FIG7B is a schematic diagram of a process of a first device accessing an external network according to an embodiment of the present application;

[0069] FIG8A is a schematic diagram of a network in which a first device and a second device are located, provided in an embodiment of the present application;

[0070] FIG8B is a schematic diagram of a network in which a first device and a second device are located, provided in another embodiment of the present application;

[0071] FIG9 is a flow chart of another communication method 500 provided in an embodiment of the present application;

[0072] FIG10 is a schematic diagram of establishing a second long distance connection between a first device and a second device according to an embodiment of the present application;

[0073] FIG11A is a schematic diagram of the architecture of a far-field P2P hole punching method provided in an embodiment of the present application;

[0074] FIG11B is a schematic diagram of the architecture of a far-field P2P relay method provided in an embodiment of the present application;

[0075] Figures 12A to 12D are schematic diagrams of a screen projection scenario provided by an embodiment of the present application;

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

[0077] 14A to 14F are schematic diagrams of another screen projection scenario provided by an embodiment of the present application;

[0078] 15A and 15B are schematic diagrams of another screen projection scenario provided in an embodiment of the present application;

[0079] 16A to 16D are schematic diagrams of a picture sharing scenario provided by an embodiment of the present application;

[0080] 17A to 17D are schematic diagrams of another picture sharing scenario provided by an embodiment of the present application;

[0081] FIG18 is a schematic structural diagram of a terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

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

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

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

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

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

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

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

[0090] 3. P2P client

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

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

[0093] 4. Wireless Access Point AP

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

[0095] 5. Site STA

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

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

[0098] DHCP, also known as Dynamic Host Configuration Protocol, is a network protocol used in Internet Protocol (IP) networks. It is located in 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.

[0099] 7. Address Resolution Protocol (ARP)

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

[0101] The following introduces two practical application scenarios with reference to FIG1A and FIG1B , thereby introducing the technical problems to be solved by this application.

[0102] In one scenario, Wi-Fi Direct technology, also known as near-field Wi-Fi P2P technology, allows devices to connect without going through an AP. It should be noted that in a P2P group, devices typically have two roles: gateway (GO) and gateway (GC). A GO device has AP-like functionality, while a GC device connects to the GO. Devices that support Wi-Fi Direct are generally referred to as either GOs or GCs. A GO can be simply understood as a master device, while a GC is a slave device. As shown in FIG1A , in a P2P group, terminal devices 1 to 7 all support the Wi-Fi Direct function, wherein terminal device 1 plays the GO role and supports a maximum of 4 concurrent connections, i.e., terminal device 1 can simultaneously connect to up to 4 GC devices, for example, terminal device 1 can establish connections with terminal devices 2 to 5 respectively; however, terminal device 1 and terminal device 6 can no longer establish a connection (see 101 shown in FIG1A ); the 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 role restrictions, 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 102 shown in FIG1A ).

[0103] In another scenario, according to the Bluetooth technology regulations, when each 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, as shown in Figure 1B, 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 to 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 103 shown in Figure 1B). 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 a slave role (i.e., a slave Bluetooth device) cannot establish a connection with other slave Bluetooth devices, unless the Bluetooth device playing a slave role switches to a Bluetooth device playing a master role (i.e., called a master Bluetooth device), then it can establish a connection with other slave Bluetooth devices. For example, slave Bluetooth device 4 cannot directly establish a connection with slave Bluetooth device 9 (see 104 shown in Figure 1B).

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

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

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

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

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

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

[0110] FIG2 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.

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

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

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

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

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

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

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

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

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

[0120] 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 (NFC), etc.

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

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

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

[0124] 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, a screen projection function or an image sharing application), etc. The data storage area can store data created during the use of the terminal device 100 (for example, contact information, information of external devices to be connected, 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.

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

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

[0127] It is understood that the structure illustrated in the embodiments 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 include more or fewer components than those in FIG. 2 , or may combine or separate certain components, or may have different component arrangements. The components in FIG. 2 may be implemented in hardware, software, or a combination of software and hardware.

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

[0129] Figure 3 shows a schematic diagram of the software architecture of the terminal device 100 provided in an embodiment of the present application. As shown in Figure 3, 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 are, from top to bottom, the application (APP) layer, the application framework (FW) layer, the Android runtime (ART) and native C / C++ library, the hardware abstraction layer (HAL) and the kernel layer (kernel).

[0130] The application layer, also known as the application layer, can include a series of application packages. For example, an application layer package may include a gallery app, a screen projection app, a video app, and a settings app. When these 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 (FWK) provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions. As shown in Figure 3, the application framework layer can 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 retrieve data (such as videos, images, etc.) and make this data accessible to applications; the view system includes visual controls, such as controls for displaying text and controls for displaying images. The display interface can be composed of one or more views. For example, the display interface of a text message notification icon can include views for displaying text and views for displaying images; the resource manager provides various resources to applications, such as images and video files; and 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 of a terminal device having the structure shown in Figures 2 and 3, combined with the software architecture diagram of the first device shown in Figure 4, to illustrate the overall process of the first device executing the above 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 a short-distance connection to a 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 layer interface (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 the software and hardware system structures shown in Figures 2 to 4. In actual applications, the software and hardware system structures shown in Figures 2 to 4 can be modified according to specific application scenarios, 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] As shown in Figure 5, a flow chart of a communication method 500 provided in an embodiment of the present application is provided. 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, as shown in FIG6A , the first device can discover a nearby receiving device (e.g., the 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 (i.e., the first device and the second device are in the same local area network), the first device can use the local area network to send broadcast information to nearby terminal devices in the same network segment to request to establish interconnection with the discovered terminal device (e.g., the second device); for another example, the first device can also send broadcast information to nearby terminal devices through Bluetooth broadcast to request to establish interconnection with the discovered terminal device (e.g., 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 shown in FIG6B , 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 a short-distance connection, and on the other hand, it can establish interconnection with the receiving devices through a long-distance connection. For example, the first device establishes interconnection with receiving device 1 (or receiving device 2, etc.) through a short-distance connection, and the first device establishes interconnection with receiving device n-1 (or receiving device n, etc.) through a long-distance connection, where n is a positive integer greater than 1.

[0186] In other embodiments, as shown in FIG7A , 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 a 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, as shown in Figure 7B, taking the first device in a home local area network as an example, the process of the first device accessing an external network (for example, a 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 a PON system and a switch (SW) for managing user access; the service control layer includes a BRAS and a service router (SR) for processing service distribution and calling, etc.; the core layer includes a 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 networks in which the first device and the receiving device discovered nearby (for example, the second device) are located may be different; for example, as shown in Figure 8A, 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 another example, as shown in FIG8B , 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] As shown in FIG9 , in some embodiments, the communication method 500 further includes steps 505 and 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] 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.

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

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

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

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

[0207] 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).

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

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

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

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

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

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

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

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

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

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

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

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

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

[0221] 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;

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

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

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

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

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

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

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

[0229] 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).

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

[0231] 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 Wifi Direct. However, the number of devices that the first device can connect to via Wifi Direct has reached the upper limit (i.e., the number threshold), and the first device cannot establish interconnection with the second device via Wifi Direct. In this case, interconnection with the second device can be established via a long-distance connection (e.g., a far-field P2P method). When the current number of connections connected by the first device using Wifi Direct does not reach the number threshold, it indicates that the current communication conditions meet the short-distance connection requirements, and interconnection with the second device can be established via Wifi Direct.

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

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

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

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

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

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

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

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

[0240] For example, as shown in FIG10 , 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. The process steps are as follows:

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

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

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

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

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

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

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

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

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

[0250] 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).

[0251] For example, as shown in FIG10 , the first device and the second device may establish a second long-distance connection through a far-field P2P relay, specifically including (prerequisite being that the first device and the second device can communicate with the relay server respectively):

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

[0253] 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).

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

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

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

[0257] 11A and 11B , two long-distance connection methods are introduced below, one of which is a far-field P2P hole punching method (or a far-field P2P traversal method), and the other is a far-field P2P transit method (or a far-field P2P relay method). It should be noted that the far-field P2P hole punching method is not limited to the method shown in FIG11A . FIG11A only shows the far-field P2P hole punching method when two devices are in different network address translations (NATs). The far-field P2P hole punching method when the two devices are in the same NAT or in multiple levels of NAT can also realize mutual communication between the first device and the second device. This application does not limit this.

[0258] As shown in Figure 11A, a schematic diagram of the architecture of a far-field P2P hole punching method is shown. In Figure 11A, the addresses of the first device and the second device are both intranet addresses and are located under different routers (i.e., under different NATs), wherein the first device is located under router 1 and the second device is located under router 2. The first device (or second device) can communicate with a 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 and second devices each initialize X communication with the server, and the address mapping is shown in Figure 11A. For example, the first device and the second device establish a communication connection (e.g., a communication session).

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

[0260] As shown in FIG11B , 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 between 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.

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

[0262] As shown in Figure 12A, 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 Figure 12B, user A can click the "Settings" icon 1202 on the main interface of mobile phone 1. At this time, mobile phone 1 enters the settings interface 1203, as shown in Figure 12C; when the user clicks the screen casting option 1204 on the settings interface 1203, mobile phone 1 receives the click operation from the settings interface 1203 and enters the screen casting interface 1205 in response to the click operation, as shown in Figure 12D; user A can set permissions on the screen casting interface 1205. For example, the traffic mode used by mobile phone 1 when establishing a long-distance connection can be set in the far-field connection mode option: one is to use cellular or Wifi; the other is to use both cellular and Wifi (i.e., cellular & Wifi). Use; wherein, cellular can be understood as mobile phone 1 using mobile data traffic to establish a long-distance connection with other nearby devices (for example, the second device), and Wifi can be understood as mobile phone 1 using Wifi to establish a long-distance connection with other nearby devices (for example, the second device); for another example, in the search permission option, set only contacts or everyone, wherein, when user A is set to "only contacts", mobile phone 1 can carry contact information when sending broadcast information to nearby devices. For details, please refer to the relevant description of the part about broadcast information carrying contacts in the introduction of step 506 above; accordingly, when mobile phone 1 receives a response message from a nearby receiving device (for example, the second device), it can display the friend device in the "friend device" area, and the non-friend device in the "other devices" area. For details, please refer to the relevant description of the part about the first device displaying the second device in the introduction of step 506 above.

[0263] For example, as shown in Figure 12D, 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), mobile phone 1 can establish an interconnection with the device that meets the requirements and display the device that meets the requirements on the "Device Display Interface 1301" shown in Figure 13A, as shown in 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 appropriate traffic mode to establish a long-distance connection with the device that meets the requirements based on the current network environment.

[0264] It should also be noted that, when limiting the ability of only friend devices that meet the requirements to reply to the response message, the mobile phone 1 can display my device that meets the requirements separately from the friend devices that meet the requirements when displaying the devices that meet the requirements. For example, as shown in FIG13A , 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 not limiting the ability of only friend devices that meet the requirements to reply to the response message, the mobile phone 1 can display my device, friend device and non-friend device separately when displaying the devices that meet the requirements. For example, as shown in FIG13B , in addition to displaying the icon of “My Device” and the icon of “Friend Device” on the device display interface 1301, the icons of other devices are also displayed in the “Other Devices” area, where the “Other Devices” area displays icons of devices other than friend devices and my device. For details, please refer to the relevant description of the first device displaying the second device in steps 506 and 507 above.

[0265] In some other embodiments, as shown in FIG13C , user A selects the “Everyone” option 1302 in the permission setting options 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 FIG13D . For details, please refer to the relevant description of the first device displaying the second device in step 507 above.

[0266] For example, as shown in Figure 13D, user A selects device 002 (as shown in 1303 in Figure 13D) and clicks the "Request Screen Cast 1304" button to connect to the screen casting; at this time, 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 Figure 14A; when the device display interface 1301 displays a status message 1402 of "Connected", it means that mobile phone 1 and device 002 have established a connection, as shown in Figure 14B; however, in this display mode, the user only knows that mobile phone 1 and device 002 have established an interconnection, but cannot know the connection mode currently being used by mobile phone 1 and device 002; therefore, in an optional implementation mode, after mobile phone 1 establishes an interconnection with device 002, the currently used connection mode can be displayed in real time on the device display interface 1301, such as short-distance connection, long-distance connection, or dual-way parallel connection, so that the user can promptly know the connection mode currently being used by mobile phone 1 and device 002.

[0267] For example, taking the example of user A selecting mobile phone 1 to establish interconnection with device 002, as shown in FIG14C, after mobile phone 1 establishes 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 the example of user A selecting mobile phone 1 to establish interconnection with multiple devices (e.g., device 001, device 002, device 101, etc.), as shown in FIG14D, after mobile phone 1 establishes connection with multiple devices, 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; The device display interface 1301 dynamically displays the connection mode currently being used by mobile phone 1 and different devices. 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 both a short distance connection and a long distance connection in a dual-path parallel manner for data transmission.

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

[0269] For another example, still taking the example of establishing a connection between mobile phone 1 and device 002, as shown in Figure 14E, when the status message 1406 of "connection failed" appears on the device display interface 1301, it means that the connection between mobile phone 1 and device 002 has failed; at this time, the device display interface 1301 can also display a "message notification" dialog box 1407, and user A can choose to "re-request" or "stop request", as shown in Figure 14E; if user A chooses "re-request", at this time, mobile phone 1 executes steps 504 and 504 in method 500; at the same time, the interface shown in Figure 14A reappears on the device display interface 1301; if user A chooses "stop request", the device display interface 1301 returns to the interface shown in Figure 13D, and user A can re-select the device to be projected (for example, device 102) on the device display interface 1301.

[0270] For another example, as shown in FIG14F , mobile phone 1 has successfully established a connection with device 002, and the icon of device 002 will be displayed in the area of ​​“Currently connected device” on the video interface 1408; 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 select the “Request screen projection 1304” button on the device display interface 1301 shown in FIG13D to reconnect (that is, mobile phone 1 re-executes steps 503 and 504 to determine the connection method with device 002).

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

[0272] For another example, as shown in FIG16A , 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, as shown in FIG16B ; 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 a broadcast message to nearby devices, it can carry contact information. For details, please refer to the above The description of the broadcast information carrying contacts in step 506 of the previous text is as follows; 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 (i.e., a device that supports distributed services, short-range connections, and long-range connections), that is, when mobile phone 1 receives a response message (e.g., a first response message) sent by a nearby receiving device (e.g., a second device), mobile phone 1 can establish a connection with the qualified device and display the qualified device on the "Device Display Interface 1603" shown in Figure 16C. Since the user selected the "Cellular" option, mobile phone 1 can establish a long-range connection with the qualified device via cellular mode.

[0273] For example, as shown in FIG16C , in addition to displaying the “My Device” icon and the “Friend’s Device” icon 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 the selected device 101 and the device 102 become gray and selected, as shown in 1605 of Figure 16C; the user can click the "Enter picture selection" button 1604, at this time, mobile phone 1 jumps from the device display interface 1603 to the picture selection interface 1606, as shown in Figure 16D; user A selects the picture to be shared on the picture selection interface 1606, and after selecting the picture, he can click the "Start sharing" button 1607 to share the picture, where the "+" in the "Friend device" area can add the device to be shared, as shown in Figure 16D.

[0274] Accordingly, as shown in FIG17A , taking the example of device 101 receiving a picture sharing request sent by mobile phone 1, first, user C can turn on Wifi, Bluetooth and mobile data traffic in the status control bar 1701 of device 101 (another example of the second device); after turning on Wifi, Bluetooth and mobile data traffic, as shown in FIG17B , the received picture sharing message reminder 1703 is displayed on the main interface 1702 of device 101; if user C chooses “Accept”, mobile phone 1 successfully establishes a connection with device 101 (for example, a short-distance connection or a long-distance connection, etc.); at this time, mobile phone 1 can share pictures with device 101; if user C chooses “Reject”, the picture sharing between mobile phone 1 and device 101 fails. Failure; for example, when user C chooses "Accept", the picture information 1704 shared by mobile phone 1 appears on the main interface 1702, as shown in FIG17C, and user C can view or save it as the received picture; in some cases, such as when the network signal is poor, the 101 device may fail to receive the picture; as shown in FIG17D, 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 continues to receive the picture shared by mobile phone 1; if user C chooses "give up", the 101 device disconnects from mobile phone 1, and the picture sharing fails or ends.

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

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

[0277] FIG18 is a schematic diagram illustrating the structure of a terminal device provided by the present application. The dashed lines in FIG18 indicate that the unit or module is optional. Terminal device 1800 can be used to implement the method described in the above method embodiment. Terminal device 1800 can be a server or a chip (system).

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

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

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

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

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

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

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

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

[0286] 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 (SynchLink DRAM, SLDRAM), and direct RAM bus random access memory (DRRAM).

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

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

[0289] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein, and these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application. Finally, the above is only a specific implementation method of the present application, but the protection scope of the present application is not limited thereto, and any changes or replacements within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope 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 Determining 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 Determining 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 obtain 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.

Citation Information

Patent Citations

  • File sharing method and electronic equipment

    CN115278616A

  • Image display method, electronic equipment and terminal equipment

    CN116668938A

  • Device and method for transmitting file

    KR1020150134266A

  • Systems and Methods for Optimizing the Topology of a Bluetooth Scatternet for Social Networking

    US20080080397A1

  • Bluetooth binding method and bluetooth device

    WO2016197572A1