Bluetooth connection method and related device
By introducing a private Bluetooth protocol between Bluetooth devices, the problem of device connection relies on the same network environment in the prior art is solved, and the seamless flow of multimedia data across networks is realized, and the device interconnection process is simplified.
Patent Information
- Application Number
- CN202510717482.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-07-11
AI Technical Summary
The interconnection of existing Bluetooth devices relies on dual-end system services, which leads to the device connection being heavily dependent on the same network environment, and requires the integration of corresponding SDKs and first pairing processes, limiting the flow of multimedia data across networks.
Through the private Bluetooth protocol between the first application and the second application, the Bluetooth connection method is realized, including sending playback and flow requests, establishing a private Bluetooth client and server, performing device type identification and secure connection, reducing dependence on public Bluetooth modules, and realizing multimedia data flow across networks.
There is no need for dual-end devices to connect to the same LAN, and seamless content flow across the network is achieved through private Bluetooth protocol, reducing duplicate operations, and simplifying the device interconnection process.
Smart Images

Figure CN120302270A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Bluetooth communication technology, and particularly to a Bluetooth connection method and related devices. Background Art
[0002] Currently, the interconnection between mobile devices and Bluetooth devices is mainly achieved through corresponding Bluetooth audio protocols or screen mirroring protocols. When the dual-end devices are interconnected based on the Bluetooth protocol, they have a high dependence on the dual-end system services. Under this limitation, when the dual-end system realizes the transfer of playback content at the client level, it highly depends on the two devices being connected to the same network environment.
[0003] Taking the Bluetooth interconnection between a mobile phone and a vehicle system as an example, the interconnection between the mobile phone and the vehicle system is mainly achieved through Bluetooth audio protocols (such as A2DP) or vehicle screen mirroring protocols (such as CarPlay, Android Auto, Hi Car) that are supported by both ends simultaneously. The client running on the mobile terminal needs to integrate the corresponding SDK to enable the mobile terminal, the client, and the vehicle system to support the corresponding Bluetooth protocol, and the two ends need to actively pair during the first connection. Summary of the Invention
[0004] In view of the above problems, this application provides a Bluetooth connection method and related devices to achieve. The specific solutions are as follows:
[0005] In a first aspect of this application, a Bluetooth connection method is provided, which is applied to a Bluetooth connection system. The Bluetooth connection system includes: a first terminal device running a first application and a second terminal device running a second application. The Bluetooth connection method includes:
[0006] The first application sends a playback transfer request to the first private Bluetooth server of the second application through the first private Bluetooth client; wherein, the playback transfer request includes the MAC address of the first terminal device;
[0007] The second application receives the playback transfer request through the first private Bluetooth server and starts the second private Bluetooth server;
[0008] The second application sends transfer confirmation information to the first private Bluetooth client through the first private Bluetooth server and listens to the first application through the second private Bluetooth server; wherein, the transfer confirmation information includes the unique identifier of the second terminal device and the universally unique identifier of the second private Bluetooth server;
[0009] After receiving the transfer confirmation information through the first private Bluetooth client, the first application creates a second private Bluetooth client according to the universally unique identifier of the second private Bluetooth server;
[0010] The first application sends a second private Bluetooth connection request to the second private Bluetooth server through the second private Bluetooth client;
[0011] The second application receives the second private Bluetooth connection request through the second private Bluetooth server. If it is determined that a secure connection has not been established, a secure connection request is sent to the first application through the second public Bluetooth module;
[0012] The first application receives the secure connection request through the first public Bluetooth module and obtains a connection instruction. If the connection instruction is an accept connection instruction, a secure connection is established with the second terminal device, and the streaming playback information of the target multimedia is sent to the second private Bluetooth server through the second private Bluetooth client.
[0013] The second application plays the target multimedia based on the streaming playback information.
[0014] In a possible implementation, the Bluetooth connection method further includes:
[0015] The first application obtains a list of discovered devices, a list of paired devices, and a list of historical connected devices. The list of discovered devices includes at least one real-time online device, the list of paired devices includes at least one paired device, and the list of historical connected devices includes at least one historical connected device;
[0016] The first application traverses the list of discovered devices, detects whether the device type of each real-time online device is the target type, and adds the real-time online devices of the target type to the list of online devices;
[0017] The first application merges the list of paired devices and the list of historical connected devices, and after filtering the real-time online devices, obtains a list of devices to be detected. The list of devices to be detected includes at least one device to be detected;
[0018] The first application traverses the list of devices to be detected, detects the connection status of each device to be detected with the first terminal device, and adds the devices to be detected that are in a connected state with the first terminal device to the list of online devices.
[0019] In a possible implementation, the Bluetooth connection method further includes:
[0020] For each device to be detected that is not in a connected state with the first terminal device, the first application sends a first private Bluetooth connection request to the device to be detected, so that the device to be detected responds to the first private Bluetooth connection request through the first private Bluetooth server;
[0021] If the device to be detected successfully responds to the first private Bluetooth connection request and establishes a first private Bluetooth connection with the first terminal device, the first application uses the device to be detected as a candidate online device;
[0022] For each device to be detected that is in a non - connected state with the first terminal device and fails to respond to the connection request of the first private Bluetooth server, the first application sends a public Bluetooth connection request to the device to be detected through the first public Bluetooth module. If the device to be detected responds to the public Bluetooth connection request and establishes a public Bluetooth connection with the first terminal device, the device to be detected is used as a candidate online device;
[0023] For each candidate online device, the first application determines whether the device type of the candidate online device is the target type. If so, the candidate online device is added to the online device list.
[0024] In a possible implementation, the Bluetooth connection method further includes:
[0025] The first application pushes Bluetooth connection prompt information and the online device list, and disconnects the Bluetooth connections with all target online devices in the online device list.
[0026] In a possible implementation, before the first application sends a play transfer request to the first private Bluetooth server of the second application through the first private Bluetooth client, the Bluetooth connection method further includes:
[0027] The first application receives a play transfer indication, and the play transfer indication includes the unique identifier of the second terminal device;
[0028] The first application establishes a first private Bluetooth client according to the unique identifier of the second terminal device;
[0029] The first application sends a first private Bluetooth connection request to the second application through the first private Bluetooth client;
[0030] The second application receives the first private Bluetooth connection request through the first private Bluetooth server and establishes a connection with the first private Bluetooth client.
[0031] In a possible implementation, after the first application receives the secure connection request and obtains the connection instruction through the first public Bluetooth module, the Bluetooth connection method further includes:
[0032] The first application responds to the reject connection instruction, issues a reject pairing indication and displays a re - pairing indication message;
[0033] After receiving the rejection pairing instruction, the second application closes the second private Bluetooth server.
[0034] A second aspect of the present application provides a Bluetooth connection system, including: a first terminal device and a second terminal device. A first application runs in the first terminal device and is used to implement the first aspect or any implementation manner of the first aspect. A second application runs in the second terminal device, and the second application is used to implement the first aspect or any implementation manner of the first aspect.
[0035] A third aspect of the present application provides a computer program product, including computer-readable instructions. When the computer-readable instructions run on an electronic device, the electronic device is enabled to implement the Bluetooth connection method of the first aspect or any implementation manner of the first aspect.
[0036] A fourth aspect of the present application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:
[0037] The memory is used to store a computer program;
[0038] The processor is used to execute the computer program so that the electronic device can implement the Bluetooth connection method of the first aspect or any implementation manner of the first aspect.
[0039] A fifth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the Bluetooth connection method of the first aspect or any implementation manner of the first aspect.
[0040] With the above technical solution, a Bluetooth connection method and related device provided by the present application, a first application sends a playback transfer request to a first private Bluetooth server of a second application through a first private Bluetooth client. The second application receives the playback transfer request through the first private Bluetooth server and starts a second private Bluetooth server. The second application sends transfer confirmation information to the first private Bluetooth client through the first private Bluetooth server and listens to the first application through the second private Bluetooth server. After receiving the transfer confirmation information through the first private Bluetooth client, the first application creates a second private Bluetooth client according to the universal unique identifier of the second private Bluetooth server, and sends a second private Bluetooth connection request to the second private Bluetooth server through the second private Bluetooth client. The second application receives the second private Bluetooth connection request through the second private Bluetooth server. If it is determined that a secure connection has not been established, a secure connection request is sent to the first application through a second public Bluetooth module. The first application receives the secure connection request through the first public Bluetooth module and obtains a connection instruction. If the connection instruction is an accept connection instruction, a secure connection is established with the second terminal device, and transfer playback information of the target multimedia is sent to the second private Bluetooth server through the second private Bluetooth client. The second application plays the target multimedia based on the transfer playback information. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In combination with the accompanying drawings and with reference to the following specific embodiments, the above and other features, advantages and aspects of the various embodiments of the present disclosure will become more obvious. Throughout the accompanying drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic and the original and elements are not necessarily drawn to scale.
[0042] Figure 1 FIG. is a schematic structural diagram of a Bluetooth connection system provided by an embodiment of the present application;
[0043] Figure 2 FIG. is a schematic flowchart of a Bluetooth connection method provided by an embodiment of the present application;
[0044] Figure 3 FIG. is a specific implementation flowchart of a Bluetooth connection method provided by an embodiment of the present application;
[0045] Figure 4 FIG. is a specific implementation flowchart of another Bluetooth connection method provided by an embodiment of the present application;
[0046] Figure 5 FIG. is a specific implementation flowchart of a Bluetooth connection system provided by an embodiment of the present application;
[0047] Figure 6 FIG. is a schematic structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0048] The embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application. The terms used in the embodiments of the present application are only used to explain the specific embodiments of the present application, rather than to limit the present application.
[0049] The embodiments of the present application will be described below with reference to the accompanying drawings. Those of ordinary skill in the art will know that with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
[0050] The terms "first", "second", etc. in the specification, claims and above-mentioned accompanying drawings of the present application are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that such terms can be interchanged under appropriate circumstances, which is only a way of distinguishing when describing objects with the same attributes in the embodiments of the present application. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion, so that a process, method, system, product or device including a series of units does not have to be limited to those units, but may include other units not clearly listed or inherent to these processes, methods, products or devices.
[0051] The present application can be applied in the field of wireless communication technology. Specifically, it can be applied to the communication scenario of dual-terminal devices based on Bluetooth to achieve application-level Bluetooth connection. Figure 1 The following is a schematic structural diagram of a Bluetooth connection system provided by an embodiment of the present application, as Figure 1 shown, the system includes a first terminal device and a second terminal device. A public Bluetooth module providing public Bluetooth communication services is configured in both the first terminal device and the second terminal device, namely a first public Bluetooth module and a second public Bluetooth module respectively. The first public Bluetooth module and the second public Bluetooth module communicate with each other through a preset public Bluetooth protocol. For details, reference can be made to the prior art.
[0052] In this embodiment, the first terminal device and the second terminal device may each include, but are not limited to, mobile terminals such as mobile phones, laptop computers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), etc., or fixed terminals such as desktop computers, multimedia large screens, in-vehicle devices, etc.
[0053] As Figure 1 shown, a first application runs on the first terminal device, and a second application runs on the second terminal device. The first application provides target multimedia data as a client application, and the second application realizes the transfer and playback of multimedia data as a server application. The embodiments of the present application provide a Bluetooth connection method, aiming to achieve Bluetooth connection between the first application and the second application based on the private Bluetooth protocol between the first application and the second application.
[0054] See Figure 2 , Figure 2 which is a schematic flowchart of a Bluetooth connection method provided by an embodiment of the present application. This method is applied to a Bluetooth connection system as shown in Figure 1 and, as shown in Figure 2 , this method includes:
[0055] S201. The first application sends a play transfer request to the first private Bluetooth server of the second application through the first private Bluetooth client.
[0056] In this embodiment, the play transfer request includes the unique identifier of the first terminal device, for example, the MAC address. The second application is the second application running on the second terminal device.
[0057] S202. The second application receives the play transfer request through the first private Bluetooth server and starts the second private Bluetooth server.
[0058] S203. The second application sends transfer confirmation information to the first private Bluetooth client through the first private Bluetooth server and listens to the first application through the second private Bluetooth server.
[0059] In this embodiment, the transfer confirmation information includes the unique identifier of the second terminal device, that is, the MAC address and the Universally Unique Identifier (UUID) of the second private Bluetooth server. Optionally, the transfer confirmation information further includes the device type.
[0060] S204. After the first application receives the transfer confirmation information sent by the second terminal device through the first private Bluetooth client, it creates a second private Bluetooth client according to the UUID of the second private Bluetooth server.
[0061] S205. The first application sends a second private Bluetooth connection request to the second private Bluetooth server through the second private Bluetooth client.
[0062] S206. The second application receives the second private Bluetooth connection request through the second private Bluetooth server. If it determines that a secure connection has not been established, it sends a secure connection request to the first application through the second public Bluetooth module.
[0063] S207. The first application receives the secure connection request through the first public Bluetooth module and obtains the connection instruction. If the connection instruction is an accept connection instruction, it establishes a secure connection with the second terminal device and sends the transfer play information of the target multimedia to the second private Bluetooth server through the second private Bluetooth client, so that the second application plays the target multimedia based on the transfer play information.
[0064] As can be seen from the above technical solution, in the Bluetooth connection method provided by the embodiment of the present application, the second private Bluetooth client and the second private Bluetooth server communicate through the second private Bluetooth protocol to achieve cross-network multimedia data transfer between devices. It is not necessary for the first terminal device and the second terminal device to be connected to the same local area network. The media resource information and playback status of the target multimedia are transmitted through the second private Bluetooth protocol between the second private Bluetooth client and the second private Bluetooth server, so as to achieve cross-network and cross-device content continuous playback, reduce repeated operations, and thus achieve seamless cross-network content transfer.
[0065] Further, Figure 3 The following is the specific implementation process of the Bluetooth connection method provided by the embodiment of the present application. As Figure 3 shown, this method specifically includes:
[0066] S301. After the first application is started and the home page content is loaded, obtain the discovered device list, paired device list, and historical connection device list.
[0067] In this embodiment, the discovered device list D1 includes at least one real-time online device. The real-time online device refers to the terminal device discovered by the first public Bluetooth module of the first terminal device. It can be understood that the real-time online device has enabled the public Bluetooth service and is configured to be discoverable.
[0068] In this embodiment, the paired device list D2 includes at least one paired device. The paired device refers to the terminal device in a Bluetooth paired state with the first terminal device.
[0069] It should be noted that the first application scans through the Bluetooth communication service of the first public Bluetooth module to obtain at least one real-time online device to generate the discovered device list, and obtains the paired device list from the historical pairing device information. The first public Bluetooth module is used to provide the Bluetooth communication service and maintain the discovered device list and the paired device list.
[0070] In this embodiment, the historical connection device list D3 includes at least one historical connection device. The historical connection device refers to the terminal device that has achieved Bluetooth connection through the first private Bluetooth server of the second application and the first private Bluetooth client of the first application before the current moment. It should be noted that the historical connection device list is saved and maintained by the first application.
[0071] S302. The first application traverses the discovered device list, detects whether the device type of each real-time online device is the target type, and adds the real-time online device of the target type as the target online device to the online device list.
[0072] In this embodiment, the target type is one or more of the preset types of terminal devices that can configure the second application. The target type is usually preset based on the application scenario. For example, in the scenario of automatic identification of in-vehicle Bluetooth, the target type is an in-vehicle device; in the scenario of automatic identification of a large screen, the target type is a large-screen Bluetooth device.
[0073] In this embodiment, there are various methods for detecting whether a real-time online device is of the target type according to the target type.
[0074] A1. When the target type is an in-vehicle device, the method for determining whether a real-time online device is an in-vehicle device includes:
[0075] Obtain the cached historical list of in-vehicle devices, and determine whether the real-time online device is an in-vehicle device through the Bluetooth device classification information and the MAC address of the real-time online device.
[0076] Or, determine whether the real-time online device is an in-vehicle device through the historical list of in-vehicle devices. The historical list of in-vehicle devices includes the MAC addresses of the historically connected in-vehicle devices. If the MAC address of the real-time online device is in the historical list of in-vehicle devices, it is determined that the real-time online device is an in-vehicle device.
[0077] A2. When the target type is a large-screen device, the method for determining whether a real-time online device is a large-screen device includes:
[0078] Obtain the cached historical list of large-screen devices, and determine whether the real-time online device is a large-screen device through the Bluetooth device classification information and the MAC address of the real-time online device.
[0079] Or, determine whether the real-time online device is a large-screen device through the historical list of large-screen devices. The historical list of large-screen devices includes the MAC addresses of the historically connected large-screen devices. If the MAC address of the real-time online device is in the historical list of large-screen devices, it is determined that the real-time online device is a large-screen device.
[0080] S303. The first application obtains the list of devices to be detected, traverses the list of devices to be detected, detects the connection status of each device to be detected with the first terminal device, and adds the device to be detected that is in a connected state with the first terminal device as a target online device to the online device list.
[0081] In this embodiment, the first application merges the paired device list and the historical connection device list to obtain an intermediate list, de-duplicates the intermediate list and filters out the real-time online devices to obtain the list of devices to be detected. The list of devices to be detected includes at least one device to be detected. It can be understood that the device to be detected is a terminal device that belongs to the paired device list and / or the historical connection device list and does not belong to the discovered device list.
[0082] In this embodiment, if the first terminal device is an Android device, the connection status between the device to be detected and the first terminal device can be obtained through the reflection of BluetoothDevice.isConnected.
[0083] S304. For each device to be detected that is in a non-connected state with the first terminal device, the first application sends a first private Bluetooth connection request to the device to be detected. If the device to be detected successfully responds to the first private Bluetooth connection request and establishes a first private Bluetooth connection with the first terminal device, the device to be detected is used as a candidate online device.
[0084] In this embodiment, for each device to be detected that is in a non-connected state with the first terminal device, the first application sends a first private Bluetooth connection request to the device to be detected, so that the second application of the device to be detected responds to the first private Bluetooth connection request through the first private Bluetooth server.
[0085] S305. For each device to be detected that is in a non-connected state with the first terminal device and fails to respond to the connection request of the first private Bluetooth server, the first application sends a GATT connection request to the device to be detected through the first public Bluetooth module. If the device to be detected responds to the GATT connection request and establishes a GATT connection with the first terminal device, the device to be detected is used as a candidate online device.
[0086] In this embodiment, the GATT connection request is a public Bluetooth connection request.
[0087] S306. For each candidate online device, the first application determines whether the device type of the candidate online device is the target type. If so, the candidate online device is added to the online device list as the target online device.
[0088] S307. The first application pushes the Bluetooth connection prompt information and the online device list, and disconnects the Bluetooth connection with all target online devices.
[0089] In this embodiment, the first application sends the Bluetooth connection prompt information and displays the online device list to prompt the user of the first application to select a target online device to enter the play transfer service.
[0090] In this embodiment, the list information of the online device list includes the device MAC (Media Access Control) address, device name, device classification parameter CoD, and universal unique identifier UUID of each target online device. It can be seen from the above technical solution that a Bluetooth connection method provided by an embodiment of the present application enables a first private Bluetooth client and a first private Bluetooth server to communicate through a first private RFCOMM protocol, and realizes the perception of the interconnection environment by probing online based on the discovered device list, paired device list, and historical connection device list. Specifically, by judging the connection status and target type of each terminal device in the three types of device lists obtained, the devices available for connection at present, that is, the target online devices, are identified.
[0091] Referring to Figure 4 Figure 4 FIG. is a schematic flowchart of another Bluetooth connection method provided by an embodiment of the present application. As Figure 4 shown, this method specifically includes:
[0092] S401. The first application receives a play transfer instruction.
[0093] In this embodiment, the play transfer instruction includes the device MAC address and device name of the second terminal device, and is used to indicate that the target multimedia is played through the second terminal device, where the second terminal device is a target online device selected by the user, and the target multimedia is the multimedia played in real time by the first application. Optionally, the type of the target multimedia is audio or video.
[0094] S402. The first application establishes a first private Bluetooth client according to the device MAC address of the second terminal device.
[0095] S403. The first application sends a first private Bluetooth connection request to the second terminal device through the first private Bluetooth client until the first private Bluetooth client is successfully connected to the second terminal device.
[0096] S404. After the second application of the second terminal device is started, a first private Bluetooth server is started, and the first private Bluetooth connection request is listened to through the first private Bluetooth server.
[0097] S405. The second application receives the first private Bluetooth connection request through the first private Bluetooth server and establishes a connection with the first private Bluetooth client.
[0098] S406. After the first private Bluetooth client is successfully connected to the first private Bluetooth server, the first application sends a play transfer request to the first private Bluetooth server of the second application through the first private Bluetooth client.
[0099] In this embodiment, after the first private Bluetooth client successfully connects to the first private Bluetooth server, data can be sent bidirectionally between the first private Bluetooth client and the first private Bluetooth server based on the first private Bluetooth protocol.
[0100] In this embodiment, the play transfer request carries a timestamp, the device name of the first terminal device, the MAC address of the first terminal device, and the device type of the first terminal device.
[0101] S407. The second application receives the play transfer request through the first private Bluetooth server and starts the second private Bluetooth server.
[0102] S408. The second application sends transfer confirmation information to the first private Bluetooth client through the first private Bluetooth server and listens to the first application through the second private Bluetooth server.
[0103] In this embodiment, the transfer confirmation information includes a timestamp, the device name of the second terminal device, the MAC address of the second terminal device, the device type (such as the device type parameter CoD), and the UUID of the second private Bluetooth server.
[0104] S409. After the first application receives the transfer confirmation information sent by the second terminal device through the first private Bluetooth client, it creates a second private Bluetooth client according to the UUID of the second private Bluetooth server.
[0105] Optionally, after the first application receives the transfer confirmation information sent by the second terminal device through the first private Bluetooth client, it can also store the device name, MAC address, and device type of the second terminal device in the historical connection device list.
[0106] S410. The first application sends a second private Bluetooth connection request to the second private Bluetooth server through the second private Bluetooth client.
[0107] In this embodiment, the second private Bluetooth connection request includes the MAC address of the second terminal device.
[0108] S411. The second application receives the second private Bluetooth connection request through the second private Bluetooth server, determines whether a secure connection has been established between the first terminal device and the second terminal device. If a secure connection has not been established, execute S412; if a secure connection has been established, execute S416.
[0109] S412. If a secure connection has not been established, the second application sends a secure connection request to the first application through the second public Bluetooth module.
[0110] In this embodiment, the secure connection request includes the MAC address of the first terminal device and the Bluetooth pairing code.
[0111] S413. The first application receives a secure connection request via the first common Bluetooth module and obtains a connection instruction.
[0112] In this embodiment, the first application receives and displays a secure connection request via the first common Bluetooth module, receives or automatically generates a connection instruction based on a Bluetooth pairing code. The connection instruction includes an accept connection instruction and a reject connection instruction.
[0113] S414. In response to the reject connection instruction, the first application issues a reject pairing indication and displays a re-pairing indication message.
[0114] That is, if the connection instruction is a reject connection instruction, the establishment of a secure connection between the first terminal device and the second terminal device fails.
[0115] In this embodiment, the re-pairing includes a pairing failure instruction and re-pairing information. The re-pairing information includes a list of online devices.
[0116] It should be noted that the specific method for the first application to issue a re-pairing indication message can refer to the above Figure 3 illustrated embodiment.
[0117] S415. After receiving the reject pairing indication, the second application closes the second private Bluetooth server.
[0118] In this embodiment, when the second application receives the reject pairing indication, indicating that the establishment of a secure connection between the first terminal device and the second terminal device fails, the second private Bluetooth server is closed.
[0119] S416. In response to the accept connection instruction, the first application establishes a secure connection with the second terminal device and sends streaming playback information to the second private Bluetooth server via the second private Bluetooth client.
[0120] In this embodiment, if the connection instruction is an accept connection instruction, the first application establishes a secure connection with the second terminal device via the first common Bluetooth module.
[0121] In this embodiment, the streaming playback information includes media asset information, playback status, and user login token information of the target multimedia.
[0122] S417. After receiving the streaming playback information via the second private Bluetooth server, the second application plays the target multimedia based on the media asset information and the playback status.
[0123] In this embodiment, the second private Bluetooth server and the second private Bluetooth client communicate via the second private Bluetooth protocol.
[0124] As can be seen from the above technical solutions, in a Bluetooth connection method provided by an embodiment of the present application, a second private Bluetooth client and a second private Bluetooth server communicate through a second private RFCOMM protocol to achieve cross-network multimedia data transfer between devices. It is not necessary for the first terminal device and the second terminal device to be connected to the same local area network. The media resource information and the playback status are transmitted through the second private Bluetooth protocol between the second private Bluetooth client and the second private Bluetooth server, so as to achieve cross-network and cross-device content continuation playback, reduce repeated operations, and thus achieve seamless cross-network content transfer.
[0125] Further, taking the mobile device as a mobile phone and the Bluetooth device as a vehicle-mounted Bluetooth device as an example, Figure 5 The following is a schematic structural diagram of a Bluetooth connection system provided by an embodiment of the present application. This system includes a mobile phone and a vehicle-mounted Bluetooth device. Both the mobile phone and the vehicle-mounted Bluetooth device are configured with a public Bluetooth module that provides public Bluetooth communication services, namely a first public Bluetooth module and a second public Bluetooth module. The first public Bluetooth module is used to provide the public Bluetooth communication service of the mobile phone system, and the second public Bluetooth module is used to provide the public Bluetooth communication service of the vehicle-mounted system.
[0126] Based on Figure 5 the Bluetooth connection system shown above, when entering the vehicle-mounted and large-screen interconnection environment, after the first application of the mobile phone is started, the detection process is automatically triggered. Or, when the first application of the mobile phone is playing a video and it is detected that the user clicks the screen mirroring button, the detection process is actively triggered. The detection process is also referred to the above 301~307. Through the non-secure Bluetooth client (i.e., the first private Bluetooth client) in the mobile application and the non-secure Bluetooth server (i.e., the first private Bluetooth server) in the vehicle-mounted application, an online device list is generated based on the discovered device list, the paired device list, the historical connection device list, and the online probing results.
[0127] The first application of the mobile phone detects that the user clicks the Bluetooth device screen mirroring instruction, and the Bluetooth device screen mirroring instruction includes a playback transfer instruction, such as opening the vehicle-mounted application of the vehicle-mounted Bluetooth device to achieve playback transfer. After the vehicle-mounted application of the vehicle-mounted Bluetooth device is started and it is detected that the non-secure Bluetooth server receives the playback transfer request, the second private Bluetooth server is started.
[0128] After the vehicle-mounted application starts the second private Bluetooth server, through the secure Bluetooth client (i.e., the second private Bluetooth client) in the mobile application and the secure Bluetooth server (i.e., the second private Bluetooth server) in the vehicle-mounted application, referring to S405~S407, the video transfer playback is achieved.
[0129] It should be noted that after the second application in S407 receives the play transfer request through the first private Bluetooth server, the login status of the in-vehicle application can also be judged. If it is safe, the non-safe Bluetooth server (i.e., the first private Bluetooth server) can be directly used to receive the media information and play status of the target multimedia, so as to achieve safe continuous playback. If it is not safe, the second private Bluetooth server is started.
[0130] It should be noted that taking the scenario of the interconnection between the mobile phone system and the in-vehicle system as an example, in the traditional Bluetooth connection method, the interconnection between the mobile phone and the in-vehicle system is mainly achieved through the in-vehicle screen mirroring protocols supported by both ends (such as CarPlay, Android Auto, HiCar), that is, the mobile and in-vehicle systems need to support the corresponding protocols, and the client running on the mobile terminal needs to integrate the corresponding protocol SDK to achieve the interconnection of the two ends of the client and realize functions such as account and play transfer. And the first connection between the two ends requires an active pairing process. That is to say, the traditional Bluetooth connection method depends on system protocol support, the application needs to be customized and integrated with the corresponding protocol SDK, and the first pairing process is required.
[0131] It can be seen from the above technical solutions that a Bluetooth connection method provided by an embodiment of the present application realizes the perception of the interconnection environment through the non-safe private RFCOMM protocol (i.e., the first private Bluetooth protocol) and the online probing of the paired Bluetooth devices, and realizes the cross-network data transfer between devices through the safe RFCOMM protocol (i.e., the second private Bluetooth protocol). Specifically, through the Bluetooth device classification information and the private protocol based on the non-safe Bluetooth RFCOMM connection, the in-vehicle or large-screen environment can be determined without user intervention and prior Bluetooth device binding, so as to realize the Bluetooth environment perception. Further, without the first terminal device and the second terminal device being connected to the same local area network, the account and play status are transmitted through the private service, so as to realize the cross-network and cross-device content continuous playback, reduce repeated operations, and thus realize the seamless cross-network content transfer.
[0132] In summary, a Bluetooth connection method provided by an embodiment of the present application can overcome the technical disadvantages of the traditional Bluetooth connection method that depends on system protocol support, the application needs to be customized and integrated with the corresponding protocol SDK (Software Development Kit), and the first pairing process is required.
[0133] The above introduces a Bluetooth connection method provided by an embodiment of the present application. The following will introduce the electronic device that executes the above Bluetooth connection method. Refer to Figure 6 as shown Figure 6It shows a schematic structural diagram of an electronic device suitable for implementing the electronic device in the embodiments of the present application. The electronic device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), etc., or fixed terminals such as desktop computers, large multimedia screens, in-vehicle devices, etc. Figure 6 The shown electronic device is merely an example and should not impose any limitations on the functions and usage scope of the embodiments of the present application.
[0134] As Figure 6 shown, the electronic device may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage device 608 into the random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.
[0135] Generally, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 6 the shown electronic device has various devices, it should be understood that it is not required to implement or have all the shown devices. More or fewer devices may be alternatively implemented or had.
[0136] The embodiments of the present application also provide a computer program product including computer-readable instructions, which, when running on an electronic device, enable the electronic device to implement any one of the Bluetooth connection methods provided by the embodiments of the present application.
[0137] The embodiments of the present application also provide a computer-readable storage medium carrying one or more computer programs, which, when executed by an electronic device, can enable the electronic device to implement any one of the Bluetooth connection methods provided by the embodiments of the present application.
[0138] In addition, it should be noted that the device embodiments described above are only illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the attached drawings of the device embodiments provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be specifically implemented as one or more communication buses or signal lines.
[0139] Through the description of the above embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general hardware. Of course, it can also be implemented by dedicated hardware, including application-specific integrated circuits, dedicated CPUs, dedicated memories, dedicated components, etc. Generally, functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structures used to implement the same function can also be various, such as analog circuits, digital circuits or dedicated circuits. However, in more cases of this application, software program implementation is a better implementation method. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disc of a computer, and includes several instructions to enable a computer device (which can be a personal computer, training device, or network device, etc.) to execute the methods described in various embodiments of this application.
[0140] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product.
[0141] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are wholly or partially generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center by wired means (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless means (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that includes one or more integrated available media. The available medium may be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
Claims
1. A Bluetooth connection method, applied to a Bluetooth connection system, characterized in that, The Bluetooth connection system includes: a first terminal device running a first application and a second terminal device running a second application. The Bluetooth connection method includes: The first application sends a playback transfer request to the first private Bluetooth server of the second application through a first private Bluetooth client; wherein, the playback transfer request includes the unique identifier of the first terminal device; The second application receives the playback transfer request through the first private Bluetooth server and starts a second private Bluetooth server; The second application sends transfer confirmation information to the first private Bluetooth client through the first private Bluetooth server and monitors the first application through the second private Bluetooth server; wherein, the transfer confirmation information includes the unique identifier of the second terminal device and the universally unique identifier of the second private Bluetooth server; After receiving the transfer confirmation information through the first private Bluetooth client, the first application creates a second private Bluetooth client according to the universally unique identifier of the second private Bluetooth server; The first application sends a second private Bluetooth connection request to the second private Bluetooth server through the second private Bluetooth client; The second application receives the second private Bluetooth connection request through the second private Bluetooth server. If it is determined that a secure connection has not been established, a secure connection request is sent to the first application through a second public Bluetooth module; The first application receives the secure connection request through a first public Bluetooth module and obtains a connection instruction. If the connection instruction is an accept connection instruction, a secure connection is established with the second terminal device, and transfer playback information of the target multimedia is sent to the second private Bluetooth server through the second private Bluetooth client; The second application plays the target multimedia based on the transfer playback information.
2. The Bluetooth connection method according to claim 1, wherein, The Bluetooth connection method further includes: The first application obtains a list of discovered devices, a list of paired devices, and a list of historical connection devices. The list of discovered devices includes at least one real-time online device, the list of paired devices includes at least one paired device, and the list of historical connection devices includes at least one historical connection device; The first application traverses the list of discovered devices, detects whether the device type of each real-time online device is the target type, and adds the real-time online devices of the target type to the list of online devices; The first application merges the list of paired devices and the list of historical connection devices, and after filtering the real-time online devices, obtains a list of devices to be detected. The list of devices to be detected includes at least one device to be detected; The first application traverses the list of devices to be detected, detects the connection status of each device to be detected with the first terminal device, and adds the devices to be detected that are in a connected state with the first terminal device to the list of online devices.
3. The Bluetooth connection method according to claim 2, wherein The Bluetooth connection method further includes: For each of the devices to be detected that are in a non - connected state with the first terminal device, the first application sends a first private Bluetooth connection request to the device to be detected, so that the device to be detected responds to the first private Bluetooth connection request through a first private Bluetooth server; If the device to be detected successfully responds to the first private Bluetooth connection request and establishes a first private Bluetooth connection with the first terminal device, the first application takes the device to be detected as a candidate online device; For each of the devices to be detected that are in a non - connected state with the first terminal device and fail to respond to the connection request of the first private Bluetooth server, the first application sends a public Bluetooth connection request to the device to be detected through a first public Bluetooth module. If the device to be detected responds to the public Bluetooth connection request and establishes a public Bluetooth connection with the first terminal device, the device to be detected is taken as a candidate online device; For each candidate online device, the first application determines whether the device type of the candidate online device is the target type. If so, the candidate online device is added to the online device list.
4. The Bluetooth connection method according to claim 2 or 3, wherein The Bluetooth connection method further includes: The first application pushes Bluetooth connection prompt information and the online device list, and disconnects the Bluetooth connections with all target online devices in the online device list.
5. The Bluetooth connection method according to claim 1, wherein Before the first application sends a play stream transfer request to the first private Bluetooth server of the second application through a first private Bluetooth client, the Bluetooth connection method further includes: The first application receives a play stream transfer indication, and the play stream transfer indication includes the unique identifier of the second terminal device; The first application establishes a first private Bluetooth client according to the unique identifier of the second terminal device; The first application sends a first private Bluetooth connection request to the second application through the first private Bluetooth client; The second application receives the first private Bluetooth connection request through the first private Bluetooth server and establishes a connection with the first private Bluetooth client.
6. The Bluetooth connection method according to claim 1, wherein After the first application receives the secure connection request and obtains a connection instruction through a first public Bluetooth module, the Bluetooth connection method further includes: The first application responds to the reject connection instruction, sends a reject pairing indication and displays a re - pairing indication message; After receiving the reject pairing indication, the second application closes the second private Bluetooth server.
7. A Bluetooth connection system, characterized in that, Includes: A first terminal device and a second terminal device. The first application as described in any one of claims 1 to 6 runs in the first terminal device, and the second application as described in any one of claims 1 to 6 runs in the second terminal device.
8. A computer program product, characterized in that, Includes computer - readable instructions that, when running on an electronic device, enable the electronic device to implement the Bluetooth connection method as described in any one of claims 1 to 6.
9. An electronic device, characterized in that, Includes at least one processor and a memory connected to the processor, wherein: The memory is used to store a computer program; The processor is used to execute the computer program so that the electronic device can implement the Bluetooth connection method as described in any one of claims 1 to 6.
10. A computer storage medium, characterized in that, The storage medium carries one or more computer programs, which, when executed by an electronic device, can enable the electronic device to implement the Bluetooth connection method described in any one of claims 1 to 6.