A Bluetooth connection method, system, intelligent terminal and computer storage medium
Through the smart terminal, the services of Bluetooth devices and the optimization of connection process are solved, and the connection failure and disconnection of Bluetooth devices are achieved, faster connection speed and higher compatibility are achieved.
Patent Information
- Application Number
- CN202011465205.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-14
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2040-12-14
AI Technical Summary
In the prior art, smart terminals are prone to failure or disconnection when connecting to Bluetooth devices, especially when Bluetooth devices support multiple protocols at the same time, the connection speed is slow and easy to conflict.
Actively obtain the services of Bluetooth devices through smart terminals, obtain the device subtype, select the services that need to be connected, and send audio input service requests and encryption instructions to optimize the connection process to improve compatibility and universality.
It improves the binding connection speed of Bluetooth devices, improves the compatibility and versatility of Bluetooth devices, and provides a good user experience.
Smart Images

Figure CN114630303B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Bluetooth connection, and in particular to a Bluetooth connection method, system, intelligent terminal and computer storage medium. Background Art
[0002] Bluetooth is a radio technology that enables short-range communication between devices, effectively simplifying data and voice communications between mobile devices. With the growing demand for wireless devices, a growing number of smart Bluetooth speakers, headsets, and other devices are now available. To use various Bluetooth device features, such as playing music, you first need to pair with the device to establish a wireless link.
[0003] Currently, when using BR (Basic Rate) devices (i.e., Bluetooth devices) such as Bluetooth speakers, smart terminals (such as smart TVs or smart phones) initiate Bluetooth scanning to scan for nearby Bluetooth speakers that are broadcasting, discoverable, and connectable. When the smart device scans the Bluetooth speaker, it initiates a pairing and binding connection to establish a wireless link connection between the smart terminal and the Bluetooth speaker. After the binding is successful, the smart terminal and the Bluetooth speaker distribute the key negotiated during the binding process. The smart terminal then obtains the service attributes supported by the Bluetooth speaker through an SDP (Service Discovery Protocol, which provides a method for discovering services and the attributes of these available services) service discovery request.
[0004] When the Bluetooth device being connected supports multiple protocols at the same time and the smart terminal initiates connections, it is bound to cause slow connection speed and connection conflict, and ultimately lead to connection failure. In addition, when some Bluetooth speakers actively initiate service requests again, the smart terminal will not respond to the request or the response content is empty, which will cause the Bluetooth device to not receive a response or respond abnormally, eventually leading to timeout and disconnection.
[0005] Therefore, the existing technology still needs to be improved and developed. Summary of the Invention
[0006] The main purpose of the present invention is to provide a Bluetooth connection method, system, smart terminal and computer storage medium, aiming to solve the problem in the prior art that smart terminals and Bluetooth devices are prone to connection failure or disconnection.
[0007] To achieve the above object, the present invention provides a Bluetooth connection method, which includes the following steps:
[0008] Establish a connection and binding with a Bluetooth device to obtain the services supported by the Bluetooth device;
[0009] Obtaining a device subtype of the Bluetooth device, and selecting a service to be connected from services supported by the Bluetooth device according to the device subtype;
[0010] Sending an audio input service request to the Bluetooth device and receiving a response, receiving an audio output service request sent by the Bluetooth device, generating a response data packet and sending it to the Bluetooth device;
[0011] Send an encryption instruction to the Bluetooth device, start the audio receiving end service connected to the Bluetooth device after encryption is completed, and start audio transmission after the connection is successful.
[0012] Optionally, the Bluetooth connection method, wherein establishing a connection and binding with a Bluetooth device and obtaining services supported by the Bluetooth device, specifically includes:
[0013] Establishing a link connection with the Bluetooth device;
[0014] Sending a request to the Bluetooth device to obtain the input and output capabilities of the Bluetooth device, receiving the input and output capabilities fed back by the Bluetooth device according to the request, and selecting a binding method with the Bluetooth device according to the input and output capabilities;
[0015] After determining the binding method with the Bluetooth device, generate a key and send it to the Bluetooth device;
[0016] Send an SDP service discovery request to the Bluetooth device to obtain services supported by the Bluetooth device.
[0017] Optionally, the Bluetooth connection method, wherein obtaining the device subtype of the Bluetooth device and selecting a service to be connected from services supported by the Bluetooth device according to the device subtype, specifically includes:
[0018] Get the device subtype of the Bluetooth device;
[0019] If the device subtype is a Bluetooth speaker, actively sending a service request to the Bluetooth speaker, and receiving a service request response sent by the Bluetooth speaker;
[0020] Parsing the service request response, obtaining the identity value and storing it in a singly linked list;
[0021] The identity identification values in the singly linked list are traversed, and a service to be connected is selected from the services supported by the Bluetooth device.
[0022] Optionally, the Bluetooth connection method, wherein the sending of the audio input service request to the Bluetooth device and receiving a response, receiving the audio output service request sent by the Bluetooth device, and generating a response data packet to send to the Bluetooth device, specifically includes:
[0023] Sending an audio input service request to the Bluetooth device, and receiving and parsing a response from the Bluetooth device to the audio input service request;
[0024] If an audio output service request is received from the Bluetooth device, determining whether the audio receiving end service connection is enabled;
[0025] If it is turned on, the audio output record is obtained and the corresponding identity value is added, and a response data packet is generated and sent to the Bluetooth device.
[0026] Optionally, in the Bluetooth connection method, the step of determining whether the audio receiving end service connection is enabled further comprises:
[0027] If it is not enabled, the content of the response sent to the Bluetooth device will be empty.
[0028] Optionally, in the Bluetooth connection method, the step of obtaining the device subtype of the Bluetooth device further includes:
[0029] If the device subtype is not a Bluetooth speaker, obtain other service requests.
[0030] Optionally, in the Bluetooth connection method, the binding mode includes at least one of: numerical comparison, only working mode, out-of-band and password login.
[0031] In addition, to achieve the above-mentioned purpose, the present invention also provides a smart terminal, wherein the smart terminal includes: a memory, a processor, and a Bluetooth connection program stored in the memory and runnable on the processor, and when the Bluetooth connection program is executed by the processor, the steps of the Bluetooth connection method described above are implemented.
[0032] In addition, to achieve the above-mentioned object, the present invention further provides a Bluetooth connection system, wherein the system includes a Bluetooth device and the above-mentioned smart terminal, wherein the smart terminal and the Bluetooth device establish a connection and binding;
[0033] Wherein, the smart terminal is used to obtain the services supported by the Bluetooth device;
[0034] The smart terminal is further configured to obtain a device subtype of the Bluetooth device, and select a service to be connected from services supported by the Bluetooth device according to the device subtype;
[0035] The intelligent terminal is further configured to send an audio input service request to the Bluetooth device and receive a response;
[0036] The Bluetooth device is used to send an audio output service request to the smart terminal, and the smart terminal generates a response data packet and sends it to the Bluetooth device;
[0037] The smart terminal is further configured to send an encryption instruction to the Bluetooth device, start the audio receiving terminal service connected to the Bluetooth device after encryption is completed, and start audio transmission after the connection is successful.
[0038] In addition, to achieve the above-mentioned object, the present invention further provides a computer storage medium, wherein the computer storage medium stores a Bluetooth connection program, and when the Bluetooth connection program is executed by a processor, the steps of the Bluetooth connection method described above are implemented.
[0039] The present invention establishes a connection and binding with a Bluetooth device through an intelligent terminal, obtains the services supported by the Bluetooth device; obtains the device subtype of the Bluetooth device, and selects the service to be connected from the services supported by the Bluetooth device according to the device subtype; sends an audio input service request to the Bluetooth device and receives a response, receives an audio output service request sent by the Bluetooth device, generates a response data packet and sends it to the Bluetooth device; sends an encryption instruction to the Bluetooth device, starts the audio receiving end service connected to the Bluetooth device after encryption is completed, and starts audio transmission after the connection is successful. The present invention optimizes the connection process with the Bluetooth device, actively obtains and selects the services of the Bluetooth device, and responds to the service requests of the Bluetooth device in a timely manner. This can not only improve the binding connection speed with the Bluetooth device, but also improve the compatibility and versatility of the Bluetooth device. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 is a flow chart of a preferred embodiment of the Bluetooth connection method of the present invention;
[0041] Figure 2 is a flowchart of step S10 in a preferred embodiment of the Bluetooth connection method of the present invention;
[0042] Figure 3 is a flowchart of step S20 in a preferred embodiment of the Bluetooth connection method of the present invention;
[0043] Figure 4 This is a schematic diagram of a preferred embodiment of the Bluetooth connection method of the present invention in which a smart terminal actively sends a service request to a Bluetooth device and selects a service to be connected;
[0044] Figure 5 is a flowchart of step S30 in a preferred embodiment of the Bluetooth connection method of the present invention;
[0045] Figure 6 This is a schematic diagram of a preferred embodiment of the Bluetooth connection method of the present invention in which a Bluetooth device actively initiates a service discovery request to a smart terminal;
[0046] Figure 7 1 is a flow chart of the entire connection process in a preferred embodiment of the Bluetooth connection method of the present invention;
[0047] Figure 8 Schematic diagram of the operating environment of a preferred embodiment of the intelligent terminal of the present invention. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solutions and advantages of the present invention more clear and distinct, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0049] The Bluetooth connection method described in the preferred embodiment of the present invention is as follows: Figure 1 As shown, the Bluetooth connection method includes the following steps:
[0050] Step S10: Establish a connection and binding with a Bluetooth device, and obtain services supported by the Bluetooth device.
[0051] For the specific process, please refer to Figure 2 , which is a flowchart of step S10 in the Bluetooth connection method provided by the present invention.
[0052] like Figure 2 As shown, step S10 includes:
[0053] S11, establishing a link connection with the Bluetooth device;
[0054] S12: Send a request to the Bluetooth device to obtain the input and output capabilities of the Bluetooth device, receive the input and output capabilities fed back by the Bluetooth device according to the request, and select a binding method with the Bluetooth device according to the input and output capabilities;
[0055] S13. After determining the binding method with the Bluetooth device, generate a key and send it to the Bluetooth device;
[0056] S14. Send an SDP service discovery request to the Bluetooth device to obtain services supported by the Bluetooth device.
[0057] Specifically, the executor of the present invention is a smart terminal (such as a smart TV, a smart phone, or other device that can play audio and video), that is, the present invention is a process of establishing a connection between the smart terminal and the Bluetooth device for audio transmission. The smart terminal (such as a smart TV TV) first establishes a link connection with the Bluetooth device. For example, the smart terminal (such as the host of the smart terminal) initiates HCI_Create_Connection (link connection) to the Bluetooth device through the protocol stack. After the link connection between the smart terminal and the Bluetooth device is successful, the smart terminal sends a request to obtain the input and output capabilities of the Bluetooth device to the Bluetooth device so that the smart terminal knows the input and output capabilities of the Bluetooth device. After the Bluetooth device receives the request from the smart terminal to obtain the input and output capabilities of the Bluetooth device, the Bluetooth device feeds back the input and output capabilities to the smart terminal according to the request. After the smart terminal receives the input and output capabilities fed back by the Bluetooth device, it selects a binding method with the Bluetooth device according to the input and output capabilities.
[0058] Among them, the binding method includes at least one of the following methods: Numeric Comparison (numeric comparison is applicable to low-power secure connections but not to traditional pairing), Just Works (i.e., this binding method does not require confirmation by the Bluetooth device, and also means that the Bluetooth device at this time has no input and output capabilities), Out of Band (Out of Band refers to when one of the two connected parties has an important event and wants to notify the other party quickly. During the data transmission process, it is hoped that a certain type of information will not be transmitted to the user through conventional transmission methods for timely processing, such as the interrupt key and terminal flow control character of the UNIX system, which is called out-of-band data) and Passkey Entry (login through password verification).
[0059] Furthermore, after the smart terminal determines the binding method with the Bluetooth device (one of the four binding methods mentioned above, for example, if the Bluetooth device is a Bluetooth speaker without input and output capabilities, the binding method selects Just Works, that is, no confirmation by the Bluetooth speaker is required), the smart device generates a key (a key is a parameter, which is a parameter input in the algorithm for converting plaintext to ciphertext or converting ciphertext to plaintext) and sends it to the Bluetooth device. After that, the smart terminal sends an SDP (Service Discovery Protocol) service discovery request to the Bluetooth device to obtain the services supported by the Bluetooth device. Because the smart terminal knows which services are supported by the Bluetooth device, it can select the service to be connected.
[0060] Step S20: Obtain the device subtype of the Bluetooth device, and select a service to be connected from services supported by the Bluetooth device according to the device subtype.
[0061] For detailed process, please refer to Figure 3 , which is a flowchart of step S20 in the Bluetooth connection method provided by the present invention.
[0062] like Figure 3 As shown, step S20 includes:
[0063] S21. Obtain the device subtype of the Bluetooth device;
[0064] S22. If the device subtype is a Bluetooth speaker, actively send a service request to the Bluetooth speaker, and receive a service request response sent by the Bluetooth speaker;
[0065] S23, parsing the service request response, obtaining an identity value and storing it in a singly linked list;
[0066] S24: traverse the identity identification values in the singly linked list, and select a service to be connected from the services supported by the Bluetooth device.
[0067] Specifically, the smart terminal obtains the device subtype (Device Class) of the Bluetooth device. Bluetooth devices are distinguished by major device class and minor device class, such as audio for speakers (major) and speaker for speakers (minor). The smart terminal determines whether the device subtype is a Bluetooth speaker (0x0400, that is, if the byte is 0x0400 during judgment, it indicates that the Bluetooth device is a Bluetooth speaker). If the device subtype is a Bluetooth speaker (0x0400), it actively sends a service request (SDP_ServiceSearchAttributeRequest) to the Bluetooth speaker. The Bluetooth speaker responds after receiving the service request, and the smart terminal receives the service request response (SDP_ServiceSearchAttributeResponse) sent by the Bluetooth speaker. Then, the smart terminal parses the service request response (that is, parses the field Service Record in the SDP Packet). Attributes value) and stored in a single linked list, the smart terminal traverses the UUID value (UniversalUniqueIdentifier, identity identification, the purpose is to allow all elements in the distributed system to have unique identification information, without the need for a central control terminal to specify the identification information) in the single linked list, so that the service that needs to be connected first can be selected from the services supported by the Bluetooth device according to the identity identification value (different identity identification values correspond to different services). For example, the service that needs to be connected is given priority. More specifically, the Bluetooth speaker Audio Sink (audio input terminal) is connected first. This strategy can solve the problem of conflicting connection failures for speakers that support multiple services. In addition, if the device subtype is not a Bluetooth speaker, other service requests are obtained, such as obtaining the power service of the Bluetooth device, obtaining the motion data of the Bluetooth device, obtaining the weather data of the Bluetooth device, etc.
[0068] Among them, a singly linked list is a chain-access data structure that uses a set of storage units with arbitrary addresses to store data elements in a linear list; the data in the linked list is represented by nodes, and each node is composed of: element (image of the data element) + pointer (indicating the storage location of the subsequent element), the element is the storage unit for storing data, and the pointer is the address data connecting each node.
[0069] Further, if Figure 4As shown, the smart terminal actively sends a service request (i.e., an SDP service discovery request) to the Bluetooth device, determines whether the device subtype of the Bluetooth device is a Bluetooth speaker, and if the device subtype is a Bluetooth speaker, actively sends a service request to the Bluetooth speaker, receives a service request response sent by the Bluetooth speaker, parses the service request response, obtains an identity value and stores it in a single linked list, traverses the identity value in the single linked list, and selects a service to be connected from the services supported by the Bluetooth device; if the device subtype is not a Bluetooth speaker, obtains other service requests.
[0070] Step S30: Send an audio input service request to the Bluetooth device and receive a response, receive an audio output service request sent by the Bluetooth device, generate a response data packet and send it to the Bluetooth device.
[0071] For detailed process, please refer to Figure 5 , which is a flowchart of step S30 in the Bluetooth connection method provided by the present invention.
[0072] like Figure 5 As shown, step S30 includes:
[0073] S31, sending an audio input service request to the Bluetooth device, and receiving and parsing a response from the Bluetooth device to the audio input service request;
[0074] S32: If an audio output service request is received from the Bluetooth device, determining whether the audio receiving end service connection is enabled;
[0075] S33: If enabled, obtain the audio output record and add the corresponding identity value, generate a response data packet and send it to the Bluetooth device.
[0076] Specifically, the smart terminal sends an audio input (AudioSink) service request to the Bluetooth device. The Bluetooth device responds after receiving the audio input service request. The smart terminal receives the response of the Bluetooth device to the audio input service request and parses the response of the Bluetooth device to the audio input service request. Since different Bluetooth devices support different services, some Bluetooth devices will actively initiate an audio output (AudioSource) service request confirmation. After receiving the AudioSource service request, the smart terminal determines whether the audio receiving end (sink) service connection is open. If the audio receiving end service connection is open, the smart terminal fills the AudioSource (audio output) record and adds the corresponding UUID value (identity value). After assembling the response packet (i.e., the response data packet), it sends a reply to the Bluetooth device. In addition, if the audio receiving end service connection is not open, the content of the response reply sent to the Bluetooth device is empty.
[0077] For example, the Bluetooth device is a Bluetooth speaker, that is, the Bluetooth speaker is the source and the smart terminal (TV) is the sink. Then the TV needs to determine whether the sink is turned on before sending a packet to the Bluetooth speaker.
[0078] Furthermore, if Figure 6 As shown, the smart terminal sends an audio input service request (AudioSink) to the Bluetooth device. In order to further confirm the connection, some Bluetooth devices will actively initiate an audio output (Audio Source) service discovery request to the smart terminal. When the smart terminal receives the audio output (Audio Source) service discovery request, it will fill in the response data field and respond to the Bluetooth device. However, some Bluetooth speakers will not initiate an audio output (Audio Source) service discovery request, so the information replied by the smart terminal is NULL, that is, the content of the response sent by the smart terminal to the Bluetooth device is empty.
[0079] Step S40: Send an encryption instruction to the Bluetooth device. After encryption is completed, start the audio receiving end service connected to the Bluetooth device. After the connection is successful, start audio transmission.
[0080] Specifically, after the service transmission between the smart terminal and the Bluetooth device is completed, the smart terminal starts encryption and sends the encryption instruction to the Bluetooth device. When the Bluetooth device receives the encryption instruction, it performs encryption. For example, the smart terminal sends the encryption command HCI_Set_Connection_Encryption to the Bluetooth device. When both parties agree to encryption, both parties will receive event: sHCI_Encryption_Change (on) to complete the encryption. After the encryption is completed, the smart terminal pneumatically connects and initiates the audio receiving end (sink) service of the Bluetooth device. Finally, the audio transmission is started after the connection is successful.
[0081] Further, if Figure 7 As shown, the entire process of the Bluetooth connection method between the smart terminal and the Bluetooth device in the present invention is as follows:
[0082] The smart terminal (e.g., TV) establishes a binding connection with the Bluetooth device. After successfully establishing a link connection (HCI_Create_Connection), the smart terminal obtains the input and output capabilities fed back by the Bluetooth device. After determining the binding method with the Bluetooth device, the smart terminal generates a key and sends it to the Bluetooth device. The smart terminal sends an SDP service discovery request to the Bluetooth device to determine the device subtype of the Bluetooth device. If the device subtype is not a Bluetooth speaker, other service requests are obtained and other service connections are made based on the parsed response (the smart terminal determines the service connection). If the device subtype is a Bluetooth speaker, the smart terminal actively sends an AudioSink service request to the Bluetooth speaker, receives and parses the service request response sent by the Bluetooth speaker, starts a timer (Timer) to wait, and determines whether the smart terminal has received an Audio Source service request from the Bluetooth device (in this case, a Bluetooth speaker). If not, the Bluetooth device does not send a service request. If the smart terminal receives an Audio Source service request from the Bluetooth device Source service request, the Bluetooth device responds to the smart terminal profile (protocol) information, the smart terminal starts encryption, and opens the audio receiving end (sink) service connection.
[0083] The present invention improves and optimizes the connection process between smart terminals and Bluetooth devices. The smart terminal actively initiates the acquisition of Bluetooth device services, the smart terminal decides to select service connection, and the smart terminal increases the service request received by the Bluetooth device and performs corresponding response processing, thereby maximizing the compatibility and versatility of Bluetooth. It can not only improve the binding connection speed with the Bluetooth device, but also solve compatibility problems, while bringing a good product experience to users and improving the core competitiveness of the product.
[0084] Further, if Figure 8 As shown, based on the above Bluetooth connection method, the present invention also provides a smart terminal, which includes a processor 10, a memory 20 and a display 30. Figure 8 Only some components of the smart terminal are shown, but it should be understood that it is not required to implement all of the shown components, and more or fewer components may be implemented instead.
[0085] In some embodiments, the memory 20 can be an internal storage unit of the smart terminal, such as a hard disk or memory of the smart terminal. In other embodiments, the memory 20 can also be an external storage device of the smart terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the smart terminal. Furthermore, the memory 20 can also include both an internal storage unit of the smart terminal and an external storage device. The memory 20 is used to store application software and various types of data installed on the smart terminal, such as the program code of the installed smart terminal. The memory 20 can also be used to temporarily store data that has been output or is to be output. In one embodiment, a Bluetooth connection program 40 is stored on the memory 20, and the Bluetooth connection program 40 can be executed by the processor 10, thereby implementing the Bluetooth connection method in the present application.
[0086] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor, or other data processing chip, configured to execute program codes or process data stored in the memory 20, such as executing the Bluetooth connection method.
[0087] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display 30 is used to display information on the smart terminal and to display a visual user interface. The components 10-30 of the smart terminal communicate with each other via a system bus.
[0088] In one embodiment, when the processor 10 executes the Bluetooth connection program 40 in the memory 20, the following steps are implemented:
[0089] Establish a connection and binding with a Bluetooth device to obtain the services supported by the Bluetooth device;
[0090] Obtaining a device subtype of the Bluetooth device, and selecting a service to be connected from services supported by the Bluetooth device according to the device subtype;
[0091] Sending an audio input service request to the Bluetooth device and receiving a response, receiving an audio output service request sent by the Bluetooth device, generating a response data packet and sending it to the Bluetooth device;
[0092] Send an encryption instruction to the Bluetooth device, start the audio receiving end service connected to the Bluetooth device after encryption is completed, and start audio transmission after the connection is successful.
[0093] The steps of establishing a connection and binding with a Bluetooth device and obtaining services supported by the Bluetooth device specifically include:
[0094] Establishing a link connection with the Bluetooth device;
[0095] Sending a request to the Bluetooth device to obtain the input and output capabilities of the Bluetooth device, receiving the input and output capabilities fed back by the Bluetooth device according to the request, and selecting a binding method with the Bluetooth device according to the input and output capabilities;
[0096] After determining the binding method with the Bluetooth device, generate a key and send it to the Bluetooth device;
[0097] Send an SDP service discovery request to the Bluetooth device to obtain services supported by the Bluetooth device.
[0098] The acquiring of the device subtype of the Bluetooth device and selecting a service to be connected from services supported by the Bluetooth device according to the device subtype specifically includes:
[0099] Get the device subtype of the Bluetooth device;
[0100] If the device subtype is a Bluetooth speaker, actively sending a service request to the Bluetooth speaker, and receiving a service request response sent by the Bluetooth speaker;
[0101] Parsing the service request response, obtaining the identity value and storing it in a singly linked list;
[0102] The identity identification values in the singly linked list are traversed, and a service to be connected is selected from the services supported by the Bluetooth device.
[0103] The sending of the audio input service request to the Bluetooth device and receiving a response, receiving the audio output service request sent by the Bluetooth device, and generating a response data packet to send to the Bluetooth device specifically include:
[0104] Sending an audio input service request to the Bluetooth device, and receiving and parsing a response from the Bluetooth device to the audio input service request;
[0105] If an audio output service request is received from the Bluetooth device, determining whether the audio receiving end service connection is enabled;
[0106] If it is turned on, the audio output record is obtained and the corresponding identity value is added, and a response data packet is generated and sent to the Bluetooth device.
[0107] Wherein, after the step of determining whether the audio receiving terminal service connection is open, the method further includes:
[0108] If it is not enabled, the content of the response sent to the Bluetooth device will be empty.
[0109] Wherein, after the step of obtaining the device subtype of the Bluetooth device, the method further includes:
[0110] If the device subtype is not a Bluetooth speaker, other service requests are obtained.
[0111] The binding mode includes at least one of: numerical comparison, only working mode, out-of-band and password login.
[0112] Furthermore, if Figure 4 Or as Figure 6 As shown, the present invention also provides a Bluetooth connection system, the system includes an intelligent terminal and a Bluetooth device; the intelligent terminal and the Bluetooth device establish a connection and binding; wherein, the intelligent terminal is used to obtain the services supported by the Bluetooth device; the intelligent terminal is also used to obtain the device subtype of the Bluetooth device, and select the service to be connected from the services supported by the Bluetooth device according to the device subtype; the intelligent terminal is also used to send an audio input service request to the Bluetooth device and receive a response; the Bluetooth device is used to send an audio output service request to the intelligent terminal, and the intelligent terminal generates a response data packet and sends it to the Bluetooth device; the intelligent terminal is also used to send an encryption instruction to the Bluetooth device, and after the encryption is completed, the audio receiving end service connected to the Bluetooth device is started, and audio transmission is started after the connection is successful.
[0113] Furthermore, the present invention also provides a computer storage medium, wherein the computer storage medium stores a Bluetooth connection program, and when the Bluetooth connection program is executed by a processor, the steps of the Bluetooth connection method described above are implemented.
[0114] In summary, the present invention provides a Bluetooth connection method, system, intelligent terminal and computer storage medium, the method comprising: establishing a connection and binding with a Bluetooth device, obtaining services supported by the Bluetooth device; obtaining the device subtype of the Bluetooth device, and selecting the service to be connected from the services supported by the Bluetooth device according to the device subtype; sending an audio input service request to the Bluetooth device and receiving a response, receiving an audio output service request sent by the Bluetooth device, generating a response data packet and sending it to the Bluetooth device; sending an encryption instruction to the Bluetooth device, starting the audio receiving end service connected to the Bluetooth device after encryption is completed, and starting audio transmission after the connection is successful. The present invention optimizes the connection process with the Bluetooth device, actively obtains and selects the services of the Bluetooth device, and promptly responds to the service requests of the Bluetooth device, which can not only improve the binding connection speed with the Bluetooth device, but also improve the compatibility and versatility of the Bluetooth device.
[0115] Of course, those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware (such as a processor, controller, etc.) through a computer program. The program can be stored in a computer-readable computer storage medium, and when executed, the program can include the processes in the above-described method embodiments. The computer storage medium can be a memory, a magnetic disk, an optical disk, etc.
[0116] It should be understood that the application of the present invention is not limited to the above examples. For those skilled in the art, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A Bluetooth connection method, characterized in that: The Bluetooth connection method includes: Establish a connection and binding with a Bluetooth device to obtain the services supported by the Bluetooth device; Obtaining a device subtype of the Bluetooth device, and selecting a service to be connected from services supported by the Bluetooth device according to the device subtype; Sending an audio input service request to the Bluetooth device and receiving a response, receiving an audio output service request sent by the Bluetooth device, generating a response data packet and sending it to the Bluetooth device; Send an encryption instruction to the Bluetooth device, start the audio receiving end service connected to the Bluetooth device after encryption is completed, and start audio transmission after the connection is successful; The establishment of a connection and binding with a Bluetooth device and obtaining services supported by the Bluetooth device specifically includes: Establishing a link connection with the Bluetooth device; Sending a request to the Bluetooth device to obtain the input and output capabilities of the Bluetooth device, receiving the input and output capabilities fed back by the Bluetooth device according to the request, and selecting a binding method with the Bluetooth device according to the input and output capabilities; After determining the binding method with the Bluetooth device, generate a key and send it to the Bluetooth device; Send an SDP service discovery request to the Bluetooth device to obtain services supported by the Bluetooth device.
2. The Bluetooth connection method according to claim 1, wherein: The acquiring the device subtype of the Bluetooth device and selecting a service to be connected from services supported by the Bluetooth device according to the device subtype specifically includes: Get the device subtype of the Bluetooth device; If the device subtype is a Bluetooth speaker, actively sending a service request to the Bluetooth speaker, and receiving a service request response sent by the Bluetooth speaker; Parsing the service request response, obtaining the identity value and storing it in a singly linked list; The identity identification values in the singly linked list are traversed, and a service to be connected is selected from the services supported by the Bluetooth device.
3. The Bluetooth connection method according to claim 2, wherein: The sending of the audio input service request to the Bluetooth device and receiving a response, receiving the audio output service request sent by the Bluetooth device, generating a response data packet and sending it to the Bluetooth device, specifically includes: Sending an audio input service request to the Bluetooth device, and receiving and parsing a response from the Bluetooth device to the audio input service request; If an audio output service request is received from the Bluetooth device, determining whether the audio receiving end service connection is enabled; If it is turned on, the audio output record is obtained and the corresponding identity value is added, and the response data packet is generated and sent to the Bluetooth device.
4. The Bluetooth connection method according to claim 3, wherein: After the step of determining whether the audio receiving terminal service connection is open, the method further includes: If it is not enabled, the content of the response sent to the Bluetooth device will be empty.
5. The Bluetooth connection method according to claim 2, wherein: After the step of obtaining the device subtype of the Bluetooth device, the method further includes: If the device subtype is not a Bluetooth speaker, obtain other service requests.
6. The Bluetooth connection method according to claim 1, wherein: The binding mode includes at least one of: numerical comparison, only working mode, out-of-band and password login.
7. An intelligent terminal, characterized in that: The intelligent terminal includes: A memory, a processor, and a Bluetooth connection program stored in the memory and executable on the processor, wherein the Bluetooth connection program, when executed by the processor, implements the steps of the Bluetooth connection method according to any one of claims 1 to 6.
8. A Bluetooth connection system, characterized in that: The system comprises: Bluetooth devices; The smart terminal according to claim 7, wherein the smart terminal and the Bluetooth device are connected and bound; Wherein, the smart terminal is used to obtain the services supported by the Bluetooth device; The smart terminal is further configured to obtain a device subtype of the Bluetooth device, and select a service to be connected from services supported by the Bluetooth device according to the device subtype; The intelligent terminal is further configured to send an audio input service request to the Bluetooth device and receive a response; The Bluetooth device is used to send an audio output service request to the smart terminal, and the smart terminal generates a response data packet and sends it to the Bluetooth device; The smart terminal is further configured to send an encryption instruction to the Bluetooth device, start the audio receiving terminal service connected to the Bluetooth device after encryption is completed, and start audio transmission after the connection is successful.
9. A computer storage medium, characterized in that The computer storage medium stores a Bluetooth connection program, and when the Bluetooth connection program is executed by the processor, the steps of the Bluetooth connection method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Method and apparatus for playing audio
CN105763936A
Bluetooth management method, mobile terminal and computer storage medium
CN110177357A
Communicator, central communication device and Bluetooth communication system
CN111132098A