Connection method between devices and electronic device

By negotiating the P2P role with the third device when there is already a P2P connection between devices, and establishing a new P2P connection when supporting multiple P2P connection groups, the problem of failed connection establishment between PC and existing P2P connection devices is solved, and lower link overhead and power consumption is achieved.

CN119946908APending Publication Date: 2025-05-06HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410374464.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-24
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

When there is already an interconnection service between devices to establish a P2P connection, when the PC initiates a P2P connection request to any device in the P2P connection, the PC fails to establish a P2P connection with the device.

Method used

By negotiating the P2P role with the third device (such as a laptop) in the case where the first device (such as a mobile phone) and the second device (such as a tablet), if the role negotiation result conflicts with the existing P2P connection, the first device determines the number of P2P connection groups it supports to establish simultaneously. If the number is greater than or equal to 2, the first device establishes a second P2P connection with the third device and ensures that the new connection and the existing connection do not belong to the same P2P connection group.

Benefits of technology

When there is already a P2P connection between devices, the PC establishes a new P2P connection with other devices, avoiding connection failures caused by role conflicts and reducing link overhead and power consumption caused by connection conflicts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119946908A_ABST
    Figure CN119946908A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a method for connecting equipment and electronic equipment, relates to the technical field of electronics, and is used for establishing new P2P connection with a PC (Personal Computer) under the condition that the equipment establishes P2P connection with other equipment. The method is applied to a first device, and comprises the following steps: after the first device establishes a first P2P connection with a second device, the first device negotiates a P2P role with a third device in response to a first event to obtain a role negotiation result; the first event comprises that the first device receives a P2P connection request from a third device, or the first device sends the P2P connection request to the third device; if the role negotiation result conflicts with the first P2P connection, the first device obtains the number of P2P connection groups which are supported by the first device and established at the same time; if the number is greater than or equal to 2, the first device establishes a second P2P connection with the third device; and the first device and the third device establish a first service session through the second P2P connection.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application. The application number of the original application is 202311381373.3, and the original application date is October 24, 2023. The entire contents of the original application are incorporated into this application by reference. Technical Field

[0002] The embodiments of the present application relate to the field of electronic technology, and in particular to a method for connecting devices and an electronic device. Background Art

[0003] With the development of technology, it is possible to achieve mutual trust and communication between multiple devices (such as mobile phones, tablet computers, personal computers (PCs), smart screens, etc.). In related technologies, the interconnection between multiple devices can be achieved through various connection capabilities such as Bluetooth connection, peer-to-peer (P2P), and wireless local area network (WLAN). Among them, services such as super keyboard and mouse, super call transfer, and document continuation usually use P2P links for data transmission.

[0004] P2P connections are divided into two roles: Group Owner (GO) and Group Client (GC). The two devices that establish a P2P connection need to be in the role of GO or GC respectively to complete the connection. The role of the device in the same P2P connection cannot be changed. In addition, if the P2P connection includes a PC, the PC can only serve as the GO role in the P2P connection.

[0005] Therefore, when there is an interconnection service between devices to establish a P2P connection, if the PC initiates a P2P connection request to any device in the P2P connection, the PC will fail to establish a P2P connection with the device. Summary of the invention

[0006] The embodiments of the present application provide a method for connecting devices and an electronic device, which are used to establish a new P2P connection with a PC when the device has established a P2P connection with other devices.

[0007] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0008] In a first aspect, a method for connecting devices is provided, the method being applied to a first device, the first device supporting establishing a point-to-point (P2P) connection with other devices. The method comprises:

[0009] In the case where the first device establishes a first P2P connection with the second device, the first device negotiates the P2P role with the third device in response to the first event and obtains the role negotiation result. The first event includes: the first device receives a P2P connection request from the third device, or the first device sends a P2P connection request to the third device. If the role negotiation result conflicts with the first P2P connection, the first device obtains the number of P2P connection groups that the first device supports to be established simultaneously. If the number of P2P connection groups that the first device supports to be established simultaneously is greater than or equal to 2, the first device establishes a second P2P connection with the third device, and the first P2P connection and the second P2P connection do not belong to the same P2P connection group. In this way, even if the first device has different roles in the second P2P connection and the first P2P connection, no conflict will occur. Finally, the first device and the third device establish a first service session through the second P2P connection. Thereby, communication between the first device and the third device is achieved.

[0010] In this solution, when the first device supports establishing more than two P2P connection groups at the same time, even if the result of the role negotiation between the first device and the third device conflicts with the P2P connection (such as the first P2P connection) already established by the first device, the first device can still establish a P2P connection with the third device. That is, the first device establishes two different P2P connection groups at the same time, and establishes P2P connections with the second device and the third device in the two different P2P connection groups respectively. In this way, no conflict will occur, and the problem of connection failure caused by P2P connection conflict in the first device can be reduced.

[0011] In a possible implementation of the first aspect, after the first device establishes a first P2P connection with the second device, the first device and the second device establish a second service session based on the first P2P connection. After the first device establishes a second P2P connection with the third device, the method may further include: the first device switches from supporting the second service session through the first P2P connection to supporting the second service session through the third device and the second P2P connection. In this way, it is convenient to disconnect the first P2P connection between the first device and the second device, reduce the link overhead of the first device, and thereby reduce the power consumption of the mobile phone.

[0012] In another possible implementation of the first aspect, the first device supports the second service session through the first P2P connection, and switches to supporting the second service session through the third device and the second P2P connection, which may specifically include: the first device sends a first indication message to the second device. In this way, the second device can establish a P2P connection with the third device according to the first indication information, and return a first response message to the first device to indicate whether the second device has established a P2P connection with the third device. The first device receives the first response message returned by the second device. In the case where the first response message indicates that the second device has established a third P2P connection with the third device, the first device switches from transmitting the session data of the second service session through the first P2P connection to transmitting the session data of the second service session through the second P2P connection and the third P2P connection. Thereby, the third device forwards the session data of the service session for the first device and the second device. Finally, the first device disconnects the first P2P connection between the first device and the second device.

[0013] In this solution, when the first device has established two P2P connection groups at the same time, an attempt is made to switch the service session of the P2P connection in one of the P2P connection groups to the P2P connection of the other P2P connection group. If the switch is successful, the first device can disconnect the connection in one P2P connection group, that is, the first P2P connection, and only retain the connection in one P2P connection group, that is, the second P2P connection. And it is possible to simultaneously realize the communication between the first device and the third device, and the communication between the first device and the second device. In this way, the link overhead of the first device can be reduced, the power consumption of the first device can be reduced, and thus the performance of the first device can be improved. And it is possible to switch the P2P connection channel without the user's perception, reducing the impact on the user and the second service session.

[0014] In another possible implementation of the first aspect, the above-mentioned role negotiation result conflicts with the first P2P connection, which may specifically include: the first device is the group manager GO role in the first P2P connection, the second device is the group client GC role in the first P2P connection, and the role negotiation result is that the third device requests to establish a P2P connection with the first device as the GO role.

[0015] In another possible implementation manner of the first aspect, the above-mentioned role negotiation result conflicts with the first P2P connection, which may specifically include: the first device is the GC role in the first P2P connection, the second device is the GO role in the first P2P connection, and the role negotiation result is that the third device requests to establish a P2P connection with the first device as the GO role.

[0016] In another possible implementation manner of the first aspect, the above-mentioned role negotiation result conflicts with the first P2P connection, which may specifically include: the first device is the GC role in the first P2P connection, the second device is the GO role in the first P2P connection, and the role negotiation result is that the third device requests to establish a P2P connection with the first device as the GC role.

[0017] In another possible implementation of the first aspect, the method further includes: if the number of P2P connection groups that the first device supports to be established simultaneously is less than 2, the first device generates connection confirmation information. The connection confirmation information is used to confirm whether the connection corresponding to the P2P connection request is allowed to preempt the first P2P connection. In this way, when the P2P connection to be established conflicts with the currently existing P2P connection, the user can decide whether to preempt the current P2P connection. After the first device receives the first operation based on the connection confirmation information, the first device disconnects the first P2P connection with the second device. The first operation is used to indicate that the connection corresponding to the P2P connection request is allowed to preempt the first P2P connection. Finally, the first device establishes a fourth P2P connection with the third device. In this way, the P2P connection is more in line with the needs of users.

[0018] In another possible implementation of the first aspect, the method further includes: after the first device receives the second operation based on the connection confirmation information, the first device does not perform an operation. The second operation is used to indicate that the connection corresponding to the P2P connection request is not allowed to preempt the first P2P connection. That is, when the first device does not support the establishment of more than two P2P connections at the same time, and the user chooses not to preempt the current existing P2P connection, the first device will retain the existing P2P connection and no longer establish a P2P connection with the third device. In this way, the P2P connection is more in line with the needs of the user.

[0019] In another possible implementation of the first aspect, the first device stores priority information, and the priority information includes the priority of each service. According to the priority information, the priority order between the services can be determined. The method also includes: if the number of P2P connection groups supported by the first device to be established simultaneously is less than 2, the first device disconnects the first P2P connection when the priority of the first service corresponding to the P2P connection request is greater than the priority of the second service corresponding to the first P2P connection. Then, the first device establishes a fourth P2P connection with the third device.

[0020] In this solution, when the role negotiation result conflicts with the first P2P connection and the first device does not support the establishment of two P2P connection groups at the same time, the first device can determine whether to allow the new P2P connection request to preempt the current existing P2P connection based on the service priority. In this way, when a P2P connection conflict occurs, it can be ensured that the service with a higher priority will establish a connection and transmit service data first.

[0021] In another possible implementation manner of the first aspect, after the first device establishes the fourth P2P connection with the third device, the method may further include: the first device restoring the service session between the first device and the second device through the third device and the fourth P2P connection.

[0022] In another possible implementation of the first aspect, the first device restores the service session between the first device and the second device through the third device and the fourth P2P connection, which may specifically include: the first device sends a second indication message to the second device. The second indication message is used for the second device to establish a P2P connection with the third device. The first device receives a second response message returned by the second device. The second response message is used to indicate whether the second device has established a P2P connection with the third device. In the case where the second response message indicates that the second device has established a fifth P2P connection with the third device, the first device restores the service session with the second device through the second P2P connection and the fifth P2P connection.

[0023] After the first P2P connection between the first device and the second device is disconnected, the service session between the first device and the second device is also disconnected. In this solution, after the first device establishes a second P2P connection with the third device, the first device can notify the second device to establish a P2P connection with the third device, that is, the fifth P2P connection. Afterwards, the service session between the first device and the second device can be restored through the second P2P connection and the fifth P2P connection. In this way, the impact of disconnecting the first P2P connection on the user and on the service session between the first device and the second device can be reduced.

[0024] In another possible implementation of the first aspect, the first device restores the service session with the second device through the second P2P connection and the fifth P2P connection, which may specifically include: the first device sends first data to the third device through the second P2P connection, and the third device forwards the first data to the second device through the fifth P2P connection. The second device sends second data to the third device through the fifth P2P connection, and the third device forwards the second data to the first device through the second P2P connection. In this way, the third device can be used as a transit device to implement the transmission of service session data between the first device and the second device.

[0025] In another possible implementation of the first aspect, the data sent by the first device to the third device through the second P2P connection carries identification information of the recipient. The first data (the actual recipient is the second device) sent by the first device to the third device carries the IP address of the second device. The data that the first device needs to send to the third device may carry the IP address of the third device, so that it is convenient for the third device to determine the recipient of the data and reduce the possibility of data transmission errors.

[0026] The data sent by the first device and the second device to the third device through the fifth P2P connection can also carry the identification information of the recipient. For example, the second data (actual recipient is the first device) sent by the second device to the third device carries the IP address of the first device. In this way, it is convenient for the third device to determine the recipient of the data and reduce the possibility of data transmission errors.

[0027] In another possible implementation of the first aspect, the first device is provided with a preset chip, and one preset chip supports the first device to establish a P2P connection group. The method further includes: the first device queries the number of preset chips set for the first device. Then, the first device determines the number of P2P connection groups that the first device supports to be established simultaneously based on the number of preset chips. Since one preset chip supports the first device to establish a P2P connection group, the first device can determine the number of P2P connection groups that the first device supports to be established simultaneously by querying the number of preset chips.

[0028] In another possible implementation of the first aspect, the first device and the second device establish a first P2P connection, which can be established based on a first preset chip. In the case where the role negotiation result conflicts with the first P2P connection, the first device and the third device can establish a second P2P connection based on a second preset chip. In this way, it can be ensured that the first P2P connection and the second P2P connection belong to different P2P connection groups, avoiding the problem of role conflict.

[0029] In a second aspect, an electronic device is provided, comprising: a processor and a memory; the memory is used to store computer execution instructions, and when the electronic device is running, the processor executes the computer execution instructions stored in the memory to enable the electronic device to perform a method for connecting devices as described in any one of the first aspects above.

[0030] In a third aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is executed on a computer, the computer can execute any one of the methods for connecting devices in the first aspect.

[0031] In a fourth aspect, a computer program product comprising instructions is provided, which, when executed on an electronic device, enables the electronic device to execute any one of the inter-device connection methods in the first aspect.

[0032] In a fifth aspect, a device (for example, the device may be a chip system) is provided, the device including a processor for supporting an electronic device to implement the functions involved in the first aspect above. In one possible design, the device also includes a memory for storing program instructions and data necessary for the electronic device. When the device is a chip system, it may be composed of a chip, or may include a chip and other discrete devices.

[0033] Among them, the technical effects brought about by any design method in the second to fifth aspects can refer to the technical effects brought about by different design methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A schematic diagram of a flow chart of a method for connecting devices in a related technology provided in an embodiment of the present application;

[0035] Figure 2 A schematic diagram of a process for establishing a P2P connection between device A and device B provided in an embodiment of the present application;

[0036] Figure 3 A schematic diagram of a connection scenario between electronic devices provided in an embodiment of the present application;

[0037] Figure 4 A schematic diagram of a connection scenario between electronic devices provided in an embodiment of the present application;

[0038] Figure 5 A schematic diagram of a connection scenario between electronic devices provided in an embodiment of the present application;

[0039] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0040] Figure 7 A software architecture diagram of an electronic device provided in an embodiment of the present application;

[0041] Figure 8 A flowchart of a method for connecting devices provided in an embodiment of the present application;

[0042] Fig. 9 A schematic diagram of a connection scenario between electronic devices provided in an embodiment of the present application;

[0043] Fig.10 A flowchart of a method for connecting devices provided in an embodiment of the present application;

[0044] Fig.11 A schematic diagram of a connection scenario between electronic devices provided in an embodiment of the present application;

[0045] Fig.12 A flowchart of a method for connecting devices provided in an embodiment of the present application;

[0046] Fig.13 A flowchart of a method for connecting devices provided in an embodiment of the present application;

[0047] Fig.14 A flowchart of a method for connecting devices provided in an embodiment of the present application;

[0048] Fig.15 A flowchart of a method for connecting devices provided in an embodiment of the present application;

[0049] Fig.16 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] The following is a brief description of the technical terms that may be involved in the embodiments of the present application.

[0051] P2P Group Owner: GO for short, is a role in the protocol, equivalent to AP. There is only one GO in a group.

[0052] P2P Group Client: GC for short, is another role. There can be multiple GCs in a group.

[0053] P2P connection is divided into two roles: GO and GC. The two devices that establish a P2P connection need to be GO or GC roles to complete the connection. In the same P2P connection, the role cannot change. In a P2P connection group, a GO role can connect to multiple GC roles, while a GC role is only allowed to establish a connection with one GO role. In some embodiments, a PC can only be connected to other devices as a GO role in a P2P architecture. PCs can include desktop computers, laptops, small laptops such as PDAs, all-in-one computers, ultrabooks, and embedded computers.

[0054] The services of mutual trust and communication between multiple devices may include: sharing, PC collaboration, PAD accompanying, screen projection, super keyboard and mouse, camera sharing, network sharing, memo synchronization, super call transfer, and document continuation. Some of these services are implemented through P2P connection. In some embodiments, services such as sharing, PC collaboration, PAD accompanying, and screen projection can be classified as the first type of interconnected services; super keyboard and mouse, camera sharing, network sharing, memo synchronization, super call transfer, and document continuation can be classified as the second type of interconnected services; such as smart interconnected services.

[0055] When a P2P connection has been established between device A and device B, if device C initiates a P2P connection request to device A or device B, device A or device B will first determine whether the P2P connection request conflicts with the established connection. If the connection request of device C conflicts with the role of the established P2P connection, device C will not be able to establish a P2P connection with device A or device B.

[0056] Exemplarily, device A has established a P2P connection with device B. After the user triggers the interconnection service on device A, device A will determine the object that needs to establish a P2P connection based on the interconnection service, such as device C. Then, device A and device C will conduct P2P role negotiation to obtain a role negotiation result. Device A determines whether there is a conflict with the existing P2P connection based on the role negotiation result. If the role negotiation result does not conflict with the existing P2P connection, device A can directly establish a P2P connection with device C. If the role negotiation result conflicts with the existing P2P connection, device A will prompt the user that the service conflicts and the connection fails.

[0057] Among them, the user can trigger the interconnection service through the service module of device A. The service module of device A sends instructions to the connection module of device A according to the user's operation, so that the connection module of device A and the connection module of device C perform role negotiation. In the case of determining that the role negotiation result conflicts with the existing P2P connection, the connection module of device A can return a fault code to the service module of device A. After receiving the fault code, the service module of device A can send a prompt message to the user according to the fault code.

[0058] In some embodiments, when it is determined that the role negotiation result conflicts with the existing P2P connection, the connection module of device A may return different fault codes to the service module of device A according to different interconnection services. Figure 1 After the user triggers the interconnection service, different connection modules negotiate roles with device C according to the service content. Figure 1The first connection module and the second connection module are used as examples for explanation. If the interconnection service triggered by the user belongs to the service of the first connection module, the first connection module performs role negotiation with device C. The first connection module determines whether the role negotiation result between device A and device C conflicts with the existing P2P connection. If not, the first connection module of device A directly establishes a P2P connection with device C and returns a successful connection result to the service module. If the role negotiation result between device A and device C does not conflict with the existing P2P connection, the first connection module determines whether to establish a connection for this application based on the interconnection service. If it is this application that requests to establish a connection, fault code 1 is returned to the service module; if it is not this application that requests to establish a connection, fault code 2 is returned to the service module.

[0059] If the interconnection service belongs to the service of the second connection module, the second connection module performs role negotiation with device C. The second connection module determines whether the role negotiation result between device A and device C conflicts with the existing P2P connection. If not, the second connection module directly establishes a P2P connection with device C and returns a successful connection result to the service module. If the role negotiation result between device A and device C conflicts with the existing P2P connection, the second connection module returns a corresponding fault code to the service module according to the type of interconnection service.

[0060] Furthermore, after the first connection module or the second connection module returns the connection result or the fault code to the service module, the service module may issue a prompt message according to the connection result or the fault code. For example, when the service module receives a connection result indicating a successful connection, it may issue a prompt message indicating a successful connection. For another example, when the service module receives a fault code, it may issue a prompt message indicating a failed connection according to the fault code, and so on.

[0061] The process of establishing a P2P connection between two devices may include the following steps: negotiation channel establishment, P2P connection information negotiation, P2P connection establishment, communication IP configuration, and P2P control channel establishment. Figure 2 A specific flow chart of establishing a P2P connection between device A and device B in some embodiments is shown. Device A includes a connection module and a communication module; device B includes a connection module and a communication module. The connection module of device A or device B specifically includes: a device management submodule / session service submodule (DeviceManager / SessionService), a bus management submodule & identity authentication management submodule (BusManager&AuthManager) and a P2P connection management submodule (P2PLinkManager). The communication module can specifically be a Wi-Fi module or a Bluetooth module.

[0062] When DeviceManager / SessionService1 in the connection module of device A receives the device connection instruction (connectDevice), DeviceManager / SessionService1 sends an authentication connection opening instruction (openAuthConn) to Bus Manager&AuthManager1. In response to the authentication connection opening instruction, device A and device B establish a WLAN or Bluetooth (such as BR) connection channel (encrypted) as a negotiation channel for subsequent P2P connections. Then Bus Manager&AuthManager1 notifies DeviceManager / SessionService1 of the successful authentication message (onAuthConnOpened).

[0063] Next, DeviceManager / SessionService1 sends a device connection instruction (connectDevice) to P2PLinkManager1. In response to the device connection instruction, P2PLinkManager1 negotiates the P2P channel with P2PLinkManager2 of device B. Device A negotiates the P2P channel with device B through P2PLinkManager1, which may specifically include: P2PLinkManager1 sends a connection request (ConnectRequest) to P2PLinkManager2, and P2PLinkManager2 returns a connection response (ConnectResponse) to P2PLinkManager1. Then, P2PLinkManager1 sends a group establishment instruction (createGroup) to the communication module 1 of device A, and the communication module 1 returns the group connection status (including the connecting status and the connected status) and the P2P role of device A (GO role) to P2PLinkManager1 in turn.

[0064] After receiving the group establishment status returned by communication module 1 as connected, P2PLinkManager1 of device A sends a connection request to P2PLinkManager2 of device B to confirm the connection. During the connection confirmation process, the connection status is confirmed between P2PLinkManager2 of device B and communication module 2. P2PLinkManager2 sends a group establishment instruction to communication module 2 of device B, and communication module 2 returns the group connection status (including connecting status and connected status) to P2PLinkManager1 in sequence. After detecting that the connection status of device B is connected, communication module 1 will notify P2PLinkManager1 that device B is successfully connected (GC connection successful). After confirming that the connection status is connected, P2PLinkManager2 of device B returns a connection response to P2PLinkManager1.

[0065] After successfully establishing a P2P connection between device A and device B, P2PLinkManager1 returns a successful connection message to DeviceManager / SessionService1. DeviceManager / SessionService1 can further return a successful connection message to the business module. After that, P2PLinkManager2 of device B can create a P2P encrypted channel. After successfully establishing a connection between device A and device B, a handshake protocol can be performed.

[0066] The following uses device A as a mobile phone, device B as a tablet computer, and device C as a laptop computer as examples to illustrate several scenarios.

[0067] Please refer to Figure 3, a P2P connection 0 is established between mobile phone 1 and tablet computer 2, and super call transfer is realized through the P2P connection 0. For example, mobile phone 1 is the GO role in the P2P connection 0, and tablet computer 2 is the GC role in the P2P connection 0. At this time, laptop computer 3 initiates a P2P connection request to mobile phone 1 or tablet computer 2 to establish a super keyboard and mouse service or PC collaborative service with mobile phone 1 or tablet computer 2, and mobile phone 1 or tablet computer 2 will negotiate the P2P role with laptop computer 3. Since laptop computer 3 can only serve as a GO role in the P2P connection, and mobile phone 1 is the GO role in the P2P connection 0, a P2P connection cannot be established between mobile phone 1 and laptop computer 3. For tablet computer 2, tablet computer 2 is the GC role in the P2P connection, but since a GC role can only be connected to one GO role, tablet computer 2 cannot establish a P2P connection with laptop computer 3. In other words, when mobile phone 1 and tablet computer 2 have established a P2P connection, the P2P connection request initiated by laptop computer 3 to mobile phone 1 or tablet computer 2 will fail to connect.

[0068] Or, if Figure 4 As shown, mobile phone 1 establishes P2P connection 0 with tablet computer 2, and implements memo synchronization service through P2P connection 0. For example, mobile phone 1 is the GO role in P2P connection 0, and tablet computer 2 is the GC role in P2P connection 0. At this time, mobile phone 1 or tablet computer 2 initiates a P2P connection request to laptop computer 3 to establish a super call transfer service with laptop computer 3. Similarly, since PC can only act as GO in P2P connection, and P2P connection 0 has been established between mobile phone 1 and tablet computer 2. Therefore, mobile phone 1 or tablet computer 2 cannot establish a new P2P connection with PC.

[0069] Or, if Figure 5 As shown, mobile phone 1 establishes a P2P connection 0 with tablet computer 2 for implementing the PAD follow-along service. At this time, mobile phone 1 initiates a P2P connection request to laptop computer 3 to establish a super call transfer service with laptop computer 3. Similarly, due to role conflict, mobile phone 1 may fail to establish a P2P connection with PC.

[0070] In the above situations, P2P connection failure may occur. In view of the situation that device A attempts to establish a new P2P connection with device C, and the new P2P connection conflicts with the existing P2P connection of device A, the present application proposes a method for connecting devices. The method is applied to electronic devices. After the first device and the second device have established a first P2P connection, the first device receives a P2P connection request sent by a third device, or the first device sends a P2P connection request to the third device, and the first device and the third device will perform P2P role negotiation. After obtaining the P2P role negotiation result, if the role negotiation result conflicts with the first P2P connection, the first device determines the number of P2P connection groups that the first device supports to be established simultaneously. If the first device supports the establishment of more than two different P2P connection groups at the same time, the first device establishes a second P2P connection with the third device. Afterwards, the first device and the third device can communicate based on the second P2P connection. In some embodiments, the first device receives a P2P connection request from a third device, or the first device sends a P2P connection to a third device, which can be collectively referred to as a first event.

[0071] In this solution, if the new P2P connection that the first device needs to establish conflicts with the existing P2P connection, and the first device has the ability to simultaneously establish more than two different P2P connection groups, the first device establishes a new P2P connection, and the new P2P connection and the existing P2P connection belong to different P2P connection groups. Afterwards, the first device and the third device can communicate based on the newly established P2P connection, such as establishing a first service session. In this way, when the new P2P connection to be established conflicts with the existing P2P connection, a new P2P connection can still be established.

[0072] Among them, in some embodiments, the role negotiation result between the first device and the third device conflicts with the first P2P connection, which may specifically include: the first device is the GO role in the first P2P connection, and the role negotiation result is that the third device requests to establish a P2P connection with the first device as the GO role. Alternatively, when the first device is the GC role in the first P2P connection, and the role negotiation result is that the third device requests to establish a P2P connection with the first device as the GO role, it also indicates that the above role negotiation result conflicts with the first P2P connection.

[0073] Further, after the first device simultaneously establishes the first P2P connection and the second P2P connection, the power consumption of the first device may be high. In order to avoid the high power consumption of the first device, after the first device establishes the second P2P connection with the third device, the second service session established by the first device and the second device through the first P2P connection can be switched to the second P2P connection for implementation. Exemplarily, after the first device establishes the second P2P connection with the third device, the first device sends the first indication information to the second device. The first indication information can be used to indicate that the second device establishes a P2P connection with the third device. In addition, the second device can also feedback a response message to the first device to indicate whether the second device has established a P2P connection with the third device. After the first device receives the response message fed back by the second device to the first device and determines that the second device has established a third P2P connection with the third device, the first device can start to support the second service session through the second P2P connection and the third P2P connection. Since the second service session has been switched to be implemented through the second P2P connection between the first device and the third device, and the third P2P connection between the third device and the second device, the first P2P connection is no longer required. Finally, the first device can disconnect the first P2P connection, thereby reducing the power consumption of the first device and improving the performance of the first device. In addition, the first device first instructs the second device to establish a third P2P connection with the third device, switches the second session service to the second P2P connection and the third P2P connection, and then disconnects the first P2P connection. As a result, the second service session will not be interrupted, and for the user, the P2P connection channel can be switched without perception, reducing the impact of the P2P connection switching on the service.

[0074] Among them, the number of P2P connection groups that the first device supports to be established simultaneously depends on the P2P connection chip included in the first device. In some embodiments, the first device includes two P2P connection chips, and the first device supports the simultaneous establishment of two different P2P connection groups. When the first device establishes two different P2P connection groups at the same time, the role of the first device may be the same in the two different P2P connection groups; for example, the first device is the GC role in the above-mentioned first P2P connection, and the first device is the GC role in the above-mentioned second P2P connection. The role of the first device in two different P2P connection groups may also be different, such as the first device is the GO role in the above-mentioned first P2P connection, and the first device is the GC role in the above-mentioned second P2P connection.

[0075] The electronic devices may be mobile phones, tablet computers, personal computers (PC), smart screens, desktops, laptops, handheld computers, notebook computers, ultra-mobile personal computers (UMPC), netbooks, smart watches and other wearable devices, artificial intelligence (AI) speakers and vehicle-mounted devices, various teaching aids (such as learning machines, early childhood education machines), smart toys, portable robots, personal digital assistants (PDA), augmented reality (AR) and virtual reality (VR) devices, media players and other devices, and may also be devices with mobile office functions, devices with smart home functions, devices with audio and video entertainment functions, devices supporting smart travel, etc. The embodiments of the present application do not impose any special restrictions on the specific form of the device.

[0076] like Figure 6 The figure shows a schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application. Exemplarily, the electronic device 100 may be a mobile phone. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 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, an audio module 170, a sensor module 180, a button 190, a motor 191, cameras 1 to N192, a display screen 1 to N193, a subscriber identification module (SIM) card interface 1 to N194, and a preset chip 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a touch sensor 180B, etc.

[0077] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0078] The processor 110 may include one or more processing units, for example: the processor 110 may include a CPU, an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural network processor (neural-network processing unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors. For example, the processor 110 is used to execute the image processing method and calibration method in the embodiments of the present application.

[0079] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0080] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0081] The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. 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 and an application required for at least one function (such as a sound playback function, an image playback function, etc.).

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

[0083] 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 external memory, the display screen 193, the camera 192, and the wireless communication module 160.

[0084] In some other embodiments, the power management module 141 may also be disposed in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 may also be disposed in the same device.

[0085] The electronic device 100 implements the display function through a GPU, a display screen 193, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 193 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0086] The electronic device 100 may capture images, record videos, etc. through the camera 192. In some embodiments, the electronic device 100 may include 1 or N cameras.

[0087] The display screen 193 is used to display images, videos, etc. In some embodiments, the electronic device 100 may include 1 or N display screens 193 , where N is a positive integer greater than 1.

[0088] In some embodiments of the present application, the preset chip 195 can be used to establish a P2P connection. One preset chip 195 can establish a P2P connection group. In some embodiments, the electronic device 100 may include 1 or N preset chips 195, where N is a positive integer greater than 1. In some embodiments, the above preset chip can also be set in the wireless communication module 160.

[0089] The method for connecting devices in the following embodiments may be implemented in the electronic device 100 having the above hardware structure.

[0090] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.

[0091] Figure 7 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

[0092] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom: application layer, application framework layer, Android runtime (ART) and native C / C++ library, hardware abstract layer (HAL) and kernel layer.

[0093] The application layer can include a series of application packages.

[0094] like Figure 7 As shown, the application package may include applications such as gallery, calendar, map, WLAN, music, SMS, call, navigation, Bluetooth, video, and Internet services.

[0095] Among them, the interconnection service can be used for electronic devices to carry out interconnection services with other electronic devices, including super call transfer service, memo synchronization service, super keyboard and mouse service, PC collaboration and so on.

[0096] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0097] like Figure 7 As shown, the application framework layer may include a window manager, a content provider, a view system, a resource manager, a notification manager, an activity manager, an input manager, and a connection module, etc.

[0098] In some embodiments of the present application, the connection module is used to receive instructions sent by the application and notify the communication module to establish a P2P connection with other electronic devices.

[0099] The window manager provides window management services (WMS). WMS can be used for window management, window animation management, surface management, and as a transfer station for the input system.

[0100] Content providers are used to store and retrieve data and make it accessible to applications. This data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0101] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0102] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0103] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0104] The activity manager can provide activity management services (AMS), which can be used to start, switch, and schedule system components (such as activities, services, content providers, and broadcast receivers) as well as manage and schedule application processes.

[0105] The input manager can provide input management services (IMS), which can be used to manage system input, such as touch screen input, key input, sensor input, etc. IMS takes events from input device nodes and distributes them to appropriate windows through interaction with WMS.

[0106] The Android runtime includes the core library and the Android runtime. The Android runtime is responsible for converting source code into machine code. The Android runtime mainly uses the ahead of time (AOT) compilation technology and the just in time (JIT) compilation technology.

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

[0108] The native C / C++ library can include multiple functional modules, such as surface manager, media framework, libc, Open Graphics Library for Embedded Systems (OpenGL ES), SQL database (SQLite), Webkit, etc.

[0109] Among them, the surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media framework supports playback and recording of multiple commonly used audio and video formats, as well as static image files, etc. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. OpenGL ES provides drawing and operation of 2D graphics and 3D graphics in applications. SQLite provides a lightweight relational database for applications of electronic device 100.

[0110] The hardware abstraction layer runs in user space, encapsulates the kernel layer driver, and provides a calling interface to the upper layer. The hardware abstraction layer can include: display module, audio module, camera module, Bluetooth module, etc.

[0111] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, audio driver, camera driver, and Bluetooth driver, etc.

[0112] The following is a brief description of the process of the device connection method provided in the embodiment of the present application in conjunction with the software architecture. The user triggers the interconnected service in the interconnected service application in the application layer. The interconnected service application notifies the connection module in the application framework layer to establish a P2P connection. The connection module communicates with the device to be connected through a communication module such as a Bluetooth module in the hardware abstraction layer, and establishes a P2P connection. Afterwards, a session channel can be established in the electronic device through the P2P connection for transmitting session data of the interconnected service. In some embodiments, the software module corresponding to the interconnected service application can be recorded as a service module. The business involved in the embodiment of the present application is an interconnected business.

[0113] The method for connecting devices provided in the embodiments of the present application can be specifically applied in a P2P connection scenario between devices. When a device that has established a P2P connection needs to establish a new P2P connection with a third device, and the role negotiation result of the new P2P connection conflicts with the existing P2P connection, the conflict problem can be resolved by the embodiments of the present application to establish a new P2P connection.

[0114] The following will describe in detail the method for connecting devices provided by the present application in conjunction with the accompanying drawings.

[0115] Figure 8 A flow chart of a method for connecting devices in some embodiments of the present application is shown. In this embodiment, the first device is a mobile phone, the second device is a tablet computer, and the third device is a notebook computer. In other embodiments, the first device, the second device, and the third device may also be other electronic devices.

[0116] S801. The mobile phone and the tablet computer establish a P2P connection 0.

[0117] In some embodiments, the GO role in P2P connection 0 may be a mobile phone, and the GC role may be a tablet computer. In other embodiments, the GO role in P2P connection 0 may be a tablet computer, and the GC role may be a mobile phone. In some embodiments, P2P connection 0 may also be recorded as the first P2P connection.

[0118] The process of establishing a P2P connection between a mobile phone and a tablet can be referred to Figure 2 The process shown will not be described in detail here.

[0119] It is understandable that after the mobile phone and the tablet computer establish a P2P connection 0, the service data can be transmitted between the mobile phone and the tablet computer based on the P2P connection 0. For example, the service between the mobile phone and the tablet computer can be super call transfer, and the call data can be transmitted between the mobile phone and the tablet computer through the P2P connection 0. For another example, the service between the mobile phone and the tablet computer can be memo synchronization, and the memo data can be transmitted between the mobile phone and the tablet computer through the P2P connection 0.

[0120] In some embodiments, the mobile phone and the tablet computer may establish a service session 0 based on the P2P connection 0, and the service session 0 is used to transmit service data between the mobile phone and the tablet computer.

[0121] S802. In response to the first event, the mobile phone performs P2P role negotiation with the notebook computer and obtains a role negotiation result.

[0122] Among them, the first event is used to trigger the mobile phone to negotiate the P2P roles with the laptop. From the above description, it can be seen that when the mobile phone receives the Internet service triggered by the user, the mobile phone may need to establish a P2P connection with other devices. When the mobile phone establishes a P2P connection with other devices, the mobile phone will initiate a P2P connection request to the other device and negotiate the P2P roles with the other device. Alternatively, when the mobile phone receives a P2P connection request initiated by other devices, the mobile phone will also negotiate the P2P roles with the other devices.

[0123] Therefore, in some embodiments, the first event may specifically be that the mobile phone initiates a P2P connection request to another device (laptop computer). Alternatively, in other embodiments, the first event may also be that the mobile phone receives a P2P connection request initiated by another device (laptop computer).

[0124] P2P role negotiation is a part of the process of establishing a P2P connection between two devices. The purpose of P2P role negotiation is to determine the roles that the two devices of the P2P connection to be established will correspond to in the P2P connection, such as GO role or GC role. The process of P2P role negotiation between a mobile phone and a laptop can be referred to Figure 2 The process shown.

[0125] After the mobile phone and the laptop computer perform P2P role negotiation, the obtained role negotiation result may include the P2P roles negotiated by the mobile phone and the laptop computer in the P2P connection to be established. For example, in the P2P connection to be established, the mobile phone serves as a GO role or a GC role, and the laptop computer serves as a GC role or a GO role.

[0126] In combination with the above description, it can be known that the two parties in the P2P connection are the GO role and the GC role respectively. Moreover, in some embodiments, the laptop can only serve as the GO role in the P2P connection. Therefore, in some embodiments, the role negotiation result obtained in the above S802 is that the mobile phone serves as the GC role and the laptop serves as the GO role.

[0127] S803. The mobile phone determines whether the role negotiation result conflicts with P2P connection 0.

[0128] In the role negotiation result, the mobile phone corresponds to a negotiated role in the P2P connection to be established, and the mobile phone also has a role in P2P connection 0. From the description of the above embodiment, it can be seen that in a P2P connection group, the GO role can be connected to multiple GC roles, while the GC role can only be connected to one GO role. In addition, the role of the device in the same P2P connection cannot be changed.

[0129] Therefore, if the mobile phone is a GC role in the above P2P connection 0, then the mobile phone can neither connect to the GO role nor to other GC roles. In other words, if the mobile phone is a GC role in P2P connection 0, the above role negotiation result will definitely conflict with P2P connection 0.

[0130] If the mobile phone is a GO role in the above P2P connection 0, and the mobile phone is a GC role in the role negotiation result (the P2P connection to be established), it also means that there is a conflict between the role negotiation result and the P2P connection 0.

[0131] If the mobile phone is a GO role in the above P2P connection 0, and the mobile phone is also a GO role in the role negotiation result (the P2P connection to be established), it means that there is no conflict between the role negotiation result and the P2P connection 0.

[0132] Based on the above description, it can be known that if the mobile phone is in the GC role in P2P connection 0, the above role negotiation result must conflict with P2P connection 0. If the mobile phone is in the GO role in P2P connection 0, it can be determined whether the role negotiation result conflicts with P2P connection 0 based on whether the role of the mobile phone in the role negotiation result is consistent with the GO role. Exemplarily, if the mobile phone is in the GO role in P2P connection 0, and the role of the mobile phone in the role negotiation result is also the GO role, it means that the role negotiation result does not conflict with P2P connection 0. If the mobile phone is in the GO role in P2P connection 0, and the role of the mobile phone in the role negotiation result is the GC role, it means that the role negotiation result conflicts with the P2P connection.

[0133] In combination with the above description, it can be known that in some embodiments, the laptop can only be used as the GO role in the P2P connection. That is, in the above role negotiation result, the laptop is the GO role. Then in the role negotiation result, the mobile phone is the GC role. Therefore, in this embodiment, no matter whether the mobile phone is the GO role or the GC role in P2P connection 0, the above role negotiation result conflicts with P2P connection 0.

[0134] Further, when the judgment result of S803 is yes, S804 may be executed.

[0135] S804. The mobile phone obtains the P2P connection capability of the mobile phone.

[0136] In some embodiments, the P2P connection capability can be used to characterize the number of P2P connection groups that the mobile phone supports to establish simultaneously. According to the P2P connection capability, it can be determined whether the mobile phone supports to establish two different connection groups simultaneously.

[0137] The electronic device may be provided with a preset chip, and the preset chip is used to support the electronic device to perform P2P connection. Specifically, a preset chip can support the electronic device to establish a P2P connection group. In some embodiments, the electronic device may be provided with multiple preset chips, and the electronic device supports the establishment of multiple P2P connection groups. In other words, the electronic device supports the establishment of multiple P2P connection groups at the same time. Further, in this embodiment, the number of P2P connection groups that the mobile phone supports to be established simultaneously can be determined according to the number of preset chips set in the mobile phone. For example, if the mobile phone is provided with 2 preset chips, the number of P2P connection groups that the mobile phone supports to be established simultaneously is 2.

[0138] In some embodiments, the mobile phone can determine and store the P2P connection capability of the mobile phone in advance according to the number of preset chips set in the mobile phone, that is, the number of P2P connection groups supported by the mobile phone. Exemplarily, after determining the number of P2P connection groups supported by the mobile phone, the mobile phone can set a preset storage area in the mobile phone to store the number of the P2P connection groups. In this way, the above S804 mobile phone can directly query the preset storage area to obtain the number of P2P connection groups that the mobile phone supports to establish simultaneously.

[0139] In other embodiments, the mobile phone P2P connection capability can also be used to indicate whether the mobile phone supports establishing more than two P2P connection groups at the same time. In this embodiment, in the above method, when it is determined that the role negotiation result between the mobile phone and the laptop conflicts with P2P connection 0, the mobile phone can obtain the P2P connection capability to determine whether the mobile phone supports establishing more than two P2P connection groups at the same time.

[0140] In some embodiments, the mobile phone may first determine whether the mobile phone supports the establishment of more than two P2P connection groups at the same time according to the number of preset chips set in the mobile phone. Then the mobile phone may set an identification bit to store the P2P connection capability. Exemplarily, in the case where the mobile phone supports the establishment of more than two P2P connection groups at the same time, the above identification bit may be set to 1 or true. In the case where the mobile phone does not support the establishment of more than two P2P connection groups at the same time, the above identification bit may be set to 0 or false, etc. In this way, the mobile phone in the above S804 can obtain the P2P connection capability of the mobile phone by querying the identification bit, that is, whether the mobile phone supports the establishment of more than two P2P connection groups at the same time. Exemplarily, if the mobile phone queries the identification bit and obtains 1 or true, it means that the mobile phone supports the establishment of more than two P2P connection groups at the same time; on the contrary, if the mobile phone queries the identification bit and obtains 0 or false, it means that the mobile phone does not support the establishment of more than two P2P connection groups at the same time.

[0141] S805. Determine, based on the P2P connection capability, whether the mobile phone supports establishing more than two P2P connection groups at the same time.

[0142] In some embodiments, the P2P connection capability of the mobile phone is used to indicate the number of P2P connection groups that the mobile phone supports to be established simultaneously. In this embodiment, the above S805 may specifically include: determining whether the number of P2P connection groups that the mobile phone supports to be established simultaneously is greater than or equal to 2. Exemplarily, if the number of P2P connection groups that the mobile phone supports to be established simultaneously is greater than or equal to 2, it indicates that the mobile phone supports to establish more than two P2P connection groups simultaneously.

[0143] In other embodiments, the P2P connection capability of the mobile phone is used to indicate whether the mobile phone supports establishing more than two P2P connection groups at the same time. In this embodiment, after obtaining the P2P connection capability of the mobile phone, it can be directly determined whether the mobile phone supports establishing more than two P2P connection groups at the same time.

[0144] If the result of S805 is yes, that is, the mobile phone supports more than two P2P connection groups at the same time, S806 can be executed.

[0145] S806. The mobile phone establishes P2P connection 1 with the notebook computer, and P2P connection 1 and P2P connection 0 belong to different P2P connection groups.

[0146] Since the mobile phone supports establishing more than two P2P connection groups at the same time, when the role negotiation result between the mobile phone and the laptop conflicts with P2P connection 0, the mobile phone can still establish a P2P connection with the laptop, that is, P2P connection 1. It can be understood that the P2P connection 1 and the above-mentioned P2P connection 0 belong to two different P2P connection groups. In other words, when the mobile phone establishes P2P connection 1 with the laptop, the preset chip used is different from the preset chip used for P2P connection 0. For example, the mobile phone includes preset chip 0 and preset chip 1. In the above S801, the mobile phone uses preset chip 0 to establish P2P connection 0 with the tablet computer. At the same time, in the above S806, the mobile phone uses preset chip 1 to establish P2P connection 1 with the laptop.

[0147] In some embodiments, the above S806 may specifically include: the mobile phone establishes a P2P connection 1 with the laptop computer according to the role negotiation result. In some embodiments, in the above role negotiation result, the laptop computer is a GO role, and the mobile phone is a GC role. In this embodiment, the GO role in the above P2P connection 1 is the laptop computer, and the GC role is the mobile phone.

[0148] The specific process of establishing a P2P connection between a mobile phone and a laptop can be found in Figure 2 The process shown.

[0149] like Fig. 9As shown, a P2P connection 0 is established between mobile phone 1 and tablet computer 2, mobile phone 1 is the GO role in P2P connection 0, and tablet computer 2 is the GC role in P2P connection 0. In response to the first event, mobile phone 1 negotiates roles with laptop computer 3. The role negotiation result conflicts with P2P connection 0, and mobile phone 1 supports the establishment of two P2P connection groups at the same time. At this time, mobile phone 1 can establish P2P connection 1 with laptop computer 3. In addition, in this P2P connection 1, mobile phone 1 is the GC role, and laptop computer 3 is the GO role.

[0150] In the technical solution provided in the embodiment of the present application, when the mobile phone supports establishing more than two P2P connection groups at the same time, even if the role negotiation result between the mobile phone and the third device (such as the above-mentioned laptop) conflicts with the P2P connection (such as P2P connection 0) already established by the mobile phone, the mobile phone can still establish a P2P connection with the laptop. That is, the mobile phone establishes two different P2P connection groups at the same time, and establishes P2P connections with the tablet computer and the laptop in the two different P2P connection groups respectively. In this way, no conflict will occur, and the problem of connection failure caused by P2P connection conflict in the mobile phone can be reduced.

[0151] In other embodiments, if the judgment result of S803 is no, it means that there is no conflict between the role negotiation result and P2P connection 0. At this time, the first device (mobile phone) and the third device (laptop computer) can directly establish a P2P connection. Figure 8 S807 shown. The specific process of establishing the P2P connection can refer to the above description.

[0152] S807. The mobile phone establishes P2P connection 2 with the notebook computer, and P2P connection 2 and P2P connection 0 belong to the same P2P connection group.

[0153] In this embodiment, the role negotiation result does not conflict with P2P connection 0, so the P2P connection established between the mobile phone and the notebook computer can belong to the same P2P connection group as P2P connection 0. That is, P2P connection 2 and P2P connection 0 belong to the same P2P connection group.

[0154] In some embodiments, the mobile phone includes a preset chip 0, which is used to support the mobile phone to establish a P2P connection group. In the above S801, the mobile phone uses the preset chip 0 to establish a P2P connection 0 with the tablet computer, and, in the above S806, the mobile phone uses the preset chip 0 to establish a P2P connection 2 with the laptop computer.

[0155] In the technical solution provided in the embodiment of the present application, if there is no conflict between the role negotiation result and the P2P connection 0, the mobile phone can directly establish a P2P connection with the laptop computer.

[0156] If the judgment result of the above S805 is no, it means that the mobile phone does not support the establishment of more than two P2P connection groups at the same time. In some embodiments, when the judgment result of S805 is no, the mobile phone may not establish a P2P connection with the laptop. In other words, the service between the mobile phone and the laptop will not be realized due to the failure to establish the P2P connection. At this time, the mobile phone or the laptop can send a first prompt message to prompt the user that the service connection establishment fails.

[0157] For example, if the user triggers the interconnection service on the mobile phone, that is, the first event is that the mobile phone sends a P2P connection request to the laptop according to the service triggering operation. Then, if the judgment result of the mobile phone in S805 is no, the mobile phone can send the first prompt information. That is, the user is prompted on the mobile phone that the interconnection service connection fails.

[0158] In other embodiments, the user triggers the interconnection service on a laptop computer, that is, the first event is that the mobile phone receives a P2P connection request initiated by the laptop computer. In this embodiment, if the mobile phone determines that the result of S805 is no, the mobile phone can notify the laptop computer of a feedback message that the P2P connection establishment fails. Then the laptop computer sends the first prompt information. That is, the laptop computer prompts the user that the interconnection service establishment fails.

[0159] In other embodiments, if the determination result of S805 is no, the mobile phone may also send a connection confirmation message to the user, and the user may decide which Internet service to use first. Figure 8 S808-S810 shown.

[0160] S808. The mobile phone generates and sends a connection confirmation message.

[0161] In some embodiments, the connection confirmation information is used to trigger the user to confirm whether to allow the connection corresponding to the P2P connection request to preempt the P2P connection 0.

[0162] In some embodiments, the connection confirmation information may include a first option and a second option. The first option may be used to indicate that the connection corresponding to the P2P connection request is allowed to occupy P2P connection 0. The second option may be used to indicate that the connection corresponding to the P2P connection request is not allowed to occupy P2P connection 0.

[0163] S809. After receiving the first operation based on the connection confirmation information, the mobile phone disconnects the P2P connection 0 with the tablet computer.

[0164] The first operation is used to indicate that the connection corresponding to the P2P connection request is allowed to preempt the P2P connection 0. In some embodiments where the connection confirmation information includes the first option and the second option, the first operation may correspond to a triggering operation of the user on the first option.

[0165] The specific implementation process of disconnecting the P2P connection between the mobile phone and the tablet computer can refer to the description in the relevant technology and will not be described in detail in the embodiments of the present application.

[0166] S810. The mobile phone and the notebook computer establish a P2P connection 3.

[0167] It can be understood that in S810, the mobile phone and the laptop establish P2P connection 3, specifically according to the role negotiation result obtained in S802. That is, in S810, the mobile phone acts as the GC role and the laptop acts as the GO role to establish P2P connection 3.

[0168] In other embodiments, after S808, if the mobile phone receives a second operation based on the connection confirmation information, the mobile phone will not establish a P2P connection with the notebook computer. The second operation is used to indicate that the connection corresponding to the P2P connection request is not allowed to preempt P2P connection 0.

[0169] In some embodiments where the connection confirmation information includes the first option and the second option, the second operation may correspond to a triggering operation of the user on the second option.

[0170] In the technical solution provided by the embodiment of the present application, when the role negotiation result conflicts with P2P connection 0, and the mobile phone does not support the establishment of more than two P2P connection groups at the same time, the user can decide whether to seize the current existing P2P connection. If the user chooses to seize the current P2P connection, the mobile phone will first disconnect P2P connection 0 with the tablet computer, and then establish P2P connection 3 with the laptop computer. If the user chooses not to seize the current existing P2P connection, the mobile phone will not establish a P2P connection with the laptop computer. In this way, the P2P connection is more in line with the user's needs. In addition, when the P2P connection to be established conflicts with the existing P2P connection, the user can be guided to resolve the conflict.

[0171] In other embodiments, the mobile phone may pre-set and store priority information, which is used to represent the priority of each interconnected service. The mobile phone may determine whether to allow a new P2P connection to preempt the current P2P connection based on the priority information.

[0172] by Figure 4For example, a P2P connection 0 is established between mobile phone 1 and tablet computer 2, and a memo synchronization service is performed through the P2P connection 0. Mobile phone 1 initiates a P2P connection request to laptop computer 3 to request the establishment of a super call transfer service. At this time, mobile phone 1 can query the priority information to determine whether the priority of the super call transfer service is higher than the priority of the memo synchronization service. If so, the mobile phone allows the P2P connection request corresponding to the super call transfer service to preempt the existing P2P connection (memo synchronization service). That is, in some embodiments, when the mobile phone determines that the priority of the super call transfer service is higher than the priority of the memo synchronization service based on the priority information, the mobile phone will give priority to the super call transfer service. Exemplarily, the mobile phone can disconnect P2P connection 0, and then the mobile phone establishes a P2P connection (such as P2P connection 3) with the laptop computer to give priority to the super call transfer service.

[0173] In the technical solution provided by the embodiment of the present application, when the role negotiation result conflicts with P2P connection 0, and the mobile phone does not support the establishment of two P2P connection groups at the same time, the mobile phone can determine whether to allow a new P2P connection request to preempt the current P2P connection based on the priority of the service. In this way, when a P2P connection conflict occurs, it can be ensured that the service with a higher priority will have priority in establishing a connection and transmitting service data.

[0174] Furthermore, after the mobile phone disconnects the P2P connection 0 according to the user's operation on the connection confirmation information or according to the priority information, the P2P connection is established with the laptop computer, which will cause the service between the mobile phone and the tablet computer implemented through the P2P connection 0 to be interrupted. In some embodiments, in order to reduce the impact of disconnecting the P2P connection 0 on the service between the mobile phone and the tablet computer, the above method can also restore the service implemented through the P2P connection 0 through the P2P connection between the mobile phone and the laptop computer.

[0175] In some embodiments, please refer to Fig.10 , the above-mentioned P2P connection between the mobile phone and the laptop computer, restoring the service implemented through the P2P connection 0 may specifically include the following steps:

[0176] S901. The mobile phone sends instruction information 1 to the tablet computer.

[0177] The indication information 1 is used to instruct the tablet computer to establish a P2P connection with the laptop computer. In some embodiments, the indication information 1 includes connection information of the laptop computer. After receiving the indication information 1, the tablet computer can establish a P2P connection with the laptop computer according to the connection information of the laptop computer in the indication information 1. In some embodiments, the indication information 1 can be recorded as the second indication information.

[0178] S902. The tablet computer establishes a P2P connection 4 with the notebook computer according to the instruction information 1.

[0179] In some embodiments, the P2P connection 4 may be recorded as the fifth P2P connection.

[0180] S903. The tablet computer sends a response message 1 to the mobile phone.

[0181] In some embodiments, after the tablet computer attempts to establish a P2P connection with the laptop computer based on the instruction information 1 and successfully establishes the P2P connection, it may send a response message to the mobile phone. The response message is used to instruct the tablet computer to establish a P2P connection with the laptop computer.

[0182] The tablet computer attempts to establish a P2P connection with the notebook computer based on the indication information 1, but may not be able to successfully establish the P2P connection. In some embodiments, in this case, the tablet computer may return a response message to the notebook computer, and the response message is used to indicate that the tablet computer has failed to establish a P2P connection with the notebook computer. Alternatively, in other embodiments, if the tablet computer fails to successfully establish a P2P connection with the tablet computer, the tablet computer may not return a response message to the mobile phone.

[0183] S904. The mobile phone receives a response message 1 returned by the tablet computer.

[0184] In some embodiments, the response message 1 may indicate that the tablet computer has established a P2P connection with the laptop computer. In other embodiments, the response message 1 may also indicate that the tablet computer has not established a P2P connection with the laptop computer. In some embodiments, the response message 1 may be recorded as a second response message.

[0185] S905. When the response message 1 indicates that the tablet computer has established a P2P connection 4 with the notebook computer, the mobile phone restores the service session between the mobile phone and the tablet computer through the P2P connection 3 and the P2P connection 4.

[0186] P2P connection 4 represents a P2P connection established between the tablet computer and the notebook computer, ie, the fifth P2P connection. P2P connection 3 is a P2P connection established between the mobile phone and the notebook computer after disconnecting P2P connection 0 in the above embodiment.

[0187] When the response message 1 indicates that the tablet computer and the laptop computer have established a P2P connection 4, a P2P connection 3 is established between the mobile phone and the laptop computer, and a P2P connection 4 is established between the tablet computer and the laptop computer. At this time, if communication between the mobile phone and the tablet computer is required, the laptop computer can be used as an intermediate forwarding device to achieve communication.

[0188] In some embodiments, the communication between the mobile phone and the tablet computer may include the mobile phone sending data to the tablet computer, and the tablet computer sending data to the mobile phone. Exemplarily, when the mobile phone sends first data to the tablet computer, the mobile phone may send the first data to the laptop computer through P2P connection 3, and then the laptop computer forwards the first data to the tablet computer through P2P connection 4. When the tablet computer sends second data to the mobile phone, the tablet computer may send the second data to the laptop computer through P2P connection 4, and then the laptop computer forwards the second data to the mobile phone through P2P connection 3. Thus, the communication between the mobile phone and the tablet computer is realized through P2P connection 3 and P2P connection 4.

[0189] Fig.11 A schematic diagram is shown of restoring a service session between a mobile phone and a tablet computer through P2P connection 3 and P2P connection 4. In some embodiments, the mobile phone implements communication between the mobile phone and the tablet computer through P2P connection 3 and P2P connection 4, which can be referred to as establishing a virtual bridge channel between the mobile phone and the tablet computer, and implementing communication between the mobile phone and the tablet computer through the virtual bridge channel.

[0190] When the mobile phone sends data to the laptop computer through the P2P connection 3, the data may carry the IP address of the recipient of the data. Exemplarily, when the mobile phone forwards the first data to the tablet computer through the laptop computer, the first data may carry the Internet Protocol Address (IP address) of the tablet computer. In this way, when the laptop computer receives the first data, it may determine the recipient of the first data according to the IP address carried in the first data. Thus, the laptop computer may forward the first data to the tablet computer through the P2P connection 4.

[0191] When the mobile phone sends data to the notebook computer via the P2P connection 3, the IP address of the notebook computer can be carried in the data. In this way, when the notebook computer receives the data, it can determine that the recipient of the data is itself according to the IP address therein.

[0192] Similarly, when a tablet needs to forward data to a mobile phone through a laptop, the mobile phone's IP address can also be carried in the data.

[0193] In the technical solution provided in the embodiment of the present application, when data is transmitted via a P2P connection, the IP address of the data receiver is carried in the data, so that the notebook computer can distinguish the data receiver and reduce the possibility of data transmission errors.

[0194] In the above method, if the mobile phone supports establishing more than two P2P connections at the same time, then when the role negotiation result conflicts with P2P connection 0, the mobile phone can establish a P2P connection with the laptop computer as a new P2P connection group of the mobile phone. Fig. 9 As shown in the figure, the mobile phone has established P2P connection 0 and P2P connection 1 at the same time. In this way, the mobile phone has two P2P connection groups at the same time, and the link overhead of the mobile phone is large, which easily leads to high power consumption of the mobile phone and reduces the performance of the mobile phone. In order to avoid problems such as high power consumption and low performance of the mobile phone due to link overhead, you can try to switch the service session (session) established between the mobile phone and the tablet computer through P2P connection 0 to that through P2P connection 1.

[0195] In some embodiments, the session established between the mobile phone and the tablet computer through P2P connection 0 can be recorded as the second service session. After the above S806, the above method further includes: the mobile phone switches from supporting the second service session through P2P connection 0 to supporting the second service session through the laptop computer and P2P connection 1.

[0196] Please refer to Fig.12 The mobile phone switches from supporting the second service session through P2P connection 0 to supporting the second service session through the laptop computer and P2P connection 1, which may specifically include the following steps.

[0197] S1001. The mobile phone sends instruction information 2 to the tablet computer.

[0198] The indication information 2 is used to instruct the tablet computer to establish a P2P connection with the laptop computer. In some embodiments, the indication information 2 includes connection information of the laptop computer. After receiving the indication information 2, the tablet computer can establish a P2P connection with the laptop computer according to the connection information of the laptop computer in the indication information 2. In some embodiments, the indication information 2 can be recorded as the first indication information.

[0199] S1002. The tablet computer establishes a P2P connection 5 with the notebook computer according to the instruction information 2.

[0200] S1003. The tablet computer sends a response message 2 to the mobile phone.

[0201] S1004. The mobile phone receives a response message 2 returned by the tablet computer.

[0202] In some embodiments, the response message 2 may indicate that the tablet computer has established a P2P connection with the laptop computer. In other embodiments, the response message 2 may also indicate that the tablet computer has not established a P2P connection with the laptop computer. In some embodiments, the response message 2 may be recorded as a first response message.

[0203] S1005. When the response message 2 indicates that the tablet computer has established a P2P connection 5 with the laptop computer, the mobile phone switches from transmitting the session data of the second service session through P2P connection 0 to transmitting the session data of the second service session through P2P connection 1 and P2P connection 5.

[0204] In some embodiments, the mobile phone can establish a virtual bridge channel between the mobile phone and the tablet computer through P2P connection 1 and P2P connection 5, and realize communication between the mobile phone and the tablet computer through the virtual bridge channel.

[0205] In some embodiments, the mobile phone switches from transmitting session data of the second service session through P2P connection 0 to transmitting session data of the second service session through P2P connection 1 and P2P connection 5, which may specifically include: the mobile phone maps the session ID of the second service session to a virtual bridge channel established by P2P connection 1 and P2P connection 5.

[0206] S1006. The mobile phone disconnects the P2P connection 0 with the tablet computer.

[0207] Since in S1003, the mobile phone has switched the second service session to transmit session data through P2P connection 1 and P2P connection 5, the P2P connection 0 between the mobile phone and the tablet computer no longer needs to transmit session data. Therefore, the mobile phone can disconnect the P2P connection 0 between the mobile phone and the tablet computer. In this way, the link overhead of the mobile phone can be reduced, thereby reducing the power consumption of the mobile phone and improving the performance of the mobile phone.

[0208] Because the mobile phone has switched the second service session from P2P connection 0 to the bridge channel established by P2P connection 1 and P2P connection 5 before disconnecting P2P connection 0, the second service session will not be interrupted for the user. That is, the channel switching of the second service session is achieved without the user's awareness.

[0209] In the technical solution provided in the embodiment of the present application, when the mobile phone has established two P2P connection groups at the same time, an attempt is made to switch the service session of the P2P connection in one of the P2P connection groups to the P2P connection of the other P2P connection group. Since the role in P2P connection 1 conflicts with P2P connection 0, in the embodiment of the present application, an attempt is made to switch the service session on P2P connection 0 to P2P connection 1 and P2P connection 5. If the switch is successful, the mobile phone can disconnect P2P connection 0 and only retain the connection in one P2P connection group, namely P2P connection 1. And it is possible to simultaneously realize the communication between the mobile phone and the laptop computer, and the communication between the mobile phone and the tablet computer. In this way, the link overhead of the mobile phone can be reduced, the power consumption of the mobile phone can be reduced, and the performance of the mobile phone can be improved. And it is possible to switch the P2P connection channel without the user's perception, reducing the impact on the user and the second service session.

[0210] Next, we will explain the connection method between the above devices from the overall process. Fig.13 ,exist Figure 1 In the process shown, if the role negotiation result conflicts with the P2P connection 0 established by the first device (such as a mobile phone), the result is no longer returned directly to the service module, but it is determined whether the mobile phone supports establishing more than two P2P connection groups at the same time.

[0211] If the mobile phone does not support establishing more than two P2P connection groups at the same time, the mobile phone will first query the service corresponding to the current existing P2P connection 0. Then, the mobile phone will send a pop-up window to prompt the user to confirm whether to disconnect the current existing service. If the user chooses not to disconnect the existing service, the mobile phone will not establish a connection with the laptop. If the user chooses to disconnect the existing service, the mobile phone will disconnect P2P connection 0 and establish a P2P connection with the laptop.

[0212] If the mobile phone supports establishing more than two P2P connection groups at the same time, the mobile phone can establish P2P connection 1 with the laptop in the new P2P connection group. Then, in order to avoid the problem of large link overhead and high power consumption of the mobile phone due to the existence of two P2P connection groups at the same time, the mobile phone tries to switch the service corresponding to P2P connection 0 to P2P connection 1 with the laptop.

[0213] The mobile phone attempts to switch the service corresponding to P2P connection 0 to P2P connection 1 with the laptop computer, which may specifically include the following steps: the mobile phone and the tablet computer establish a virtual bridge channel through the laptop computer. The specific implementation process of the mobile phone and the tablet computer establishing a virtual bridge channel through the laptop computer can refer to the description above. Then the mobile phone switches the service session corresponding to P2P connection 0 to P2P connection 1 between the mobile phone and the laptop computer. Afterwards, the mobile phone can disconnect P2P connection 0.

[0214] Finally, the connection module returns the connection result to the business module, and the business module can issue a prompt message based on the connection result.

[0215] Fig.13 The detailed implementation process of the steps in the shown flow can refer to the description in the previous embodiments.

[0216] Fig.14 The module interaction process between device A (such as the mobile phone mentioned above), device B (such as the tablet computer mentioned above) and device C (such as the laptop computer mentioned above) in the process of the method for connecting devices in the embodiment of the present application is shown. Device A includes a connection module, a short-range module (i.e., the communication module mentioned above), a service A module and a service B module. Device B includes a connection module, a short-range module and a service A module. Device C includes a connection module, a short-range module and a service B module. Among them, the connection module can be the first connection module or the second connection module in the above embodiment.

[0217] S1101. The device goes online, and device A exchanges device information with device B.

[0218] The device online may include device A online and device B online.

[0219] S1102. The device goes online, and device A and device C exchange device information.

[0220] The device online may include device A online and device C online.

[0221] S1103. Device A establishes P2P connection 0 with device B, establishes a service session through P2P connection 0, and sets service A to be reconnectable.

[0222] It can be understood that the service session established between device A and device B through P2P connection 0 is a session of service A. The session of service A is the second service session in the above embodiment.

[0223] S1104. Call the session creation interface to establish a P2P connection with device C.

[0224] The session creation interface may be named as OpenSession interface, which is used to trigger the establishment of a P2P connection and a service session. In this embodiment, the OpenSession interface is called by the service B module to trigger the establishment of a P2P connection with device C.

[0225] It can be understood that in this embodiment, the user triggers service B on device A, thereby triggering device A to establish a connection with device C. In other embodiments, the user can also trigger service B between device C and device A. At this time, the service B module of device C will trigger the connection module and short-range module of device C to negotiate the P2P role with device A and establish a P2P connection. That is, the above S1104 can also be replaced by the short-range module of device A receiving the P2P connection request sent by the short-range module of device C.

[0226] S1105 . Verify that the role negotiation result between device A and device C conflicts with P2P connection 0 .

[0227] It can be understood that P2P connection 0 is the P2P connection established by the current service, that is, the P2P connection established by service A. The specific implementation process of S1105 can refer to the description of the above embodiment.

[0228] S1106. The connection module queries the short-range module whether device A supports dual-path P2P.

[0229] Whether device A supports dual-path P2P, that is, whether device A supports establishing more than two P2P connection groups at the same time.

[0230] S1107. The short-range module returns the query result to the connection module.

[0231] The query result may include two situations, the first is that device A supports dual-path P2P, and the second is that device A does not support dual-path P2P. Exemplarily, the short-distance module may return true or false to the connection module. True indicates that device A supports dual-path P2P; false indicates that device A does not support dual-path P2P.

[0232] Next, the case where device A supports dual-path P2P is described, including S1108-S1126.

[0233] S1108. A pop-up window is displayed in the service B module to prompt the user whether to disconnect the P2P connection of the current service.

[0234] In the embodiment of the present application, the current business is the above-mentioned business A.

[0235] S1109. The user decides to seize the P2P connection of the current service, calls the session creation interface again, and inputs the seizure flag.

[0236] Understandably, if the user decides to seize the P2P connection of the current service, it means that the user chooses to disconnect the P2P connection of the existing service in the pop-up window.

[0237] S1110 . The connection module of device A notifies the short-range module of device A to disconnect P2P connection 0 .

[0238] S1111. The short-range module of device A notifies the short-range module of device B to disconnect P2P connection 0.

[0239] S1112 . The short-range module of device B notifies the connection module of device B to disconnect P2P connection 0 .

[0240] S1113. Device B notifies through service A module that P2P connection 0 is preempted and disconnected.

[0241] S1114. The connection module of device A returns a preemption disconnection failure to the service A module of device A.

[0242] At this point, the P2P connection 0 between device A and device B has been successfully disconnected. Afterwards, device A can establish a P2P connection with device C.

[0243] S1115. The connection module of device A notifies the short-range module of device A to establish a P2P connection 1 with device C.

[0244] S1116. The short-range module of device A establishes a P2P connection 2 with device C.

[0245] S1117. After P2P connection 2 is successfully established, the short-range module of device C returns the connection result to the connection module of device C.

[0246] S1118. The connection module of device C calls back the session creation callback function to notify the service B module that the P2P connection 2 has been established.

[0247] The session creation callback function may be named OnSeassionOpened; it is a callback function that may be used to notify the business module that a P2P connection has been successfully established, that is, P2P connection 2.

[0248] At the same time as S1118 , device A may also notify service B module that P2P connection 2 is successfully established.

[0249] S1119. The short-range module of device A returns the connection result to the connection module of device A.

[0250] S1120. The connection module of device A calls back the session creation callback function to notify the service B module that the P2P connection 2 has been established.

[0251] S1121. The connection module of device A sends a message to the short-range module of device A to trigger reconnection with device B.

[0252] S1122. The short-range module of device A reestablishes a connection with device B.

[0253] It should be noted that device A and device B re-establish a connection. For details, please refer to Fig.10 The connection reestablished between device A and device B is a virtual bridge channel established between device A and device B through device C. Based on the virtual bridge channel, device A and device B can restore service A.

[0254] S1123. The short-distance module of device B returns a successful connection to the connection module of device B.

[0255] S1124. The connection module of device B notifies the service A module of device B, prompting that service A has been restored.

[0256] S1125. The short-distance module of device A returns a successful connection to the connection module of device A.

[0257] S1126. The connection module of device A notifies the service A module of device A, prompting that service A has been restored.

[0258] Fig.14 For the specific implementation process of each step in the shown process, reference may be made to the description in the above embodiment.

[0259] Next, combine Fig.15 The case where device A supports dual-path P2P is described. Fig.15 S1101-S1107 and Fig.14 After the query result in S1107 determines that device A supports dual-path P2P, the following steps may be included:

[0260] S1201. The connection module of device A calls the connection interface to the short-distance module of device A, and the connection name is passed to P2P1.

[0261] The connection interface may also be named as the connect interface, and the connection name may be recorded as linkname. P2P1 represents the second P2P of device A, and the P2P used by device A to establish P2P connection 0 with device B is P2P0. In some embodiments, P2P0 and P2P1 are respectively the preset chip 0 and the preset chip 1 in the above embodiments.

[0262] When the connection module calls the connection interface, the connection name is passed to P2P1, indicating that the short-distance module is specified to establish a new P2P connection through P2P1.

[0263] S1202. The short-distance module of device A uses the second P2P path to establish P2P connection 1.

[0264] It can be understood that P2P connection 1 and P2P connection 0 belong to different P2P connection groups.

[0265] S1203. The short-distance module of device C returns the connection result to the connection module of device C.

[0266] S1204. The connection module of device C calls back the session creation callback function to notify the service B module that the P2P connection 1 has been established.

[0267] S1205. The short-range module of device A returns a connection result to the connection module of device A.

[0268] S1206. The connection module of device A calls back the session creation callback function to notify the service B module that the P2P connection 1 has been established.

[0269] At this point, device A and device C have established P2P connection 1 based on the second P2P of device A. At this point, device A has two P2P links, P2P connection 0 and P2P connection 1, at the same time, and the link overhead is large. In order to reduce the link overhead of device A, you can perform the following steps to try to switch the service session of P2P connection 0 to P2P connection 1.

[0270] S1207. The connection module of device A sends instruction information to the connection module of device B, and the configuration information is passed into the GO information of device C.

[0271] The indication information includes configuration information. The indication information is used to instruct device B to establish a P2P connection with device C.

[0272] S1208. The connection module of device B calls the connection interface of the short-distance module of device B, and the connection name is passed to P2P1.

[0273] S1209. The connection module of device B returns a connection response message to the connection module of device A.

[0274] At the same time, device B also needs to establish a P2P connection with device C based on the indication information.

[0275] S1210. The short-range module of device B communicates with the short-range module of device C to establish a P2P connection.

[0276] After device B establishes a P2P connection with device C, device A can transmit session data of service A by means of P2P connection 1 between device A and device C and the P2P connection between device B and device C.

[0277] S1211. The connection module of device A maps the session identifier of service A to P2P1.

[0278] The session identifier can be named sessionID, which is used to uniquely identify the service session. The above S1210 means that the connection module of device A maps the service session of service A from P2P0 to P2P1. After S1210, device A can send the session data of service A to device C through P2P connection 1, and device C forwards the session data of service A to device B. Similarly, device B can also forward the session data of service A to device A through device C.

[0279] In this way, service A between device A and device B will forward data through device C.

[0280] S1212. The connection module of device A notifies the short-distance module of device A to disconnect P2P connection 0.

[0281] S1213. The short-range module of device A interacts with the short-range module of device B and disconnects P2P connection 0.

[0282] In this way, device A only retains one P2P connection group while retaining both service A and service B. This can reduce the link overhead of device A, reduce the power consumption of device A, and improve the performance of device A.

[0283] Above Fig.15 For the specific implementation process of each step in the illustrated process, reference may be made to the description in the previous embodiments.

[0284] Some other embodiments of the present application provide an electronic device (such as a mobile phone). The computer may include: a memory and one or more processors. The memory is coupled to the processor. The memory is also used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the computer can execute the various functions or steps performed by the mobile phone in the above method embodiment. When the computer is an electronic device, its structure can refer to Figure 6 The structure of the electronic device 100 is shown.

[0285] The present application also provides a chip system, such as Fig.16As shown, the chip system 160 includes at least one processor 1601 and at least one interface circuit 1602. The processor 1601 and the interface circuit 1602 can be interconnected via lines. For example, the interface circuit 1602 can be used to receive signals from other devices (such as a computer memory). For another example, the interface circuit 1602 can be used to send signals to other devices (such as processor 1601). Exemplarily, the interface circuit 1602 can read instructions stored in the memory and send the instructions to the processor 1601. When the instruction is executed by the processor 1601, the computer can execute the various steps in the above embodiments. Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiments of the present application.

[0286] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device (such as a mobile phone), the electronic device executes each function or step executed by the mobile phone in the above-mentioned method embodiment.

[0287] The present application also provides a computer program product, which, when executed on a computer, enables the computer to execute the functions or steps executed by the mobile phone in the above method embodiment. The computer may be an electronic device, such as a mobile phone.

[0288] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0289] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0290] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0291] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0292] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0293] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A method for connecting devices, characterized in that: The method is applied to a first device, the first device supports establishing a point-to-point (P2P) connection with other devices; the method includes: In the case where the first device establishes a first P2P connection with the second device, the first device receives a first event; the first event includes: the first device receives a P2P connection request from a third device, or the first device sends a P2P connection request to the third device; in the first event, the third device is a group manager GO role; In response to the first event, the first device disconnects the first P2P connection with the second device; The first device establishes a fourth P2P connection with the third device; The first device restores the service session between the first device and the second device through the third device and the fourth P2P connection; After the service session between the first device and the second device is restored, the first device is in the role of a GC client in the group, and the second device is in the role of a GC.

2. The method according to claim 1, characterized in that: Before disconnecting the first P2P connection with the second device, the method further includes: In response to the first event, the first device acquires the number of P2P connection groups that the first device supports to be established simultaneously; The disconnecting the first P2P connection with the second device includes: if the number of P2P connection groups that the first device supports to be established simultaneously is less than 2, disconnecting the first P2P connection with the second device by the first device.

3. The method according to claim 2, characterized in that The method further comprises: If the number of P2P connection groups that the first device supports to be established simultaneously is greater than or equal to 2, the first device establishes a second P2P connection with the third device, and the first P2P connection and the second P2P connection do not belong to the same P2P connection group; The first device establishes a first service session with the third device through the second P2P connection.

4. The method according to claim 3, characterized in that After the first device establishes a first P2P connection with the second device, the first device and the second device establish a second service session based on the first P2P connection; After the first device establishes a second P2P connection with the third device, the method further includes: The first device switches from supporting the second service session through the first P2P connection to supporting the second service session through the third device and the second P2P connection.

5. The method according to claim 4, characterized in that The first device supports the second service session through the first P2P connection, and switches to supporting the second service session through the third device and the second P2P connection, including: The first device sends first indication information to the second device; the first indication information is used for the second device to establish a P2P connection with the third device; The first device receives a first response message returned by the second device; the first response message is used to indicate whether the second device has established a P2P connection with the third device; When the first response message indicates that the second device has established a third P2P connection with the third device, the first device switches from transmitting session data of the second service session through the first P2P connection to transmitting session data of the second service session through the second P2P connection and the third P2P connection; The first device disconnects the first P2P connection with the second device.

6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: The first device is a GO role in the first P2P connection, and the second device is a GC role in the first P2P connection; or, The first device plays a GC role in the first P2P connection, and the second device plays a GO role in the first P2P connection.

7. The method according to any one of claims 1 to 6, characterized in that Before disconnecting the first P2P connection with the second device, the method further includes: The first device displays connection confirmation information; the connection confirmation information is used to confirm whether the connection corresponding to the P2P connection request is allowed to preempt the first P2P connection; The disconnecting the first P2P connection with the second device includes: After the first device receives a first operation based on the connection confirmation information, the first device disconnects the first P2P connection with the second device; the first operation is used to indicate that a connection corresponding to the P2P connection request is allowed to preempt the first P2P connection.

8. The method according to any one of claims 1 to 6, characterized in that The first device stores priority information, where the priority information includes the priority of each service; before disconnecting the first P2P connection with the second device, the method further includes: comparing the priority of a first service corresponding to the P2P connection request of the first device with the priority of a second service corresponding to the first P2P connection; The disconnecting the first P2P connection with the second device includes: If the priority of the first service is greater than the priority of the second service, the first device disconnects the first P2P connection.

9. The method according to any one of claims 1 to 8, characterized in that The first device recovers the service session between the first device and the second device through the third device and the fourth P2P connection, including: The first device sends second indication information to the second device; the second indication information is used for the second device to establish a P2P connection with the third device; The first device receives a second response message returned by the second device; the second response message is used to indicate whether the second device has established a P2P connection with the third device; When the second response message indicates that the second device has established a fifth P2P connection with the third device, the first device resumes the service session with the second device through the second P2P connection and the fifth P2P connection.

10. The method according to any one of claims 2 to 9, characterized in that: The first device is provided with a preset chip, and a preset chip supports the first device to establish a P2P connection group; the method further includes: The first device queries the number of preset chips set by the first device; The first device determines, according to the number of the preset chips, the number of P2P connection groups that the first device supports to be established simultaneously.

11. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; the memory is coupled to the processor; a computer program code is stored in the memory, and the computer program code comprises computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1-10.

12. A computer-readable storage medium, characterized in that: The method comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method as claimed in any one of claims 1 to 10.