Device connection method

By generating random UUIDs for slave devices instead of fixed UUIDs, the master device can accurately identify and connect to each slave device, solving the problem of misconnection caused by a single UUID in master-slave device connections and improving the accuracy and efficiency of the connection.

WO2026158171A1PCT designated stage Publication Date: 2026-07-30LENOVO (BEIJING) LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
LENOVO (BEIJING) LTD
Filing Date
2026-01-16
Publication Date
2026-07-30

AI Technical Summary

Technical Problem

In short-distance connections between master and slave devices, a single service UUID can cause the master device to fail to accurately identify the slave device, which can easily lead to misconnection issues.

Method used

The master device pre-generates a random UUID for the slave device to uniquely identify the connection service and carries it in the device discovery request, replacing the slave device's original fixed UUID, thereby achieving accurate identification and connection.

Benefits of technology

By generating a specific service identifier for each slave device, the master device can accurately identify and connect to each slave device, avoiding misconnections and improving the accuracy and efficiency of the connection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2026073020_30072026_PF_FP_ABST
    Figure CN2026073020_30072026_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of short-range communications. Disclosed is a device connection method. The disclosed method comprises: obtaining a device discovery request initiated by a second device, wherein the device discovery request comprises a first service identifier, and the first service identifier is a service identifier pre-generated by a first device and used for uniquely identifying a connection service for the second device; and on the basis of the first service identifier, executing first connection processing regarding the second device, so as to establish a communication connection with the second device.
Need to check novelty before this filing date? Find Prior Art

Description

A device connection method

[0001] This application claims priority to Chinese Patent Application No. 202510127961.7, filed on January 27, 2025, entitled "A Method for Connecting Devices", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of short-range communication technology, and in particular to a device connection method. Background Technology

[0003] When establishing short-range connections, such as Bluetooth connections, between PCs (Personal Computers) and mobile phones (master and slave devices) using connection services like SmartConnect, the PC needs to connect based on the SmartConnect service UUID (Universally Unique Identifier) ​​broadcast by the slave device. However, in scenarios with multiple slave devices, such as multiple mobile phones, a single service UUID makes it difficult for the master device (PC) to accurately identify the slave devices, leading to the potential for accidental connection to other slave devices. Summary of the Invention

[0004] Therefore, this application discloses the following technical solution:

[0005] A device connection method, applied to a first device, the method comprising:

[0006] A device discovery request initiated by a second device is obtained; the device discovery request includes a first service identifier; the first service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the second device;

[0007] Based on the first service identifier, perform a first connection process with the second device to establish a communication connection with the second device.

[0008] Optionally, the device connection method further includes:

[0009] Obtain a device discovery request initiated by a third device; the device discovery request initiated by the third device includes a second service identifier;

[0010] Based on the second service identifier, perform a first connection process with the third device to establish a communication connection with the third device;

[0011] Wherein, the second service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the third device; the connection service of the third device and the connection service of the second device are the same connection service, and the second service identifier is different from the first service identifier.

[0012] Optionally, the second device and the third device include the same third service identifier;

[0013] The second device and the third device can respectively interact with the first device based on their corresponding communication connections to provide service data indicated by the third service identifier.

[0014] Optionally, the device connection method further includes, before receiving a device discovery request initiated by the second device:

[0015] In response to receiving a device add request for adding a device, the system generates a first service identifier to uniquely identify the connection service of the second device to be added, and generates and displays an electronic information code containing the first service identifier.

[0016] Optionally, the step of performing the first connection process with the second device based on the first service identifier includes:

[0017] If not paired with the second device, pairing processing with the second device is performed based on the first service identifier. Based on the second device address of the second device obtained through the pairing processing, a communication connection is established with the second device, and a first record processing is performed. The first record processing is used to record the mapping relationship information between the first service identifier and the second device address.

[0018] If pairing with the second device has been completed, the second device address of the second device is obtained based on the first service identifier and the mapping relationship information, and a communication connection is established with the second device based on the second device address.

[0019] Optionally, the device discovery request may further include a second device identifier of the second device, and the first record processing is used to record mapping relationship information between the first service identifier and the second device address and the second device identifier;

[0020] If pairing with the second device has been completed, the process includes the following steps before receiving a device discovery request initiated by the second device:

[0021] In response to selecting a second device identifier from the set of paired device identifiers corresponding to the first device to indicate the second device, the first service identifier corresponding to the second device identifier is obtained based on the mapping relationship information, so as to listen for device discovery requests initiated by the second device based on the first service identifier.

[0022] Optionally, the device connection method further includes:

[0023] If the pairing process with the second device has been completed, and the second device identifier is lost in the set of paired device identifiers, the system listens for device discovery requests initiated by the second device. In response to the listen for device discovery requests initiated by the second device, the pairing process with the second device is re-executed based on the first service identifier in the device discovery request.

[0024] A device connection method, applied to a second device, the method comprising:

[0025] Initiate a device discovery request; the device discovery request includes a first service identifier; the first service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the second device;

[0026] A second connection process is performed between the first device and the first service identifier to establish a communication connection with the first device.

[0027] Optionally, before initiating a device discovery request, the method further includes:

[0028] The first service identifier is obtained based on the electronic information code containing the first service identifier displayed by the first device.

[0029] Optionally, performing the second connection process with the first device includes:

[0030] If not paired with the first device, pairing processing with the first device is performed based on the first service identifier. Based on the first device address of the first device obtained through the pairing processing, a communication connection is established with the first device, and a second recording process is performed. The second recording process is used to record the mapping relationship information between the first service identifier and the first device address.

[0031] If pairing with the first device has been completed, the first device address of the first device is obtained based on the first service identifier and the mapping relationship information, and a communication connection is established with the first device based on the first device address.

[0032] A device connection apparatus, applied to a first device, the apparatus comprising:

[0033] The acquisition module is used to acquire a device discovery request initiated by the second device; the device discovery request includes a first service identifier; the first service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the second device;

[0034] The first connection processing module is used to perform a first connection processing with the second device based on the first service identifier, so as to establish a communication connection with the second device.

[0035] An electronic device, comprising:

[0036] Memory is used to store computer instruction sets;

[0037] A processor is configured to implement, by executing a set of computer instructions in the memory, a device connectivity method applicable to a first device, or a device connectivity method applicable to a second device, as provided above.

[0038] A storage medium carrying one or more computer instruction sets, which, when executed by an electronic device, enable the electronic device to implement the device connection method applied to a first device or the device connection method applied to a second device as described in any of the preceding claims. Attached Figure Description

[0039] To more clearly illustrate the technical solutions in this application or related technologies, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0040] Figure 1 is a flowchart of a device connection method for a first device provided in this application;

[0041] Figure 2 is another flowchart of the device connection method applied to the first device provided in this application;

[0042] Figure 3 is a flowchart of the device connection method for the second device provided in this application;

[0043] Figure 4 is an example diagram of a master-slave device connection scenario provided in this application;

[0044] Figure 5 is a flowchart illustrating the process of establishing a Bluetooth connection between a PC and a mobile phone in the initial pairing scenario provided in this application.

[0045] Figure 6 is a flowchart illustrating the process of establishing a Bluetooth connection between a PC and a mobile phone in the event of device pairing loss recovery provided in this application.

[0046] Figure 7 is a flowchart illustrating the process of establishing a Bluetooth connection between a PC and a mobile phone under paired conditions, as provided in this application.

[0047] Figure 8 is a structural diagram of the device connection device applied to the first device provided in this application;

[0048] Figure 9 is a structural diagram of the device connection device applied to the second device provided in this application;

[0049] Figure 10 is a structural diagram of the electronic device provided in this application. Detailed Implementation

[0050] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0051] This application provides a device connection method to address the problem in known technologies where, when establishing connections between master and slave devices, a single service UUID prevents the master device (such as a PC) from accurately identifying the slave devices, leading to misconnections, especially when facing multiple slave devices (e.g., multiple mobile phones). The device connection method provided in this application can be applied to electronic devices in various general-purpose or dedicated computing environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor devices, etc.

[0052] The device connection method includes a device connection method applied to a first device and a device connection method applied to a second device. The first device and the second device are used as a master device and a slave device in a short-range communication connection application scenario, respectively, and may be, but are not limited to, a user PC and a smartphone, respectively.

[0053] The short-range communication connection can be, but is not limited to, Bluetooth or Wi-Fi connections. This application will primarily use Bluetooth as an example to illustrate the solution.

[0054] Referring to the method flowchart shown in Figure 1, the device connection method for a first device provided in this application embodiment may include the following steps 101 to 102, which are described in detail below.

[0055] Step 101: Obtain a device discovery request initiated by the second device; the device discovery request includes a first service identifier; the first service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the second device.

[0056] Optionally, the second device may initiate a device discovery request via a broadcast message, which may be, but is not limited to, a Bluetooth broadcast message. For example, a mobile phone may initiate a device discovery request via a Bluetooth broadcast message.

[0057] The connection service of the second device may be, but is not limited to, SmartConnect deployed on the second device, which can be used to establish a connection between the second device as a slave device and the master device.

[0058] The device discovery request initiated by the second device should include the service identifier of the connection service of the second device, such as the UUID of the SmartConnect of the second device. In order to overcome the defect in the known technology that when facing multiple slave devices, such as multiple mobile phones, a single service UUID makes it impossible for the master device such as the PC to accurately identify the slave device, which may easily lead to misconnection to other slave devices, the embodiments of this application pre-generate a first service identifier for the second device to uniquely identify the connection service of the second device by the first device.

[0059] Optionally, the first service identifier can be a random UUID generated by the first device, such as a random UUID generated by a PC for a mobile phone to be connected to uniquely identify the SmartConnect connection service on the mobile phone, so as to distinguish it from the fixed UUID of the SmartConnect connection service in known technologies.

[0060] The random UUID or other first service identifier is used to replace the original fixed UUID of the connection service such as SmartConnect. The first service identifier is carried in the device discovery request of the second device so that the master device, such as the first device, can accurately identify the second device based on the first service identifier in the device discovery request and avoid mistakenly connecting to other slave devices.

[0061] Step 102: Based on the first service identifier, perform a first connection process with the second device to establish a communication connection with the second device.

[0062] After receiving the device discovery request from the second device, the first device parses the device discovery request and accurately identifies the second device based on the parsed first service identifier. Then, based on the first service identifier, it performs the first connection processing with the second device to establish a communication connection with the second device.

[0063] Taking Bluetooth connection as an example, the first device (master device) can discover the Bluetooth broadcast message initiated by the second device (slave device) by scanning the Bluetooth broadcast signal. This Bluetooth broadcast message is also the device discovery request. Then, the first service identifier in the Bluetooth broadcast message is parsed, and a Bluetooth connection between the first service identifier and the second device is established based on the first service identifier.

[0064] In summary, the device connection method provided in this application, targeting short-distance connection scenarios between master and slave devices, generates a first service identifier for a second device (which is a slave device) in advance, which is a first device acting as the master device, to uniquely identify its (second device's) connection service. This first service identifier replaces the original fixed service identifier of the second device's connection service in the device discovery request of the second device. This allows the first device to accurately identify the second device based on the first service identifier and establish a communication connection with the second device, avoiding accidental connection to other slave devices. Thus, this application solves the problem of accidental connection caused by the inability of master devices such as PCs to accurately identify slave devices due to a single service UUID when facing multiple slave devices, such as multiple mobile phones, in master-slave device connection scenarios.

[0065] In an optional embodiment, referring to the flowchart of the device connection method applied to the first device shown in FIG2, the device connection method applied to the first device provided in this application may further include the following processing before step 101:

[0066] Step 201: In response to receiving a device addition request for adding a device, generate the first service identifier to uniquely identify the connection service of the second device to be added, and generate and display an electronic information code containing the first service identifier.

[0067] Optionally, the device add request may be a request for adding a device triggered by a user performing a device add operation on the connection service of the first device.

[0068] The connection service of the first device may be, but is not limited to, SmartConnect deployed on the first device, which can be used to establish a connection between the first device as the master device and the slave device.

[0069] When a user needs to establish a communication connection between their second device (slave device) such as a smartphone and a first device (master device) such as a PC, optionally, they can perform a device addition operation on the connection service of the first device. For example, they can click the "Add Device" button on the SmartConnect interface of the PC to trigger a device addition request based on this operation.

[0070] In response to a request to add a device, the first device generates a first service identifier, such as a random UUID, to uniquely identify the connection service of the second device to be added, and generates an electronic information code containing the first service identifier to display it.

[0071] The electronic information code may be, but is not limited to, a QR code.

[0072] The second device can obtain the first service identifier by scanning the electronic information code, so that a device discovery request can be constructed based on the first service identifier. For example, a second electronic device such as a mobile phone can obtain the random UUID by scanning a QR code containing a random UUID generated and displayed by a PC. The random UUID can then be used to construct a Bluetooth broadcast message for device discovery.

[0073] This embodiment generates a first service identifier for the second device based on the device addition operation, which is used to uniquely identify the connection service of the second device. This allows each slave device to have a specific service identifier that can uniquely identify its connection service in the master-slave device connection scenario. This makes it easier for the master device to accurately identify each slave device based on the specific service identifier corresponding to each slave device, thereby effectively avoiding the problem of misconnection of slave devices.

[0074] In an optional embodiment, step 102 of the device connection method for the first device provided in this application, namely, performing a first connection process with the second device based on the first service identifier, can be implemented by including the following processes:

[0075] 11) If not paired with the second device, perform pairing processing with the second device based on the first service identifier, establish a communication connection with the second device based on the second device address of the second device obtained through the pairing processing, and perform first record processing.

[0076] If the first device is not paired with the second device, the first device may first perform pairing processing with the second device based on the first service identifier, obtain the second device address of the second device through the pairing processing, and then establish a communication connection with the second device based on the second device address, and perform the first record processing.

[0077] Specifically, when not paired with a second device, the first device can initiate a pairing request to the second device based on the parsed first service identifier and execute subsequent pairing processing with the second device. Through pairing processing, the first device can obtain the second device address of the second device, which may be, but is not limited to, the MAC address of the second device. After pairing is completed, the first device can further initiate a connection request, such as a Bluetooth connection request, to the second device based on the second device address, and execute connection processing with the second device based on the initiated connection request to establish a communication connection with the second device.

[0078] The first recording process is used to record the mapping relationship information between the first service identifier and the second device address on the first device. For example, on a host device such as a PC, the mapping relationship information between the random UUID of the mobile phone and the MAC address of the mobile phone is recorded. For ease of description, this embodiment refers to this mapping relationship information as the first mapping relationship information.

[0079] 12) If pairing with the second device has been completed, obtain the second device address of the second device based on the first service identifier and the mapping relationship information, and establish a communication connection with the second device based on the second device address.

[0080] If the first device has completed pairing with the second device, the first device can directly use the parsed first service identifier (parsed from the device discovery request of the second device) as a basis to extract the second device address of the second device from the first mapping relationship information, such as extracting the MAC address of the second device from the first mapping relationship information, and then establish a communication connection with the second device based on the second device address, such as establishing a Bluetooth connection with a mobile phone or other second device.

[0081] This embodiment enables the first device to accurately identify the second device through the first service identifier when the first device is not paired with the second device or has been paired with the second device. This effectively avoids the problem of the first device mistakenly connecting to other devices due to device identification errors.

[0082] In one alternative embodiment, the device discovery request initiated by the second device may include not only the first service identifier but also the second device identifier of the second device.

[0083] The second device identifier can be, but is not limited to, the name of the second device. Taking the communication connection as a Bluetooth connection as an example, the second device identifier can specifically be, but is not limited to, the Bluetooth name of the second device, such as the Bluetooth name of a mobile phone. The first recording process can specifically be used to record the mapping relationship information between the first service identifier of the second device and the second device address and the second device identifier. This mapping relationship information is the first mapping relationship information mentioned above. That is, in this embodiment, the first mapping relationship information specifically represents the mapping relationship between the first service identifier of the second device and the second device address and the second device identifier.

[0084] In practical applications, the first device, acting as the master device, can maintain a set of paired device identifiers. This set includes the device identifiers of each slave device paired with the first device, such as the Bluetooth names of each paired device. Each paired device identifier in this set corresponds to a specific mapping relationship, which represents the mapping relationship between the device identifier, service identifier (such as a random UUID), and device address of the corresponding paired device.

[0085] The set of paired device identifiers may be implemented as a list or array, for example, a list of paired Bluetooth devices may be maintained on a first device such as a PC, and the list may include the Bluetooth names of each slave device such as a mobile phone that has been paired with the first device such as the PC.

[0086] If the first device has already completed pairing with the second device, before the first device receives a device discovery request initiated by the second device, the device connection method for the first device provided in this application may further include the following processing:

[0087] In response to selecting a second device identifier from the set of paired device identifiers corresponding to the first device to indicate the second device, the first service identifier corresponding to the second device identifier is obtained based on the first mapping relationship information, so as to listen for device discovery requests initiated by the second device based on the first service identifier.

[0088] Specifically, if the first device has been paired with the second device, when a user needs to establish a connection between the second device and the first device, the user can select the second device identifier of the second device to be connected from the set of paired device identifiers of the first device. The first device can selectively listen for device discovery requests initiated by the second device based on the second device identifier selected by the user. Subsequently, after listening to the device discovery request initiated by the second device, the first device can obtain the second device address of the second device from the first mapping relationship information based on the first service identifier carried in the device discovery request or the second device identifier selected by the user, such as obtaining the MAC address of the second device, and then establish a communication connection with the second device based on the second device address.

[0089] For example, taking Bluetooth connection as an example, the user can select the desired target paired device from the list of paired Bluetooth devices on the PC (such as the list of Bluetooth names of each paired mobile phone). For example, by clicking the Bluetooth name of the desired target paired device, the PC listens for the device discovery request initiated by the target paired device. In response to the device discovery request, the PC obtains the MAC address of the target paired device from the recorded mapping relationship information based on the random UUID in the device discovery request or the Bluetooth name selected by the user, and then establishes a Bluetooth connection with the paired device based on the obtained MAC address.

[0090] This embodiment records the mapping relationship between the service identifier, device identifier, and device address of paired devices (slave devices) on the first device and maintains a set of paired device identifiers. This allows users to directly select the target slave device to be connected from the set of paired device identifiers on the first device when they need to establish a communication connection between the target slave device and the first device. This enables the first device to selectively listen for device discovery requests from target slave devices based on the selection results, and to quickly establish a communication connection with the target slave device based on the recorded device address when a device discovery request is heard. This improves the efficiency of establishing a communication connection between the master and slave devices and reduces the time consumption.

[0091] In an optional embodiment, the device connection method for a first device provided in this application may further include the following processing:

[0092] If the pairing process with the second device is completed, and the second device identifier is lost in the set of paired device identifiers, the system listens for device discovery requests initiated by the second device. In response to the listening for device discovery requests initiated by the second device, the pairing process with the second device is re-executed based on the first service identifier in the device discovery request.

[0093] In practical applications, due to accidental operation, such as a user's mistake on the first device SmartConnect, a device identifier in the set of paired device identifiers on the first device may be deleted, resulting in the loss of a device identifier in the set of paired device identifiers.

[0094] In this case, when the first device detects a device discovery request from a slave device whose device identifier has been lost, it can re-execute the pairing process with the slave device. By re-executing the pairing process with the slave device, the device identifier of the slave device can be added back to the first device's set of paired device identifiers.

[0095] For the second device, if the second device's second device identifier is lost in the first device's set of paired device identifiers after the first device has completed pairing with the second device, the first device can re-execute the pairing process with the second device based on the first service identifier carried in the device discovery request when it hears the second device's device discovery request. For example, the first device can initiate a pairing request to the second device to execute the pairing process with the second device, thereby completing the re-pairing process with the second device. Based on the re-pairing process with the second device, the second device identifier of the second device can be added back to the first device's set of paired device identifiers. At the same time, a communication connection can be established with the second device based on the second device's second device address.

[0096] For example, if a phone's Bluetooth name is lost in the PC's list of paired Bluetooth devices, the PC can re-perform the pairing process with the phone based on the random UUID carried in the Bluetooth broadcast message when it hears the phone's Bluetooth broadcast message. The PC can also add the phone's Bluetooth name back to the PC's list of paired Bluetooth devices and establish a Bluetooth connection with the phone based on the phone's MAC address.

[0097] It should be noted that if the first device has completed pairing with a slave device and the slave device's device identifier is lost in the first device's set of paired device identifiers, the mapping relationship information corresponding to the slave device (the mapping relationship information between the service identifier and the slave device identifier and the slave device address) will not be lost and will still be retained in the first device. Therefore, after the first device completes the re-pairing with the slave device, it is not necessary to re-record the mapping relationship information corresponding to the slave device.

[0098] If the device identifier of a paired slave device is lost in the paired device identifier set of the first device, this embodiment can re-add the device identifier of the slave device to the paired device identifier set of the first device by re-performing the pairing process with the slave device. This makes it convenient to quickly and efficiently establish a communication connection between the first device and the slave device when there is a connection requirement between the first device and the slave device in the future, by directly selecting the device identifier of the slave device from the paired device identifier set of the first device.

[0099] In an optional embodiment, the device connection method for a first device provided in this application may further include the following steps 21)-22):

[0100] 21) Obtain a device discovery request initiated by a third device; the device discovery request initiated by the third device includes a second service identifier.

[0101] Wherein, the second service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the third device; the connection service of the third device and the connection service of the second device are the same connection service, and the second service identifier is different from the first service identifier.

[0102] In other words, for each slave device that needs to connect to the first device (master device), the first device can generate a specific service identifier to uniquely identify the connection service of that slave device, so that the first device can accurately identify the corresponding slave device based on the specific service identifier. For example, the first device, such as a PC, can generate a random SmartConnect UUID to uniquely identify each mobile phone to be connected, so that the PC can accurately identify the corresponding mobile phone based on the random UUID generated for each mobile phone.

[0103] Each slave device can use the same connection service to establish a connection with the master device, but each slave device identifies the same connection service based on a different specific service identifier. This allows the first device to accurately identify each slave device and establish a communication connection with it based on the specific service identifier corresponding to each slave device, thus avoiding misconnection due to device identification errors.

[0104] In practice, similar to the operation method for the second device, the third device can also trigger a device addition request by performing a device addition operation on the first device. In response to the device addition request, the first device generates a second service identifier such as a random UUID for the third device to be added, and generates and displays an electronic information code containing the second service identifier, such as a QR code containing the random UUID, so that the third device can obtain the second service identifier such as the random UUID by scanning the code.

[0105] 22) Based on the second service identifier, perform a first connection process with the third device to establish a communication connection with the third device.

[0106] If the first device is not paired with the third device, the first device performs a pairing process with the third device based on the second service identifier, establishes a communication connection with the third device based on the third device address obtained through the pairing process, and performs a first recording process; here, the first recording process is used to record the mapping relationship information between the second service identifier and the third device address;

[0107] If pairing with the third device has been completed, the first device obtains the third device address of the third device based on the second service identifier and the above-mentioned mapping relationship information, and establishes a communication connection with the third device based on the third device address.

[0108] In practical applications, the first device, acting as the master device, can disconnect from one slave device and then establish a communication connection with another slave device. Alternatively, it can establish communication connections with one or more slave devices based on actual device connection requirements, even if a communication connection has already been established with one or more slave devices. When the first device needs to establish communication connections with multiple slave devices, it can do so serially or in parallel, such as via Bluetooth. There are no restrictions on this, and it can be determined based on the actual application situation.

[0109] In summary, in this embodiment, by having the first device generate a specific service identifier for each slave device that needs to be connected, the first device can accurately identify each slave device based on the corresponding specific service identifier. This ensures that in scenarios involving connection to a single slave device or multiple slave devices, the first device can accurately identify and connect to each slave device that initiates a device discovery request, thus avoiding misconnection problems caused by device misidentification.

[0110] In an alternative embodiment, each slave device connected to the first device (master device), such as the second device and the third device, also includes the same third service identifier.

[0111] The service indicated by the third service identifier can perform service data interaction between the slave device and the first device based on the communication connection between the slave device and the first device.

[0112] Accordingly, the second device and the third device can respectively interact with the first device based on their respective communication connections to exchange service data provided by the service indicated by the third service identifier.

[0113] For ease of description, in this embodiment, the service indicated by the third service identifier is referred to as the upper-layer service of the connection service.

[0114] Taking the communication connection as a Bluetooth connection as an example, the service indicated by the third service identifier, that is, the upper-layer service, may include various Bluetooth services, specifically including but not limited to some or all of the following Bluetooth services: general access service, general attribute service, device information service, battery service, heart rate service, health temperature service, blood pressure service, ambient light service, real-time alarm service, and scan parameter service.

[0115] Each of these upper-layer services corresponds to a unique identifier (UUID). The same upper-layer service deployed on different slave devices corresponds to the same UUID. In practical applications, the specific service identifier corresponding to the connection service of each slave device and the service identifier of the upper-layer service can be combined to jointly identify the upper-layer service of each specific slave device. For example, the random UUID of the second device and the UUID of the battery service can be used to identify the battery service of the second device, and the random UUID of the third device and the UUID of the battery service can be used to identify the battery service of the third device.

[0116] This embodiment deploys upper-layer services on each slave device that enable service data interaction between the slave device and the master device based on the communication connection between the slave device and the master device. By combining the specific service identifier corresponding to the connection service of each slave device with the service identifier of the upper-layer service, the upper-layer service of each slave device is jointly identified. This allows the master device, such as the first device, to effectively distinguish the same upper-layer service of different slave devices, thereby achieving accurate service data interaction between the master device and different slave devices. It also prevents incorrect service data interaction with other devices due to misidentification of slave devices.

[0117] Referring to the method flowchart shown in Figure 3, the device connection method for a second device provided in this application embodiment may include the following steps 301 to 302, which are described below.

[0118] Step 301: Initiate a device discovery request; the device discovery request includes a first service identifier; the first service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the second device.

[0119] The second device is used as a slave device in a master-slave connection scenario.

[0120] Optionally, the second device may initiate a device discovery request via a broadcast message, such as via a Bluetooth broadcast message.

[0121] The device discovery request includes the first service identifier. Optionally, it may also include the second device identifier of the second device, such as the Bluetooth name of the second device.

[0122] The second device can obtain the first service identifier by scanning the electronic information code, such as a QR code, displayed by the first device that contains the first service identifier, and use the first service identifier to uniquely identify the connection service of the second device.

[0123] Step 302: Perform a second connection process with the first device based on the first service identifier to establish a communication connection with the first device.

[0124] If the second device is not paired with the first device, a pairing process is performed with the first device based on the first service identifier. Based on the first device address of the first device obtained through the pairing process, a communication connection is established with the first device, and a second record process is performed.

[0125] Specifically, if the second device is not paired with the first device, the first device can initiate a pairing request to the second device based on the first service identifier in the device discovery request. The second device then executes the pairing process with the first device in response to the pairing request, thereby completing the pairing between the second device and the first device. Based on this, the second recording process is performed, which is used to record the mapping relationship information between the first service identifier and the address of the first device on the second device. For ease of description, this mapping relationship information is referred to as the second mapping relationship information in this embodiment.

[0126] If the second device has completed pairing with the first device, the first device address of the first device is obtained based on the first service identifier and the second mapping relationship information, and a communication connection between the second device and the first device is established based on the first device address.

[0127] The first device address of the first device can be the MAC address of the first device, such as the MAC address of a PC.

[0128] Similar to the first device maintaining a set of device identifiers for paired slave devices, the second device can maintain a set of device identifiers for each of its corresponding paired master devices, such as a list of Bluetooth names for each paired PC. This allows the second device to select the desired target master device when it has a connection request to that target master device, thereby quickly establishing a communication connection with that target master device.

[0129] Optionally, the device identifier and device address of the master device can be obtained by the second device through a pairing process with the master device.

[0130] In practical applications, the connection scenarios between master devices and slave devices can be one-to-one, one-to-many, many-to-one, or many-to-many connection scenarios, as shown in the schematic diagram in Figure 4. When multiple slave devices are involved, since each slave device obtains a specific service identifier (such as a random UUID) from the master device to which it needs to connect, it can ensure that the master device can accurately identify each slave device, effectively avoiding the problem of misconnecting to other slave devices due to misidentification of slave devices.

[0131] In summary, the device connection method for the second device provided in this embodiment uniquely identifies the connection service of the second device based on a first service identifier pre-generated by the first device, and establishes a communication connection with the first device based on the first service identifier rather than the original fixed identifier of the connection service. This allows the first device to effectively identify the second device based on the first service identifier, avoiding the problem of the first device mistakenly connecting to other devices due to misidentification of the second device.

[0132] Based on the solutions in this application, the connection scenarios between the master device and the slave device, such as between a PC and a user's mobile phone, can be divided into three types: establishing a connection based on initiating pairing during the first connection, establishing a connection in the case of device pairing loss recovery, and establishing a connection when already paired.

[0133] The following describes the connection establishment process in the above three scenarios, using the example of a PC and a user's mobile phone as the first device (master device) and the second device (slave device), and establishing a Bluetooth connection between the PC and the mobile phone.

[0134] 1. During the initial connection, a connection is established based on initiating pairing.

[0135] Referring to Figure 5, which shows the flowchart of establishing a Bluetooth connection between a PC and a mobile phone in the initial pairing scenario, the process mainly includes:

[0136] 1. A random UUID is generated on the PC and stored in a QR code;

[0137] 2. The mobile phone obtains a random UUID by scanning a QR code and initiates a Bluetooth broadcast message to establish a service. The Bluetooth broadcast message includes the random UUID and may also include the mobile phone's Bluetooth identifier.

[0138] 3. After receiving the Bluetooth broadcast message, the PC begins Bluetooth pairing with the mobile phone;

[0139] 4. After successful pairing, a Bluetooth connection is established between the mobile phone and the PC, and the mapping relationship between the random UUID and the device address of the peer device is saved. At the same time, the corresponding list of paired devices can be maintained.

[0140] Optionally, the PC can store the mapping relationship between the random UUID and the MAC address and Bluetooth identifier of the mobile phone, and the mobile phone can store the mapping relationship between the random UUID and the MAC address and Bluetooth identifier of the PC.

[0141] For a more detailed implementation process of establishing a Bluetooth connection between the PC and the mobile phone in this scenario, please refer to Figure 5.

[0142] II. Establishing a connection in case of device pairing loss and recovery

[0143] Referring to Figure 6, which shows the flowchart for establishing a Bluetooth connection between a PC and a mobile phone in the case of device pairing loss recovery, the process mainly includes:

[0144] 1. When starting a connection service such as SmartConnect on a PC and selecting the Bluetooth identifier of the phone to be connected, the Bluetooth identifier of the phone is found to be missing.

[0145] 2. The PC listens for the random UUID broadcast by the phone via Bluetooth broadcast message (device discovery request);

[0146] 3. After detecting a broadcast message carrying a random UUID from the mobile phone, the PC re-initiates a pairing request to the mobile phone in order to re-pair with the mobile phone;

[0147] 4. After successful pairing, a Bluetooth connection will be established between the PC and the mobile phone. At the same time, the PC's list of paired devices will be updated, and the blue icon of the mobile phone will be added back to the PC's list of paired devices.

[0148] For a more detailed implementation process of establishing a Bluetooth connection between the PC and the mobile phone in this scenario, please refer to Figure 6.

[0149] III. Establishing a connection when already paired

[0150] Referring to Figure 7, the flowchart for establishing a Bluetooth connection between a PC and a mobile phone under paired conditions is shown. This process mainly includes:

[0151] 1. The PC selects the phone to connect from the list of paired devices, obtains the random UUID used by the phone (saved after the first successful connection), and listens for its broadcast messages.

[0152] 2. Switch the mobile phone to the PC to be connected, obtain the corresponding random UUID (save it after the first successful connection), establish a service and initiate a broadcast message (device discovery request);

[0153] 3. The PC receives the broadcast message sent by the mobile phone and initiates a connection.

[0154] For a more detailed implementation process of establishing a Bluetooth connection between the PC and the mobile phone in this scenario, please refer to Figure 7.

[0155] In Figures 6 and 7, the APP refers to the APP used to provide the connection service such as SmartConnect.

[0156] In any scenario, the PC can accurately identify and connect to the phone based on the random UUID corresponding to each phone, avoiding problems of misidentification and misconnection.

[0157] Corresponding to the device connection method applied to the first device, this application embodiment also provides a device connection apparatus applied to the first device. Referring to the structural diagram shown in FIG8, the device connection apparatus applied to the first device includes:

[0158] The acquisition module 801 is used to acquire a device discovery request initiated by the second device; the device discovery request includes a first service identifier; the first service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the second device;

[0159] The first connection processing module 802 is used to perform a first connection processing with the second device based on the first service identifier, so as to establish a communication connection with the second device.

[0160] In an optional embodiment, the acquisition module 801 is further configured to: acquire a device discovery request initiated by a third device; the device discovery request initiated by the third device includes a second service identifier;

[0161] The first connection processing module 802 is further configured to: perform a first connection processing with the third device based on the second service identifier, so as to establish a communication connection with the third device;

[0162] Wherein, the second service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the third device; the connection service of the third device and the connection service of the second device are the same connection service, and the second service identifier is different from the first service identifier.

[0163] In one alternative implementation, the second device and the third device include the same third service identifier;

[0164] The second device and the third device can respectively interact with the first device based on their corresponding communication connections to provide service data indicated by the third service identifier.

[0165] In an optional embodiment, the above apparatus further includes a generation and display module, which, in response to receiving a device addition request for adding a device before receiving a device discovery request initiated by the second device, generates the first service identifier to uniquely identify the connection service of the second device to be added, and generates and displays an electronic information code containing the first service identifier.

[0166] In an optional implementation, the first connection processing module 802, when performing the first connection processing with the second device based on the first service identifier, is specifically used for:

[0167] If not paired with the second device, pairing processing with the second device is performed based on the first service identifier. Based on the second device address of the second device obtained through the pairing processing, a communication connection is established with the second device, and a first record processing is performed. The first record processing is used to record the mapping relationship information between the first service identifier and the second device address.

[0168] If pairing with the second device has been completed, the second device address of the second device is obtained based on the first service identifier and the mapping relationship information, and a communication connection is established with the second device based on the second device address.

[0169] In an optional implementation, the device discovery request further includes a second device identifier of the second device, and the first record processing is used to record mapping information between the first service identifier and the second device address and the second device identifier;

[0170] The acquisition module 801 is further configured to: when pairing with the second device has been completed, before receiving a device discovery request initiated by the second device, in response to selecting a second device identifier from the set of paired device identifiers corresponding to the first device to indicate the second device, obtain the first service identifier corresponding to the second device identifier based on the mapping relationship information, so as to listen for the device discovery request initiated by the second device based on the first service identifier.

[0171] In an optional embodiment, the first connection processing module 802 is further configured to: if the pairing with the second device has been completed, and if the second device identifier is lost in the set of paired device identifiers, listen for a device discovery request initiated by the second device, and in response to listening for the device discovery request initiated by the second device, re-execute the pairing process with the second device based on the first service identifier in the device discovery request.

[0172] Corresponding to the device connection method applied to the second device, this application embodiment also provides a device connection apparatus applied to the second device. Referring to the structural diagram shown in FIG9, the device connection apparatus applied to the second device includes:

[0173] Initiation module 901 is used to initiate a device discovery request; the device discovery request includes a first service identifier; the first service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the second device;

[0174] The second connection processing module 902 is used to perform a second connection processing with the first device based on the first service identifier, so as to establish a communication connection with the first device.

[0175] In an optional embodiment, the above apparatus further includes an acquisition module, configured to: obtain the first service identifier based on an electronic information code containing the first service identifier displayed by the first device before initiating a device discovery request.

[0176] In an optional embodiment, the second connection processing module 902 is specifically used for:

[0177] If not paired with the first device, pairing processing with the first device is performed based on the first service identifier. Based on the first device address of the first device obtained through the pairing processing, a communication connection is established with the first device, and a second recording process is performed. The second recording process is used to record the mapping relationship information between the first service identifier and the first device address.

[0178] If pairing with the first device has been completed, the first device address of the first device is obtained based on the first service identifier and the mapping relationship information, and a communication connection is established with the first device based on the first device address.

[0179] This application also discloses an electronic device, the composition of which, as shown in Figure 10, includes at least:

[0180] Memory 10 is used to store the computer instruction set;

[0181] Computer instruction sets can be implemented in the form of computer programs.

[0182] The processor 20 is configured to implement, by executing a set of computer instructions in the memory, a device connection method applied to a first device, or a device connection method applied to a second device, as provided in any of the above method embodiments.

[0183] The processor 20 can be a central processing unit (CPU), an application-specific integrated circuit (ASIC), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a neural network processor (NPU), a deep learning processor (DPU), or other programmable logic devices.

[0184] Optionally, electronic devices may also include storage resources such as memory and cache.

[0185] Optionally, the electronic device may also include a camera assembly, and / or be connected to an external camera assembly.

[0186] In addition to these components, electronic devices may also include communication interfaces, communication buses, and other parts. Memory, processor, and communication interface communicate with each other through the communication bus.

[0187] Communication interfaces are used for communication between electronic devices and other devices. Communication buses can be Peripheral Component Interconnect (PCI) buses or Extended Industry Standard Architecture (EISA) buses, and can be divided into address buses, data buses, control buses, etc.

[0188] This application also discloses a storage medium carrying one or more computer instruction sets. When the one or more computer instruction sets are executed by an electronic device, the electronic device is able to implement the device connection method for a first device or the device connection method for a second device as provided in any of the above method embodiments.

[0189] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0190] For ease of description, the above systems or devices are described separately as various modules or units based on their functions. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware components.

[0191] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence or the part that makes a creative contribution, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.

[0192] Finally, it should be noted that in this document, relational terms such as first, second, third, and fourth are used to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0193] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A device connection method, applied to a first device, the method comprising: Receive a device discovery request initiated by the second device; The device discovery request includes a first service identifier; The first service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the second device; Based on the first service identifier, perform a first connection process with the second device to establish a communication connection with the second device.

2. The device connection method according to claim 1 further includes: Receive a device discovery request initiated by a third device; The device discovery request initiated by the third device includes a second service identifier; Based on the second service identifier, perform a first connection process with the third device to establish a communication connection with the third device; Wherein, the second service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the third device; the connection service of the third device and the connection service of the second device are the same connection service, and the second service identifier is different from the first service identifier.

3. The device connection method according to claim 2, wherein the second device and the third device include the same third service identifier; The second device and the third device can respectively interact with the first device based on their corresponding communication connections to provide service data indicated by the third service identifier.

4. The device connection method according to claim 1, further comprising, before obtaining the device discovery request initiated by the second device: In response to receiving a device add request for adding a device, the system generates a first service identifier to uniquely identify the connection service of the second device to be added, and generates and displays an electronic information code containing the first service identifier.

5. The device connection method according to claim 1, wherein performing the first connection process with the second device based on the first service identifier includes: If not paired with the second device, pairing processing with the second device is performed based on the first service identifier. Based on the second device address of the second device obtained through the pairing processing, a communication connection is established with the second device, and a first record processing is performed. The first record processing is used to record the mapping relationship information between the first service identifier and the second device address. If pairing with the second device has been completed, the second device address of the second device is obtained based on the first service identifier and the mapping relationship information, and a communication connection is established with the second device based on the second device address.

6. The device connection method according to claim 5, wherein the device discovery request further includes a second device identifier of the second device, and the first record processing is used to record mapping relationship information between the first service identifier and the second device address and the second device identifier; If pairing with the second device has been completed, the process includes the following steps before receiving a device discovery request initiated by the second device: In response to selecting a second device identifier from the set of paired device identifiers corresponding to the first device to indicate the second device, the first service identifier corresponding to the second device identifier is obtained based on the mapping relationship information, so as to listen for device discovery requests initiated by the second device based on the first service identifier.

7. The device connection method according to claim 6 further includes: If the pairing process with the second device has been completed, and the second device identifier is lost in the set of paired device identifiers, the system listens for device discovery requests initiated by the second device. In response to the listen for device discovery requests initiated by the second device, the pairing process with the second device is re-executed based on the first service identifier in the device discovery request.

8. A device connection method applied to a second device, the method comprising: Initiate a device discovery request; The device discovery request includes a first service identifier; The first service identifier is a service identifier pre-generated by the first device to uniquely identify the connection service of the second device; A second connection process is performed between the first device and the first service identifier to establish a communication connection with the first device.

9. The device connection method according to claim 8, further comprising, before initiating a device discovery request: The first service identifier is obtained based on the electronic information code containing the first service identifier displayed by the first device.

10. The device connection method according to claim 8, wherein performing the second connection process with the first device includes: If not paired with the first device, pairing processing with the first device is performed based on the first service identifier. Based on the first device address of the first device obtained through the pairing processing, a communication connection is established with the first device, and a second recording process is performed. The second recording process is used to record the mapping relationship information between the first service identifier and the first device address. If pairing with the first device has been completed, the first device address of the first device is obtained based on the first service identifier and the mapping relationship information, and a communication connection is established with the first device based on the first device address.