Bluetooth communication method, terminal equipment and readable storage medium

By using directional broadcast messages to carry device identification in Bluetooth communication, the problem of mobile phones being unable to connect to tablets when they are not in broadcasting state is solved, connection between devices is achieved, power consumption is saved, and the normal operation of business is ensured.

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

Patent Information

Application Number
CN202410390555.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-29
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

In Bluetooth communication, when a mobile phone needs to conduct business with a tablet computer, but the tablet computer is not in the broadcasting state, the mobile phone and the tablet computer cannot establish a Bluetooth connection, affecting business execution.

Method used

The mobile phone sends a directional broadcast message to the tablet computer. The broadcast message contains the device identification of the tablet computer, so that the tablet computer can filter out the message and actively connect to the mobile phone to establish a connection between the two.

Benefits of technology

In the case that the tablet does not need to be in the broadcast state all the time, the connection between the mobile phone and the tablet is achieved, which saves device power consumption and avoids device loss, ensuring the normal operation of Bluetooth services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120730278A_ABST
    Figure CN120730278A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to the technical field of communication, and provides a Bluetooth communication method, terminal equipment and a readable storage medium. The Bluetooth communication method comprises: a first terminal device sends a broadcast message to a second terminal device, the broadcast message being used for triggering the second terminal device to establish a Bluetooth connection with the first terminal device, and the broadcast message comprising a device identifier of the second terminal device; and the first terminal device receives a connection request message sent by the second terminal device. A directional broadcast message is sent to a second terminal device through a first terminal device, the second terminal device can filter and screen broadcast messages sent to the second terminal device based on a device identifier of the second terminal device, and the second terminal device is triggered to send a connection request message to the first terminal device. Through the reversal of the active connection role, the establishment of the connection between the first terminal device and the second terminal device is completed, and the normal operation of the service is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Bluetooth technology is a short-range wireless communication technology that is widely used in communication devices such as smartphones, Bluetooth headsets, and tablet computers.

[0003] Before devices can transmit data via Bluetooth, they must be paired and connected. Only after establishing a Bluetooth connection can normal operations be performed. For example, for a mobile phone to connect to a tablet, the tablet must be in broadcast mode and sending broadcast messages. Conversely, the mobile phone must receive the broadcast message from the tablet and resolve the address in the broadcast message before initiating a Bluetooth connection.

[0004] However, when the mobile phone needs to conduct business with the tablet computer and the tablet computer is not in the broadcast state, the Bluetooth connection between the mobile phone and the tablet computer will not be established, and the business will not be conducted, which affects the execution of the business. Summary of the Invention

[0005] The embodiments of the present application provide a Bluetooth communication method, a terminal device, and a readable storage medium. When a mobile phone needs to conduct business with a tablet computer and the tablet computer is not in a broadcasting state, a Bluetooth connection can be achieved between the mobile phone and the tablet computer, so that the business can be conducted normally.

[0006] In a first aspect, a Bluetooth communication method is provided, including: a first terminal device sends a broadcast message to a second terminal device, the broadcast message is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device, the broadcast message includes a device identifier of the second terminal device; the first terminal device receives a connection request message sent by the second terminal device.

[0007] The Bluetooth communication method provided in the first aspect is suitable for scenarios where a first terminal device needs to actively connect to a second terminal device, but the second terminal device is not in a broadcast state. For example, the first terminal device is a mobile phone and the second terminal device is a tablet computer. A directed broadcast message is sent from the first terminal device to the second terminal device, and the directed broadcast message includes the device identification of the second terminal device. Thus, the second terminal device can filter out the broadcast messages sent to itself based on its own device identification, and trigger the sending of a connection request message to the first terminal device. By reversing the active connection role, in a scenario where the first terminal device needs to actively connect to the second terminal device, the second terminal device is triggered to reverse and actively connect to the first terminal device, thereby completing the connection establishment between the first terminal device and the second terminal device, thereby ensuring the normal operation of the Bluetooth service.

[0008] In a possible implementation, the first terminal device sends a broadcast message to the second terminal device, including: when the first terminal device initiates a first service, the first terminal device sends a broadcast message to the second terminal device.

[0009] In a possible implementation, the broadcast message further includes a first service identifier, where the first service identifier is used to indicate the first service.

[0010] In a possible implementation, the first service identifier is a challenge code.

[0011] In a possible implementation, the Bluetooth communication method further includes: the first terminal device and the second terminal device transmitting verification information, where the verification information is used to determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

[0012] In a possible implementation, the verification information includes: a first service identifier and / or a second service identifier, where the second service identifier is sent by the second terminal device and is used to indicate the first service.

[0013] In a possible implementation, the verification information further includes: a device identification of the first terminal device and / or a device identification of the second terminal device.

[0014] In one possible implementation, the first terminal device and the second terminal device transmit verification information, including: the first terminal device receives a second service identifier and a device identifier of the second terminal device sent by the second terminal device, where the second service identifier is used to indicate the first service; if the second service identifier is the same as the first service identifier, the first terminal device sends the device identifier of the first terminal device to the second terminal device.

[0015] In a possible implementation, the Bluetooth communication method further includes: the first terminal device acquiring a device identification of the second terminal device.

[0016] In one possible implementation, the first terminal device obtains the device identification of the second terminal device, including: the first terminal device and the second terminal device perform networking authentication; the first terminal device receives second networking information sent by the second terminal device, and the second networking information includes the device identification of the second terminal device.

[0017] In a possible implementation, the Bluetooth communication method further includes: the first terminal device sending first networking information to the second terminal device, where the first networking information includes a device identifier of the first terminal device.

[0018] In a possible implementation, before the first terminal device receives the connection request message sent by the second terminal device, the process further includes: the first terminal device receives a scan request message sent by the second terminal device; and the first terminal device sends a scan response message to the second terminal device.

[0019] In the second aspect, a Bluetooth communication method is provided, including: a second terminal device receives a broadcast message sent by a first terminal device, the broadcast message is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device, and the broadcast message includes a device identifier of the second terminal device; the second terminal device sends a connection request message to the first terminal device.

[0020] The Bluetooth communication method provided in the second aspect is suitable for scenarios where the first terminal device needs to actively connect to the second terminal device, but the second terminal device is not in a broadcast state. For example, the first terminal device is a mobile phone and the second terminal device is a tablet computer. The second terminal device receives the broadcast message sent by the first terminal device, and constructs a filter based on the device identification of the second terminal device, so as to determine whether the broadcast message is a broadcast message sent directly to itself by the first terminal device. When it is determined that the broadcast message is a broadcast message sent directly to itself by the first terminal device, the second terminal device sends a connection request message to the first terminal device. By reversing the active connection role, in the scenario where the first terminal device needs to actively connect to the second terminal device, the second terminal device is triggered to reverse and actively connect to the first terminal device, thereby completing the connection establishment between the first terminal device and the second terminal device, thereby ensuring the normal operation of the Bluetooth service.

[0021] In a possible implementation, the broadcast message further includes a first service identifier, where the first service identifier is used to indicate the first service.

[0022] In a possible implementation, the first service identifier is a challenge code.

[0023] In a possible implementation, the Bluetooth communication method further includes: the second terminal device and the first terminal device transmitting verification information, where the verification information is used to determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

[0024] In a possible implementation, the verification information includes: a first service identifier and / or a second service identifier, where the second service identifier is sent by the second terminal device and is used to indicate the first service.

[0025] In a possible implementation, the verification information further includes: a device identification of the first terminal device and / or a device identification of the second terminal device.

[0026] In a possible implementation, the second terminal device transmits verification information to the first terminal device, including: the second terminal device sends a second service identifier and a device identifier of the second terminal device to the first terminal device, where the second service identifier is used to indicate the first service.

[0027] In a possible implementation, the second terminal device transmits verification information to the first terminal device, further comprising: the second terminal device receiving a device identification of the first terminal device sent by the first terminal device.

[0028] In a possible implementation, the Bluetooth communication method further includes: the second terminal device obtaining a device identification of the first terminal device.

[0029] In one possible implementation, the second terminal device obtains the device identification of the first terminal device, including: the second terminal device performs networking authentication with the first terminal device; the second terminal device receives first networking information sent by the first terminal device, and the first networking information includes the device identification of the first terminal device.

[0030] In a possible implementation, the Bluetooth communication method further includes: the second terminal device sending second networking information to the first terminal device, where the second networking information includes a device identifier of the second terminal device.

[0031] In a possible implementation, before the second terminal device sends a connection request message to the first terminal device, the process further includes: the second terminal device sends a scan request message to the first terminal device; and the second terminal device receives a scan response message sent by the first terminal device.

[0032] In the third aspect, a terminal device is provided, which serves as a first terminal device. The first terminal device includes: a sending module for sending a broadcast message to a second terminal device, the broadcast message is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device, and the broadcast message includes a device identification of the second terminal device; and a receiving module for receiving a connection request message sent by the second terminal device.

[0033] In a possible implementation, the sending module is configured to send a broadcast message to the second terminal device when the first terminal device initiates the first service.

[0034] In a possible implementation, the broadcast message further includes a first service identifier, where the first service identifier is used to indicate the first service.

[0035] In a possible implementation, the first service identifier is a challenge code.

[0036] In a possible implementation, the sending module and / or the receiving module is further configured to: transmit verification information, where the verification information is used to determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

[0037] In a possible implementation, the verification information includes: a first service identifier and / or a second service identifier, where the second service identifier is sent by the second terminal device and is used to indicate the first service.

[0038] In a possible implementation, the verification information further includes: a device identification of the first terminal device and / or a device identification of the second terminal device.

[0039] In one possible implementation, the sending module is used to: receive a second service identifier and a device identifier of the second terminal device sent by the second terminal device, where the second service identifier is used to indicate the first service; if the second service identifier is the same as the first service identifier, the receiving module is used to send the device identifier of the first terminal device to the second terminal device.

[0040] In a possible implementation, the processing module is configured to obtain a device identification of the second terminal device.

[0041] In a possible implementation, the processing module is used to: perform networking authentication with the second terminal device; the receiving module is used to receive second networking information sent by the second terminal device, where the second networking information includes a device identifier of the second terminal device.

[0042] In a possible implementation, the sending module is further configured to: send the first networking information to the second terminal device, where the first networking information includes a device identifier of the first terminal device.

[0043] In a possible implementation, the receiving module is further configured to: the first terminal device receives a scan request message sent by the second terminal device; and the sending module is further configured to: the first terminal device sends a scan response message to the second terminal device.

[0044] In the fourth aspect, a terminal device is provided, which serves as a second terminal device, and the second terminal device includes: a receiving module for receiving a broadcast message sent by a first terminal device, the broadcast message is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device, and the broadcast message includes a device identification of the second terminal device; a sending module for sending a connection request message to the first terminal device.

[0045] In a possible implementation, the broadcast message further includes a first service identifier, where the first service identifier is used to indicate the first service.

[0046] In a possible implementation, the first service identifier is a challenge code.

[0047] In a possible implementation, the sending module and / or the receiving module is further configured to: transmit verification information, where the verification information is used to determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

[0048] In a possible implementation, the verification information includes: a first service identifier and / or a second service identifier, where the second service identifier is sent by the second terminal device and is used to indicate the first service.

[0049] In a possible implementation, the verification information further includes: a device identification of the first terminal device and / or a device identification of the second terminal device.

[0050] In a possible implementation, the sending module is configured to send a second service identifier and a device identifier of the second terminal device to the first terminal device, where the second service identifier is used to indicate the first service.

[0051] In a possible implementation, the receiving module is further configured to: receive a device identification of the first terminal device sent by the first terminal device.

[0052] In a possible implementation, the processing module is configured to obtain a device identification of the first terminal device.

[0053] In a possible implementation, the processing module is used to: perform networking authentication with the first terminal device; the receiving module is used to receive first networking information sent by the first terminal device, where the first networking information includes a device identifier of the first terminal device.

[0054] In a possible implementation, the sending module is further configured to: send second networking information to the first terminal device, where the second networking information includes a device identifier of the second terminal device.

[0055] In a possible implementation, the sending module is further used to: send a scan request message to the first terminal device; and the receiving module is further used to: receive a scan response message sent by the first terminal device.

[0056] In a fifth aspect, a terminal device is provided as a first terminal device, comprising a processor, the processor being used to couple with a memory, read instructions in the memory, and enable the first terminal device to execute the method provided in the first aspect according to the instructions.

[0057] In a sixth aspect, a terminal device is provided as a second terminal device, comprising a processor, the processor being used to couple with a memory, read instructions in the memory, and enable the second terminal device to execute the method provided in the second aspect according to the instructions.

[0058] In a seventh aspect, a program is provided, which, when executed by a processor, is used to execute the method provided in the first aspect or the second aspect.

[0059] In an eighth aspect, a computer-readable storage medium is provided, in which instructions are stored. When the instructions are executed on a computer or a processor, the method provided in the first aspect or the second aspect is implemented.

[0060] In the ninth aspect, a program product is provided, which includes a computer program, wherein the computer program is stored in a readable storage medium, and at least one processor of a device can read the computer program from the readable storage medium, and the at least one processor executes the computer program so that the device implements the method provided in the first aspect or the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1A-1B A set of schematic diagrams of Bluetooth communication scenarios;

[0062] Figure 2 A message interaction diagram of a Bluetooth communication method in related technology;

[0063] Figure 3 A message interaction diagram of the Bluetooth communication method provided in an embodiment of the present application;

[0064] Figure 4 A schematic diagram of the packet structure of a broadcast message provided in an embodiment of the present application;

[0065] Figure 5 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0066] Figure 6 Another structural diagram of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0067] In order to make the purpose, technical solutions and advantages of this application more clear, the application will be further described in detail below with reference to the accompanying drawings. The specific operation methods and functional descriptions in the method embodiments can also be applied to the device embodiments or system embodiments.

[0068] In the embodiments of the present application, unless otherwise specified, the same or similar parts between the various embodiments can refer to each other. In the various embodiments of the present application, and the various implementation methods / implementation methods / implementation methods in each embodiment, if there is no special explanation and logical conflict, the terms and / or descriptions between different embodiments and the various implementation methods / implementation methods / implementation methods in each embodiment are consistent and can be referenced to each other. The technical features in different embodiments and the various implementation methods / implementation methods / implementation methods in each embodiment can be combined to form new embodiments, implementation methods, implementation methods, or implementation methods according to their inherent logical relationships. The above-described implementation methods of the present application do not constitute a limitation on the scope of protection of the present application. In each embodiment step, it can be partially executed (for example, the terminal device may not execute the steps performed by the terminal device in the above embodiment). The execution order of different steps can be changed. The embodiments described herein can be combined with other embodiments, and the steps of different embodiments herein can also be combined.

[0069] Reference herein to an "embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the present application. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments.

[0070] The terms "first", "second", "third", "fourth", etc. (if any) in the embodiments of the present application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0071] In the embodiments of the present application, "include" can be an inclusion relationship or an equality relationship. For example, A includes B, which means that A includes B and can also include other content, or A and B are the same content.

[0072] In the description of this application, unless otherwise specified, " / " indicates that the objects associated with each other are in an "or" relationship. For example, A / B can represent A or B. "And / or" in this application is only a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, in the description of this application, unless otherwise specified, "multiple" means two or more than two. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple. In addition, in order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with basically the same functions and effects. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.

[0073] In the embodiments of this application, words such as "exemplarily" and "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as "exemplary" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of the word "exemplary" is intended to present concepts in a concrete way.

[0074] The Bluetooth communication method provided in the embodiment of the present application is applicable to Bluetooth communication, such as Bluetooth low energy (BLE) communication. Figure 1A-1B A set of schematic diagrams of Bluetooth communication scenarios. Figure 1A As shown, both terminal device 100 and terminal device 200 support Bluetooth function. Terminal device 100 is a mobile phone, and terminal device 200 is a headset. The mobile phone and the headset can be connected to each other via Bluetooth for Bluetooth communication. For example, songs and videos on the mobile phone can be played through the headset. Figure 1B As shown, terminal device 100 is a mobile phone, and terminal device 200 is a tablet computer. The mobile phone and the tablet computer can communicate via Bluetooth. For example, when performing screen projection, files on the mobile phone can be displayed on the tablet computer.

[0075] It should be noted that this application does not limit the name and type of terminal devices. For example, a terminal device may also be referred to as a terminal, electronic device, communication device, Bluetooth device, etc. Some examples of terminal devices include: mobile phones, tablet computers, laptop computers, PDAs, wearable devices, headphones, speakers, styluses, smart screens, teaching equipment, Internet of Things (IoT) devices, or wireless terminals in smart homes. Optionally, the terminal device has a display screen.

[0076] It should be noted that in different scenarios, according to the function, role or communication protocol of the terminal device, the terminal device may also have other names. Figure 1B The mobile phone and tablet computer shown in the figure are used as examples for explanation.

[0077] In some scenarios, the terminal device that initiates the connection is called the central device, and the terminal device that is connected is called the peripheral device. Figure 1B In this scenario, the mobile phone is the central device and the tablet is the peripheral device. In some scenarios, the central device is also called the connecting device and the peripheral device is also called the connected device.

[0078] In some scenarios, the terminal device that initiates the service is called the server or server device, and the corresponding terminal device is called the client or client device. Figure 1B In the process, the mobile phone initiates the screen projection service, the mobile phone is the server, and the tablet is the client.

[0079] For the convenience of distinction and description, this application uses Figure 1B The mobile phone and tablet computer shown are used as examples. The mobile phone actively initiates the screen projection service. The mobile phone is called the first terminal device or central device or server, and the tablet computer is called the second terminal device or peripheral device or client. This is used as an example for explanation.

[0080] In the related art, when the peripheral device is in the broadcast state, the central device can connect to the peripheral device. For example, Figure 2 This is a message interaction diagram of the Bluetooth communication method in the related art, with the mobile phone as the central device and the tablet computer as the peripheral device.

[0081] like Figure 2 As shown, the Bluetooth communication method may include:

[0082] S201. The tablet computer sends a broadcast message.

[0083] Specifically, when the tablet is in the broadcast state, it can send connectable non-directional broadcast messages, called ADV_IND messages or broadcast packets, to other terminal devices around it. Connectable non-directional broadcast messages are not targeted at one or more devices, and other terminal devices around the tablet may receive the broadcast message.

[0084] The broadcast message includes an address. Optionally, the address is a random address.

[0085] After the tablet sends a broadcast message, it needs to open a radio frequency window for a period of time to receive data packets from other terminal devices. For example, the tablet can receive connection request messages sent by mobile phones during this period. Figure 2 In the example, the tablet sent three broadcast messages.

[0086] S202: The mobile phone sends a connection request message to the tablet computer.

[0087] Specifically, the mobile phone receives a broadcast message sent by the tablet computer, parses the broadcast message to obtain the address, and sends a connection request message (called a CONN_REQ message or a CONNECT_IND message) to the tablet computer to initiate a Bluetooth connection. This process is called a link establishment process.

[0088] S203. Conduct business between the mobile phone and the tablet computer.

[0089] Specifically, after the mobile phone and the tablet computer are connected, services can be performed.

[0090] Need to explain, Figure 2 The process of establishing a connection and performing a service shown may also include other steps, which are not limited in this embodiment.

[0091] There is a scenario where a central device needs to connect to a peripheral device when initiating a service, but the peripheral device is not in the advertising state. In this case, the peripheral device will not send a broadcast message to connect, resulting in the central device being unable to actively connect to the peripheral device and unable to conduct Bluetooth services.

[0092] In this scenario, one approach to connecting a central device to a peripheral device is to keep the peripheral device in a constant broadcast state. Specifically, when the peripheral device is not connected, the peripheral device continuously sends broadcast messages indicating it can connect, but when the peripheral device is connected, the peripheral device stops sending broadcast messages. This results in the peripheral device being in the broadcast state for extended periods of time, increasing power consumption, increasing the risk of device damage, and shortening its lifespan.

[0093] The present application provides a Bluetooth communication method, which is applicable to Bluetooth communication, particularly to BLE communication, and involves a first terminal device and a second terminal device. In a scenario where the first terminal device needs to actively connect to the second terminal device, but the second terminal device is not in a broadcast state, the first terminal device sends a broadcast message to the second terminal device, triggering the second terminal device to actively connect to the first terminal device in turn, thereby achieving a connection between the first terminal device and the second terminal device, avoiding power consumption and wear problems caused by the second terminal device being in a broadcast state all the time, and eliminating the need to propose equipment improvement requirements for the first terminal device and the second terminal device. The connection between the terminal devices is achieved, ensuring the normal operation of the business.

[0094] The technical solution of this application is described in detail below through specific embodiments.

[0095] Figure 3 A message interaction diagram of the Bluetooth communication method provided in an embodiment of the present application. This embodiment involves a first terminal device and a second terminal device, and is applicable to a scenario where the first terminal device needs to actively connect to the second terminal device, but the second terminal device is not in a broadcast state, but is not limited to this scenario. It should be noted that this embodiment does not limit the triggering reason for the first terminal device to actively connect to the second terminal device. Exemplarily, the first terminal device can be a mobile phone, and the second terminal device can be a tablet computer.

[0096] like Figure 3 As shown, the Bluetooth communication method provided in this embodiment may include:

[0097] S301. A first terminal device sends a broadcast message to a second terminal device. The broadcast message is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device. The broadcast message includes a device identifier of the second terminal device.

[0098] Correspondingly, the second terminal device receives the broadcast message sent by the first terminal device.

[0099] The device identifier is used to uniquely distinguish different terminal devices. This embodiment does not limit the name and implementation of the device identifier. For example, the device identifier can also be called a network identifier. Specifically, in the application scenario of this embodiment, the communication distance between the first terminal device and the second terminal device is usually close, which belongs to near-field communication. The first terminal device and the second terminal device are in a near-field networking relationship and each has a unique device identifier.

[0100] The broadcast message sent by the first terminal device to the second terminal device includes the device identification of the second terminal device, that is, the first terminal device sends a targeted broadcast message to the second terminal device, or the first terminal device sends a targeted broadcast message to the second terminal device.

[0101] It can be understood that the broadcast message in this step is Figure 2 The broadcast message in S201 is different. In S201, the broadcast message sent by the tablet computer is a non-directional broadcast message, which is used by other terminal devices to determine that the tablet computer is in a connectable state and can establish a Bluetooth connection. Other terminal devices around the tablet computer may receive the broadcast message and successfully parse the broadcast message, obtain the address in the broadcast message, and actively establish a connection to the tablet computer. In this step, the broadcast message sent by the first terminal device is a directional broadcast message, which is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device. Other terminal devices around the second terminal device may receive the broadcast message, but through parsing, the second terminal device can determine that the broadcast message is sent to itself, triggering the second terminal device to establish a connection with the first terminal device, while other terminal devices can determine that the broadcast message is not sent to themselves and terminate the processing flow.

[0102] The following describes the packet structure of a broadcast message. For example, Figure 4 A schematic diagram of the packet structure of a broadcast message provided in an embodiment of the present application.

[0103] like Figure 4 As shown, the broadcast message is represented by ADV_IND or ADV_DIRECT_IND. ADV_IND or ADV_DIRECT_IND includes AdvA and AdvData. AdvA is 6 bytes (octect), indicating the broadcaster address, public address or random address. AdvData is 0 to 31 bytes, indicating the broadcast data. In one structure, AdvA is a resolvable private address (RPA), that is, the source device is identified by the RPA address. AdvData includes: length, ADtype, ADID, AD Data and AD Flag. Among them, length is 1 byte, indicating the length. AD type is 1 byte, indicating the message type. AD ID is 2 bytes, which can indicate the source of data. AD Data is 0 to 24 bytes, indicating the broadcast data. ADFlag is 3 bytes. Furthermore, AD Data can include: Version, Business and Business Data. Version is 1 byte, indicating the version. Business is 1 byte, indicating the message type. For example, in this embodiment, Business can take the value 0x15, indicating a soft bus broadcast message. Business Data is 1 to 22 bytes, indicating broadcast data. Figure 4In the Business Data field, LSB refers to the least significant bit, and MSB refers to the most significant bit. Furthermore, Business Data includes: a control field, a message type, a Dst ID, a SeqNo, and Command Messages. The control field is 4 bits and is used to indicate whether to wake up. The message type is 4 bits. Dst ID represents a truncation identifier. In this embodiment, Dst ID is the device identifier of the second terminal device. SeqNo is 1 byte and indicates a sequence number. CommandMessages is 16 bytes and indicates command data.

[0104] pass Figure 4 As can be seen, by using the Dst ID field to indicate the device identifier of the second terminal device, the first terminal device can send a broadcast message to the second terminal device in a targeted manner. Accordingly, after receiving the broadcast message, the second terminal device can filter it using the Dst ID field to determine whether the broadcast message is sent to it by the first terminal device.

[0105] Need to explain, Figure 4 This is just an example and does not limit the packet structure of the broadcast message. Figure 4 The names, meanings, and sizes of the fields in the packet structure shown can be found in the Bluetooth-related protocols and will not be described in detail here.

[0106] S302. The second terminal device sends a connection request message to the first terminal device.

[0107] Correspondingly, the first terminal device receives the connection request message sent by the second terminal device.

[0108] Specifically, the second terminal device receives the broadcast message sent by the first terminal device, filters the broadcast message through the device identifier of the second terminal device, and through analysis, if the device identifier carried in the broadcast message is the device identifier of the second terminal device, it is determined that the broadcast message is sent to itself by the first terminal device, thereby triggering the second terminal device to send a connection request message to the first terminal device, so that the second terminal device actively connects to the first terminal device and completes the link establishment.

[0109] It should be noted that the process of establishing a connection between the first terminal device and the second terminal device (ie, the link establishment process) may also include other steps, which are not limited in this embodiment, and other steps of the existing link establishment process may be adopted.

[0110] S303: The first terminal device and the second terminal device perform services.

[0111] Specifically, after the first terminal device establishes a connection with the second terminal device, services can be performed. This step is similar to S203.

[0112] It can be seen that this embodiment provides that, in a scenario where the first terminal device needs to actively connect to the second terminal device, but the second terminal device is not in a broadcast state, a directed broadcast message is sent to the second terminal device through the first terminal device. The directed broadcast message includes the device identification of the second terminal device, so that the second terminal device can filter out the broadcast messages sent to itself based on its own device identification, and trigger the sending of a connection request message to the first terminal device. By reversing the active connection role, in a scenario where the first terminal device needs to actively connect to the second terminal device, the second terminal device is triggered to reverse and actively connect to the first terminal device, thereby completing the connection establishment between the first terminal device and the second terminal device, that is, the link establishment process, avoiding the need for the second terminal device to be in a broadcast state all the time and sending non-directional broadcast messages all the time, saving the power consumption and equipment loss of the second terminal device, and no need to propose equipment improvement requirements for the first terminal device and the second terminal device, thereby realizing the connection between the terminal devices and ensuring the normal operation of the Bluetooth service.

[0113] Optionally, the Bluetooth communication method provided in this embodiment may further include:

[0114] S304: The first terminal device and the second terminal device perform network authentication.

[0115] Specifically, the first terminal device performs near field communication with the second terminal device. Through networking authentication, the first terminal device and the second terminal device can discover the terminal devices in the near field communication and determine a trusted terminal device with which they can communicate.

[0116] Optionally, the first terminal device and the second terminal device perform network authentication, which may include:

[0117] The first terminal device sends the first trusted information, and correspondingly, the second terminal device receives the first trusted information.

[0118] The second terminal device sends the second trusted information, and correspondingly, the first terminal device receives the second trusted information.

[0119] The first terminal device performs device verification based on the first trusted information and the second trusted information, and the second terminal device performs device verification based on the first trusted information and the second trusted information.

[0120] The first trusted information is used to indicate that the first terminal device is a trusted device, and the second trusted information is used to indicate that the second terminal device is a trusted device. The first terminal device broadcasts the first trusted information so that other terminal devices can determine that the first terminal device is a trusted communication device based on the first trusted information, thereby enabling near-field communication. Similarly, the second terminal device broadcasts the second trusted information so that other terminal devices can determine that the second terminal device is a trusted communication device based on the second trusted information, thereby enabling near-field communication.

[0121] Optionally, in one implementation, the first trusted information is a user account used by a user to log in to a first terminal device, and the second trusted information is a user account used by a user to log in to a second terminal device. In this implementation, if the first trusted information is the same as the second trusted information, that is, if the user logs in to the first and second terminal devices using the same account, the first and second terminal devices determine that they are mutually trusted, can perform near-field communication, and complete network authentication.

[0122] Optionally, in another implementation, both the first trusted information and the second trusted information are pairing codes. In this implementation, if the first trusted information is the same as the second trusted information, it indicates that the first terminal device and the second terminal device can be paired, and the first terminal device and the second terminal device determine that they are mutually trusted terminal devices, can perform near-field communication, and complete network authentication.

[0123] S305: The first terminal device exchanges networking information with the second terminal device.

[0124] Specifically, after the first terminal device and the second terminal device undergo network authentication and are determined to be trusted, they can obtain the other terminal device's network information by exchanging network information. This embodiment does not limit the name of the network information; for example, it can also be called basic device information. This exchange of network information is used to enable subsequent communication.

[0125] Optionally, the networking information may include, but is not limited to, at least one of the following: a device identifier of the terminal device, the terminal device's ability to support Bluetooth communication, and the terminal device's ability to support wireless fidelity (Wi-Fi) communication. Optionally, the terminal device's ability to support Bluetooth communication may include: whether the terminal device supports Bluetooth Basic Rate (BR), whether the terminal device supports Bluetooth Enhanced Data Rate (EDR), and whether the terminal device supports BLE.

[0126] In this embodiment, through the networking authentication in S304 and the networking information exchange in S305 , the first terminal device can obtain the device identification of the second terminal device, and the second terminal device can obtain the device identification of the first terminal device.

[0127] Specifically, the first terminal device obtaining the device identification of the second terminal device may include:

[0128] The first terminal device and the second terminal device perform network authentication.

[0129] The second terminal device sends second networking information, which includes the device identification of the second terminal device. Correspondingly, the first terminal device receives the second networking information sent by the second terminal device.

[0130] The second terminal device may obtain the device identification of the first terminal device by:

[0131] The first terminal device and the second terminal device perform network authentication.

[0132] The first terminal device sends first networking information to the second terminal device, where the first networking information includes the device identification of the first terminal device. Correspondingly, the second terminal device receives the first networking information sent by the first terminal device.

[0133] Optionally, the Bluetooth communication method provided in this embodiment may further include, before the second terminal device sends the connection request message to the first terminal device in S302:

[0134] S306: The second terminal device sends a scan request message to the first terminal device. Correspondingly, the first terminal device receives the scan request message sent by the second terminal device.

[0135] S307: The first terminal device sends a scan response message to the second terminal device. Correspondingly, the second terminal device receives the scan response message sent by the first terminal device.

[0136] Among them, the scan request message is called a SCAN_REQ message, and the scan response message is called a SCAN_RSP message. Please refer to the Bluetooth related protocol and will not be repeated here.

[0137] Optionally, in S301, the first terminal device sends a broadcast message to the second terminal device, including:

[0138] When the first terminal device initiates the first service, the first terminal device sends a broadcast message to the second terminal device.

[0139] This implementation provides an application scenario in which a first terminal device needs to actively connect to a second terminal device. Specifically, the first terminal device needs to initiate a first service, and therefore needs to connect to the second terminal device. For example, a mobile phone needs to project its screen onto a tablet, and therefore needs to connect to the tablet. Different application scenarios and different first services will vary, and this embodiment does not limit this.

[0140] Optionally, in a scenario where the first terminal device initiates the first service, the broadcast message also includes a first service identifier, and the first service identifier is used to indicate the first service.

[0141] By carrying the first service identifier in the broadcast message, the second terminal device can learn that the Bluetooth connection to be established is related to the first service and that the first terminal device is to perform the first service, thereby preparing to establish a link for the first service.

[0142] Optionally, the first service identifier is a challenge code.

[0143] The challenge code is expressed as challenge. In the field of communications, the challenge code is also called a challenge password, which generally refers to an encrypted password generated in accordance with the communication protocol, and is used to ensure that information is not leaked during transmission. In this embodiment, different services are indicated by challenge codes. Specifically, in the scenario where the first terminal device initiates the first service, the broadcast message includes: the device identification of the second terminal device and the challenge code (for example, challenge code a).

[0144] The following combination Figure 4 The first service identifier and the challenge code are exemplified. Figure 4 As shown, CommandMessages may include: Command, LinkType, PSM, Padding, Challenge, and MIC.

[0145] Command is a 1-byte field that indicates a link establishment command. A value of 2 indicates a BLE link establishment command. This field is used when requesting to establish a BLE GATT / COC link. GATT stands for Generic Attributes Profile, and COC stands for Consulation Calling.

[0146] LinkType is 1 byte and indicates the requested link type, that is, the link type requested to be established by the other party. A value of 0 indicates BLE GATT Master, a value of 1 indicates BLE GATT Slave, and a value of 2 indicates BLE COC Master.

[0147] The PSM field is 1 byte and is optional. It is mandatory when the link type is CoC.

[0148] Padding is 9 bytes, which means the padding field and indicates the currently unused broadcast space.

[0149] Challenge is 2 bytes and means a random challenge code to request the other party to perform security confirmation. In this embodiment, it represents the first service identifier or challenge code.

[0150] MIC is 2 bytes and means message check bit.

[0151] Optionally, the Bluetooth communication method provided in this embodiment may further include, after the second terminal device sends a connection request message to the first terminal device in S302:

[0152] S308: The first terminal device and the second terminal device transmit verification information, where the verification information is used to determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

[0153] Specifically, in a scenario where the first terminal device initiates the first service, by transmitting verification information between the first terminal device and the second terminal device, further verification can be performed on the Bluetooth connection established for the first service, thereby improving the success rate and efficiency of link establishment.

[0154] Optionally, the verification information may include: a first service identifier and / or a second service identifier, where the second service identifier is sent by the second terminal device and is used to indicate the first service.

[0155] For ease of distinction, the service identifier indicating the first service on the first terminal device side is referred to as the first service identifier. The directed broadcast message sent by the first terminal device to the second terminal device carries the first service identifier. After the second terminal device receives the broadcast message, it filters the broadcast message through the device identifier of the second terminal device and determines that the broadcast message is sent to itself. It can then obtain the service identifier carried in the broadcast message, and the obtained service identifier is referred to as the second service identifier. It can be understood that when correctly parsed, the first service identifier is the same as the second service identifier. The second terminal device can send the second service identifier to the first terminal device as verification information so that the first terminal device can determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

[0156] Optionally, the verification information may further include: a device identification of the first terminal device and / or a device identification of the second terminal device.

[0157] Optionally, the first terminal device determines whether the Bluetooth connection between the first terminal device and the second terminal device is successful by comparing the locally stored device identifier and / or service identifier with the device identifier and / or service identifier received from the second terminal device. If the device identifiers and the service identifiers are the same, the Bluetooth connection between the first terminal device and the second terminal device is determined to be successful, and the subsequent process continues. If the device identifiers are different, or the service identifiers are different, the Bluetooth connection between the first terminal device and the second terminal device is determined to have failed, and the subsequent process is terminated.

[0158] Similarly, the second terminal device determines whether the Bluetooth connection between the first terminal device and the second terminal device is successful by comparing the locally stored device identifier and / or service identifier with the device identifier and / or service identifier received from the first terminal device. If the device identifiers and service identifiers are the same, the Bluetooth connection between the first terminal device and the second terminal device is determined to be successful, and the subsequent process continues. If the device identifiers are different, or the service identifiers are different, the Bluetooth connection between the first terminal device and the second terminal device is determined to have failed, and the subsequent process is terminated.

[0159] Optionally, in one implementation, in S308, the first terminal device and the second terminal device transmit verification information, including:

[0160] The second terminal device sends the second service identifier and the device identifier of the second terminal device to the first terminal device. Correspondingly, the first terminal device receives the second service identifier and the device identifier of the second terminal device sent by the second terminal device.

[0161] If the second service identifier is the same as the first service identifier, the first terminal device sends the device identifier of the first terminal device to the second terminal device.

[0162] In this implementation, the directed broadcast message sent by the first terminal device to the second terminal device carries the first service identifier. The second terminal device sends a connection request message to the first terminal device, and the second terminal device actively connects to the first terminal device. The verification information sent by the second terminal device to the first terminal device includes the second service identifier and the device identifier of the second terminal device. If the second service identifier is the same as the first service identifier, it means that the second terminal device determines to establish a link with the first terminal device for the first service, the Bluetooth connection between the first terminal device and the second terminal device is successful, and the first terminal device sends the device identifier of the first terminal device to the second terminal device. The first terminal device and the second terminal device can carry out the subsequent process to carry out the first service.

[0163] Optionally, before the first terminal device sends the device identification of the first terminal device to the second terminal device, the following steps may also be included:

[0164] The first terminal device determines that the locally stored device identification of the second terminal device is the same as the device identification of the second terminal device sent by the second terminal device.

[0165] By comparing the device identification of the second terminal device, the accuracy of determining whether the Bluetooth connection between the first terminal device and the second terminal device is successful is further improved.

[0166] It is understandable that, in order to implement the above functions, the first terminal device and the second terminal device include hardware and / or software modules that perform the corresponding functions. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of this application.

[0167] In the embodiment of the present application, the functional modules of the first terminal device and the second terminal device can be divided according to the above-mentioned method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one module. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. It should be noted that the names of the modules in the embodiment of the present application are schematic and are not limited in actual implementation.

[0168] For example, Figure 5 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application, wherein the terminal device can be a first terminal device or a second terminal device. Figure 5 As shown, the first terminal device or the second terminal device may include a receiving module 501, a processing module 502, and a sending module 503. The first terminal device or the second terminal device can perform the actions performed by the first terminal device or the second terminal device in the above-mentioned method embodiment of the present application. The technical principles and technical effects are similar and are not further described here.

[0169] When the terminal device is a first terminal device, the first terminal device includes:

[0170] a sending module 503, configured to send a broadcast message to a second terminal device, wherein the broadcast message is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device, and the broadcast message includes a device identifier of the second terminal device;

[0171] The receiving module 501 is configured to receive a connection request message sent by the second terminal device.

[0172] Optionally, the sending module 503 is configured to:

[0173] When the first terminal device initiates the first service, the broadcast message is sent to the second terminal device.

[0174] Optionally, the broadcast message further includes a first service identifier, where the first service identifier is used to indicate the first service.

[0175] Optionally, the first service identifier is a challenge code.

[0176] Optionally, the sending module 503 and / or the receiving module 501 is further configured to:

[0177] Transmit verification information, where the verification information is used to determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

[0178] Optionally, the verification information includes: the first service identifier and / or the second service identifier, where the second service identifier is sent by the second terminal device and is used to indicate the first service.

[0179] Optionally, the verification information further includes: a device identification of the first terminal device and / or a device identification of the second terminal device.

[0180] Optionally, the sending module 503 is configured to:

[0181] receiving a second service identifier and a device identifier of the second terminal device sent by the second terminal device, where the second service identifier is used to indicate the first service;

[0182] If the second service identifier is the same as the first service identifier, the receiving module 501 is configured to send the device identifier of the first terminal device to the second terminal device.

[0183] Optionally, the processing module 502 is configured to:

[0184] Obtain a device identification of the second terminal device.

[0185] Optionally, the processing module 502 is configured to:

[0186] Performing network authentication with the second terminal device;

[0187] The receiving module 501 is configured to receive second networking information sent by the second terminal device, where the second networking information includes a device identifier of the second terminal device.

[0188] Optionally, the sending module 503 is further configured to:

[0189] Send first networking information to the second terminal device, where the first networking information includes a device identifier of the first terminal device.

[0190] Optionally, the receiving module 501 is further configured to:

[0191] The first terminal device receives a scan request message sent by the second terminal device;

[0192] The sending module 503 is further configured to:

[0193] The first terminal device sends a scan response message to the second terminal device.

[0194] When the terminal device is a second terminal device, the second terminal device includes:

[0195] A receiving module 501 is configured to receive a broadcast message sent by a first terminal device, wherein the broadcast message is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device, and the broadcast message includes a device identifier of the second terminal device;

[0196] The sending module 503 is configured to send a connection request message to the first terminal device.

[0197] Optionally, the broadcast message further includes a first service identifier, where the first service identifier is used to indicate the first service.

[0198] Optionally, the first service identifier is a challenge code.

[0199] Optionally, the sending module 503 and / or the receiving module 501 is further configured to:

[0200] Transmit verification information, where the verification information is used to determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

[0201] Optionally, the verification information includes: the first service identifier and / or the second service identifier, where the second service identifier is sent by the second terminal device and is used to indicate the first service.

[0202] Optionally, the verification information further includes: a device identification of the first terminal device and / or a device identification of the second terminal device.

[0203] Optionally, the sending module 503 is configured to:

[0204] A second service identifier and a device identifier of the second terminal device are sent to the first terminal device, where the second service identifier is used to indicate the first service.

[0205] Optionally, the receiving module 501 is further configured to:

[0206] Receive the device identification of the first terminal device sent by the first terminal device.

[0207] Optionally, the processing module 502 is configured to:

[0208] Obtain a device identifier of the first terminal device.

[0209] Optionally, the processing module 502 is configured to:

[0210] Performing network authentication with the first terminal device;

[0211] The receiving module 501 is configured to receive first networking information sent by the first terminal device, where the first networking information includes a device identifier of the first terminal device.

[0212] Optionally, the sending module 503 is further configured to:

[0213] Send second networking information to the first terminal device, where the second networking information includes a device identifier of the second terminal device.

[0214] Optionally, the sending module 503 is further configured to:

[0215] Sending a scan request message to the first terminal device;

[0216] The receiving module 501 is further configured to:

[0217] Receive a scan response message sent by the first terminal device.

[0218] Please refer to Figure 6 , which shows a structure of a terminal device provided in an embodiment of the present application, and the terminal device can be a first terminal device or a second terminal device. Figure 6 As shown, the terminal device includes: a processor 601, a receiver 602, a transmitter 603, a memory 604, and a bus 605. The processor 601 includes one or more processing cores and executes various functional applications and information processing by running software programs and modules. The receiver 602 and transmitter 603 can be implemented as a communication component, which can be a baseband chip. The memory 604 is connected to the processor 601 via a bus 605. The memory 604 can be used to store at least one program instruction, and the processor 601 is used to execute at least one program instruction to implement the technical solutions of the above-mentioned embodiments. The implementation principles and technical effects are similar to those of the above-mentioned method-related embodiments and will not be repeated here.

[0219] When the device is powered on, the processor reads the software program from the memory, interprets and executes its instructions, and processes the data. When data needs to be transmitted via the antenna, the processor performs baseband processing on the data to be transmitted and outputs a baseband signal to the control circuit within the control circuit. The control circuit then performs RF processing on the baseband signal and transmits it as electromagnetic waves via the antenna. When data is sent to the device, the control circuit receives the RF signal via the antenna, converts it to a baseband signal, and outputs the baseband signal to the processor, which converts the baseband signal into data and processes it.

[0220] Those skilled in the art will understand that for ease of explanation, Figure 6 Only one memory and processor are shown. In an actual device, there may be multiple processors and memories. The memory may also be referred to as a storage medium or a storage device, etc., which is not limited in the embodiments of the present application.

[0221] As an optional implementation, the processor may include a baseband processor and a central processing unit (CPU). The baseband processor is primarily responsible for processing communication data, while the CPU is primarily responsible for executing software programs and processing data from these programs. Those skilled in the art will appreciate that the baseband processor and the CPU may be integrated into a single processor or may be separate processors interconnected via a bus or other technology. Those skilled in the art will appreciate that a device may include multiple baseband processors to accommodate different network standards, multiple CPUs to enhance its processing capabilities, and that the various components of the device may be connected via various buses. The baseband processor may also be referred to as a baseband processing circuit or a baseband processing chip. The CPU may also be referred to as a central processing circuit or a central processing chip. The functionality for processing communication protocols and communication data may be built into the processor or stored in a memory as a software program, which is then executed by the processor to implement the baseband processing functionality. The memory may be integrated into the processor or independent of the processor. The memory includes a cache to store frequently accessed data / instructions.

[0222] In the embodiments of the present application, the processor may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present application may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0223] In the embodiments of the present application, the memory may be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SS), or a volatile memory, such as a random-access memory (RAM). The memory is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, without limitation.

[0224] The memory in the embodiments of the present application may also be a circuit or any other device capable of implementing a storage function, for storing program instructions and / or data. The methods provided in the various embodiments of the present application may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiments of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a digital video disc (DWD), or a semiconductor medium (e.g., an SSD), etc.

[0225] An embodiment of the present application also provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the technical solution in the above embodiment. Its implementation principle and technical effect are similar to those of the above-mentioned related embodiments and will not be repeated here.

[0226] The present embodiment provides a computer-readable storage medium having program instructions stored thereon. When the program instructions are executed by a terminal device, the terminal device executes the technical solution of the above embodiment. The implementation principle and technical effects thereof are similar to those of the above-mentioned related embodiments and will not be further described here.

[0227] In summary, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A Bluetooth communication method, characterized in that: include: The first terminal device sends a broadcast message to the second terminal device, where the broadcast message is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device, and the broadcast message includes a device identifier of the second terminal device; The first terminal device receives a connection request message sent by the second terminal device.

2. The method according to claim 1, characterized in that The first terminal device sending a broadcast message to the second terminal device includes: When the first terminal device initiates the first service, the first terminal device sends the broadcast message to the second terminal device.

3. The method according to claim 2, characterized in that The broadcast message further includes a first service identifier, where the first service identifier is used to indicate the first service.

4. The method according to claim 3, characterized in that The first service identifier is a challenge code.

5. The method according to claim 2 or 3, characterized in that The method further comprises: The first terminal device and the second terminal device transmit verification information, where the verification information is used to determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

6. The method according to claim 5, characterized in that The verification information includes: the first service identifier and / or the second service identifier, where the second service identifier is sent by the second terminal device and is used to indicate the first service.

7. The method according to claim 6, characterized in that The verification information further includes: a device identification of the first terminal device and / or a device identification of the second terminal device.

8. The method according to any one of claims 5 to 7, characterized in that The first terminal device and the second terminal device transmit verification information, including: The first terminal device receives a second service identifier and a device identifier of the second terminal device sent by the second terminal device, where the second service identifier is used to indicate the first service; If the second service identifier is the same as the first service identifier, the first terminal device sends the device identifier of the first terminal device to the second terminal device.

9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: The first terminal device obtains the device identification of the second terminal device.

10. The method according to claim 9, characterized in that The first terminal device acquiring the device identification of the second terminal device includes: Performing network authentication between the first terminal device and the second terminal device; The first terminal device receives second networking information sent by the second terminal device, where the second networking information includes a device identifier of the second terminal device.

11. The method according to claim 10, characterized in that The method further comprises: The first terminal device sends first networking information to the second terminal device, where the first networking information includes a device identifier of the first terminal device.

12. The method according to any one of claims 1 to 11, characterized in that Before the first terminal device receives the connection request message sent by the second terminal device, the method further includes: The first terminal device receives a scan request message sent by the second terminal device; The first terminal device sends a scan response message to the second terminal device.

13. A Bluetooth communication method, characterized in that: include: The second terminal device receives a broadcast message sent by the first terminal device, where the broadcast message is used to trigger the second terminal device to establish a Bluetooth connection with the first terminal device, and the broadcast message includes a device identifier of the second terminal device; The second terminal device sends a connection request message to the first terminal device.

14. The method according to claim 13, characterized in that The broadcast message further includes a first service identifier, where the first service identifier is used to indicate the first service.

15. The method according to claim 14, characterized in that The first service identifier is a challenge code.

16. The method according to claim 14 or 15, characterized in that The method further comprises: The second terminal device transmits verification information to the first terminal device, where the verification information is used to determine whether the Bluetooth connection between the first terminal device and the second terminal device is successful.

17. The method according to claim 16, characterized in that The verification information includes: the first service identifier and / or the second service identifier, where the second service identifier is sent by the second terminal device and is used to indicate the first service.

18. The method according to claim 17, characterized in that The verification information further includes: a device identification of the first terminal device and / or a device identification of the second terminal device.

19. The method according to any one of claims 16 to 18, characterized in that The second terminal device transmitting verification information to the first terminal device includes: The second terminal device sends a second service identifier and a device identifier of the second terminal device to the first terminal device, where the second service identifier is used to indicate the first service.

20. The method according to claim 19, characterized in that The second terminal device transmits verification information to the first terminal device, further comprising: The second terminal device receives the device identification of the first terminal device sent by the first terminal device.

21. The method according to any one of claims 13 to 20, characterized in that The method further comprises: The second terminal device obtains the device identification of the first terminal device.

22. The method according to claim 21, characterized in that The second terminal device obtaining the device identification of the first terminal device includes: The second terminal device performs networking authentication with the first terminal device; The second terminal device receives first networking information sent by the first terminal device, where the first networking information includes a device identifier of the first terminal device.

23. The method according to claim 22, characterized in that The method further comprises: The second terminal device sends second networking information to the first terminal device, where the second networking information includes a device identifier of the second terminal device.

24. The method according to any one of claims 13 to 23, characterized in that Before the second terminal device sends a connection request message to the first terminal device, the method further includes: The second terminal device sends a scan request message to the first terminal device; The second terminal device receives the scan response message sent by the first terminal device.

25. A terminal device, characterized in that: The method comprises a processor, wherein the processor is coupled to a memory, reads instructions in the memory, and causes the terminal device to execute the method according to any one of claims 1 to 12, or execute the method according to any one of claims 13 to 24.

26. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on a terminal device, the terminal device executes the method according to any one of claims 1 to 12, or executes the method according to any one of claims 13 to 24.