Search

US-12621878-B2 - Pairing connection method and apparatus, and storage medium

US12621878B2US 12621878 B2US12621878 B2US 12621878B2US-12621878-B2

Abstract

A pairing connection method is applied to a first device, and the pairing connection method includes: in response to determining that the first device is triggered to make a pairing connection with a second device, acquiring device information of the second device, and authenticating the second device based on the device information of the second device; in response to that authentication of the second device is passed, obtaining pairing connection service information that matches the second device from pre-stored service information for pairing connection; and pairing with the second device based on the pairing connection service information.

Inventors

  • Lei Chen

Assignees

  • BEIJING XIAOMI MOBILE SOFTWARE CO., LTD.

Dates

Publication Date
20260505
Application Date
20230831
Priority Date
20230505

Claims (13)

  1. 1 . A pairing connection method, applied to a first device, the method comprising: in response to determining that the first device is triggered to make a pairing connection with a second device, acquiring device information of the second device, and authenticating the second device based on the device information of the second device; in response to that authentication of the second device is passed, obtaining pairing connection service information that matches the second device from pre-stored service information for pairing connection; and pairing with the second device based on the pairing connection service information, wherein acquiring device information of the second device, and authenticating the second device based on the device information of the second device comprises: acquiring a broadcast message broadcast by the second device, the broadcast message comprising address information and private protocol information of the second device; scanning the second device based on the address information of the second device; in response to having scanned the second device based on the address information of the second device, parsing the private protocol information; and determining consistency between information content obtained by parsing the private protocol information and information content stored in the first device to authenticate the second device, and wherein the private protocol information comprises at least one of the following: data content identification, second device identification, and second device version information.
  2. 2 . The method according to claim 1 , wherein obtaining pairing connection service information that matches the second device from pre-stored service information for pairing connection comprises: triggering, based on a connection callback event of a protocol stack, to obtain cache information of the second device from a local database, the cache information being used to cache the pairing connection service information of the second device; when the cache information of the second device exists in the local database, obtaining the pairing connection service information of the second device from the local database; and when the cache information of the second device does not exist in the local database, loading a cache file comprising a service identification field of the second device, and obtaining the pairing connection service information of the second device from the cache file based on the service identification field of the second device.
  3. 3 . The method according to claim 2 , wherein the service identification field is used to identify a report and descriptor information of each service in all services provided by the second device.
  4. 4 . The method according to claim 1 , wherein the first device is a terminal, and the second device is a stylus.
  5. 5 . A non-transitory computer-readable storage medium, having stored thereon instructions, which, when executed by a processor of a first device, enable the first device to execute the method according to claim 1 .
  6. 6 . A pairing connection method, applied to a second device, the method comprising: in response to determining that the second device is triggered to make pairing connection with a first device, sending device information of the second device; and pairing with the first device based on pairing connection service information, the pairing connection service information being obtain by the first device from pre-stored service information for pairing connection when authentication of the second device is passed, wherein sending device information of the second device comprises: broadcasting a broadcast message, the broadcast message comprising address information and private protocol information of the second device; and the address information being used for the first device to scan to the second device, and the private protocol information being used for the first device to authenticate the second device based on consistency between information content obtained by parsing the private protocol information and information content stored in the first device, and wherein the private protocol information comprises at least one of the following: data content identification, second device identification, and second device version information.
  7. 7 . The method according to claim 6 , wherein the pre-stored service information for pairing connection is stored in cache information of a local database of the first device, and the cache information is used to cache the pairing connection service information of the second device; or the pre-stored service information for pairing connection is stored in a cache file, and the cache file comprises a service identification field of the second device, and the service identification field of the second device is used to identify the pairing connection service information of the second device.
  8. 8 . The method according to claim 7 , wherein the service identification field is used to identify a report and descriptor information of each service in all services provided by the second device.
  9. 9 . A pairing connection apparatus, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to implement the method according to claim 6 .
  10. 10 . The apparatus according to claim 9 , wherein the pre-stored service information for pairing connection is stored in cache information of a local database of the first device, and the cache information is used to cache the pairing connection service information of the second device; or the pre-stored service information for pairing connection is stored in a cache file, and the cache file comprises a service identification field of the second device, and the service identification field of the second device is used to identify the pairing connection service information of the second device.
  11. 11 . A non-transitory computer-readable storage medium, having stored thereon instructions, which, when executed by a processor of a second device, enable the second device to execute the method according to claim 6 .
  12. 12 . A pairing connection apparatus, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to perform: in response to determining that the first device is triggered to make a pairing connection with a second device, acquiring device information of the second device, and authenticating the second device based on the device information of the second device; in response to that authentication of the second device is passed, obtaining pairing connection service information that matches the second device from pre-stored service information for pairing connection; and pairing with the second device based on the pairing connection service information, wherein the processor is further configured to: acquire a broadcast message broadcast by the second device, the broadcast message comprising address information and private protocol information of the second device; scan the second device based on the address information of the second device; in response to having scanned the second device based on the address information of the second device, parse the private protocol information; and determine consistency between information content obtained by parsing the private protocol information and information content stored in the first device to authenticate the second device, and wherein the private protocol information comprises at least one of the following: data content identification, second device identification, and second device version information.
  13. 13 . The apparatus according to claim 12 , wherein the processor is further configured to perform: triggering, based on a connection callback event of a protocol stack, to obtain cache information of the second device from a local database, the cache information being used to cache the pairing connection service information of the second device; when the cache information of the second device exists in the local database, obtaining the pairing connection service information of the second device from the local database; and when the cache information of the second device does not exist in the local database, loading a cache file comprising a service identification field of the second device, and obtaining the pairing connection service information of the second device from the cache file based on the service identification field of the second device.

Description

CROSS-REFERENCE TO RELATED APPLICATION This application is based on and claims priority to Chinese Patent Application No. 202310499627.5 filed on May 5, 2023, the disclosure of which is hereby incorporated by reference in its entirety for all purposes. BACKGROUND With the development of Bluetooth communication technology, pairing connection technology comes into our daily life with its own advantages. There are also greater demands and more application scenarios for the pairing connection. For example, it is applied in the scenario of pairing connection of the Bluetooth Low Energy (BLE) Human Machine Interface device. SUMMARY The present disclosure relates to the field of Bluetooth communication technology, and more specifically, to a pairing connection method and apparatus, and a storage medium. In order to overcome the problems existing in the related technologies, the present disclosure provides a pairing connection method and apparatus, and a storage medium. According to a first aspect of embodiments of the present disclosure, there is provided a pairing connection method, applied to a first device, the method including: in response to determining that the first device is triggered to make a pairing connection with a second device, acquiring device information of the second device, and authenticating the second device based on the device information of the second device; in response to that authentication of the second device is passed, obtaining pairing connection service information that matches the second device from pre-stored service information for pairing connection; and pairing with the second device based on the pairing connection service information. According to a second aspect of embodiments of the present disclosure, there is provided a pairing connection method, applied to a second device, the method including: in response to determining that the second device is triggered to make pairing connection with a first device, sending device information of the second device; and pairing with the first device based on pairing connection service information, the pairing connection service information being obtain by the first device from pre-stored service information for pairing connection when authentication of the second device is passed. According to a third aspect of embodiments of the present disclosure, there is provided a pairing connection apparatus, applied to a first device, the apparatus including: a processing unit configured to, in response to determining that the first device is triggered to make a paring connection with a second device, acquire device information of the second device, and authenticate the second device based on the device information of the second device; and in response to that authentication of the second device is passed, obtain pairing connection service information that matches the second device from pre-stored service information for pairing connection; and a connecting unit configured to pair with the second device based on the pairing connection service information. According to a fourth aspect of embodiments of the present disclosure, there is provided a pairing connection apparatus, applied to a second device, the apparatus including: a sending unit configured to, in response to determining that the second device is triggered to make pairing connection with a first device, send device information of the second device; and a connecting unit configured to perform pairing connection with the first device based on pairing connection service information, the pairing connection service information being obtain by the first device from pre-stored service information for pairing connection when authentication of the second device is passed. According to a fifth aspect of the present disclosure, there is provided a pairing connection apparatus, including: a processor; a memory for storing instructions executable by the processor; where the processor is configured to implement the method in the first aspect or any embodiment of the first aspect described above. According to a sixth aspect of the present disclosure, there is provided a pairing connection apparatus, including: a processor; a memory for storing instructions executable by the processor; where the processor is configured to implement the method in the second aspect or any embodiment of the second aspect described above. According to a seventh aspect of the present disclosure, there is provided a storage medium, where instructions are stored in the storage medium, a first device is enabled to execute the pairing connection method in the first aspect or any embodiment of the first aspect described above when the instructions are executed by a processor of the first device. According to an eighth aspect of the present disclosure, there is provided a storage medium, where instructions are stored in the storage medium, a second device is enabled to execute the pairing connection method in the second aspect or