Disclosure of Invention
The purpose of the present application is to provide a communication method, apparatus and medium for pairing bluetooth devices, so that one bluetooth device can pair multiple clients, and a paired client can share a bluetooth device with a new unpaired client.
In order to solve the above technical problem, the present application provides a communication method for pairing bluetooth devices, including:
acquiring ID information of a client to be shared, which is sent by a connected client;
responding to a request sent by the client to be shared, wherein the request comprises the ID information;
and sending Bluetooth equipment information to the client to be shared according to the ID information so that the client to be shared can be paired with Bluetooth equipment according to the Bluetooth equipment information, wherein the Bluetooth equipment information at least comprises a secret key for communication between the client to be shared and the Bluetooth equipment.
Preferably, after the obtaining of the ID information of the to-be-shared client sent by the connected client, the method further includes:
judging whether the number of the ID information in the sharing list is larger than a threshold value, if so, deleting the ID information of the client to be shared; and if not, sending the ID information of the client to be shared to the sharing list.
Preferably, after the sending the ID information of the client to be shared to the sharing list, the method further includes:
and sending the sharing list to the client to be shared.
Preferably, after the determining whether the number of the ID information in the sharing list is greater than a threshold, the method further includes:
and sending a judgment result for representing sharing success/failure to the connected client.
Preferably, the bluetooth device information further includes:
and matching codes.
In order to solve the above technical problem, the present application further provides a communication method for pairing bluetooth devices, which is applied to a client to be shared, and the method includes:
sending a request to a cloud server, wherein the request comprises ID information of a client to be shared, which is obtained by the cloud server and sent by a connected client;
acquiring Bluetooth equipment information sent by the cloud server according to the ID information, wherein the Bluetooth equipment information at least comprises a secret key used for communication between the client to be shared and the Bluetooth equipment;
and pairing the Bluetooth equipment according to the Bluetooth equipment information.
In order to solve the above technical problem, the present application further provides a communication method for pairing bluetooth devices, which is applied to a connected client, and the method includes:
sending the ID information of the client to be shared to a cloud server; so that the cloud server responds to a request sent by the client to be shared, wherein the request comprises the ID information; so that the cloud server sends bluetooth device information to the to-be-shared client according to the ID information, so that the to-be-shared client pairs with bluetooth devices according to the bluetooth device information, and the bluetooth device information at least includes a secret key for communication between the to-be-shared client and the bluetooth devices.
In order to solve the above technical problem, the present application further provides a communication apparatus for bluetooth device pairing, the apparatus including:
the acquisition module is used for acquiring the ID information of the client to be shared, which is sent by the connected client;
the response module is used for responding to a request sent by the client to be shared, wherein the request comprises the ID information;
and the sending module is used for sending Bluetooth equipment information to the client to be shared according to the ID information so as to be convenient for the client to be shared to be paired with Bluetooth equipment according to the Bluetooth equipment information, and the Bluetooth equipment information at least comprises a secret key for communication between the client to be shared and the Bluetooth equipment.
In order to solve the above technical problem, the present application further provides a communication apparatus for bluetooth device pairing, the apparatus including:
a memory for storing a computer program;
a processor for implementing the steps of the communication method for pairing bluetooth devices as described above when executing the computer program.
In order to solve the above technical problem, the present application further provides a computer-readable storage medium, having a computer program stored thereon, where the computer program is executed by a processor to implement the steps of the communication method for pairing bluetooth devices as described above.
According to the Bluetooth device pairing communication method, the Bluetooth device pairing communication device and the Bluetooth device pairing communication medium, the ID information of the client to be shared, which is required to be shared, is acquired from the connected client, the Bluetooth device information paired with the connected client is sent to the client to be shared according to the ID information, the Bluetooth device information at least comprises a secret key used for communication between the client to be shared and the Bluetooth device, and the client to be shared can be paired with the Bluetooth device according to the Bluetooth device information. Therefore, by adopting the technical scheme, one Bluetooth device can be paired with a plurality of clients, and the function that the paired clients share the Bluetooth device with the new unpaired client is realized.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without any creative effort belong to the protection scope of the present application.
The core of the application is to provide a communication method, a device and a medium for pairing Bluetooth equipment.
In order that those skilled in the art will better understand the disclosure, the following detailed description will be given with reference to the accompanying drawings.
Fig. 1 is a flowchart of a communication method for pairing bluetooth devices according to an embodiment of the present application, and as shown in fig. 1, the method includes the following steps:
s10: and acquiring the ID information of the client to be shared, which is sent by the connected client.
In step S10, the connected client may be a mobile phone, a tablet, a computer, or the like, and the to-be-shared client may also be a mobile phone, a tablet, a computer, or the like. It is understood that the clients may be of the same category or different categories, for example, the connected client is a mobile phone, and the client to be shared is a mobile phone, a computer, or the like. Further, when the client to be shared is a mobile phone, the ID information may be a mobile phone number, and when the client to be shared is a computer, the ID information may be an equipment number.
S11: and responding to a request sent by the client to be shared, wherein the request comprises ID information.
In step S11, the to-be-shared client sends a request to the cloud server for requesting bluetooth device information, where the request includes ID information of the to-be-shared client. The process of issuing the request may be continuous or intermittent, and may be issuing the request periodically or issuing the request after receiving the trigger signal, which is not limited herein.
S12: and sending the Bluetooth equipment information to the client to be shared according to the ID information so that the client to be shared is paired with the Bluetooth equipment according to the Bluetooth equipment information, wherein the Bluetooth equipment information at least comprises a secret key for communication between the client to be shared and the Bluetooth equipment.
In step S12, the bluetooth device information is uploaded to the cloud server when the connected client pairs with the bluetooth device, and after the cloud server receives the request, the bluetooth device information is sent to the client to be shared according to the ID information in the obtained request, and the client to be shared can pair with the bluetooth device according to the bluetooth device information. The bluetooth device information at least includes a key required for communication between the bluetooth device and the client to be shared, and of course, may also include information such as a model number, a version number, a pairing code, and the like of the bluetooth device. As a preferred option, the type of the Bluetooth device is Bluetooth Low Energy (BLE) Bluetooth device, and the BLE Bluetooth device has the advantage of Low power consumption, can be used for a long time, and improves user experience.
Fig. 2 is a flowchart of a communication method for pairing bluetooth devices according to another embodiment of the present disclosure, in which a connected client and a to-be-shared client are both mobile phones, a mobile phone a is a connected client, a mobile phone B is a to-be-shared client, and ID information of the connected client and the to-be-shared client is a mobile phone number. As shown in fig. 2, a mobile phone a sends a mobile phone number of a mobile phone B to a cloud server, the mobile phone B sends a request to the cloud server, the request includes the mobile phone number, the cloud server receives the mobile phone number sent by the mobile phone a, responds to the request of the mobile phone B, calls bluetooth device information of a bluetooth device paired with the mobile phone a, and sends the bluetooth device information to the mobile phone B according to the mobile phone number, the bluetooth device information at least includes a secret key, and the mobile phone B starts communication with the bluetooth device through the secret key, so that pairing is achieved. The pairing process is based on pairing of a client and HID-based Bluetooth equipment in the prior art, when a mobile phone B is paired with the Bluetooth equipment for the first time, the Bluetooth equipment can send broadcast to the periphery at regular time, when the mobile phone B captures the broadcast, the broadcast is analyzed, and communication is established with the Bluetooth equipment according to a secret key. If the Bluetooth equipment needs to check the identity, the corresponding pairing code needs to be input by the mobile phone B, the Bluetooth equipment is checked, and after the check is successful, equipment information such as the model, the mac address and the uuid information of the Bluetooth equipment is sent to the mobile phone B. The required pairing code may be that which handset a tells handset B, or may be contained in the bluetooth device information. Of course, this step can be omitted if the bluetooth device does not need to verify identity. After the mobile phone B acquires the device information, registering the related information of the mobile phone B and the Bluetooth device information in a cloud server for binding, and after receiving the information indicating that the binding is successful, storing the Bluetooth device information in a white list of the mobile phone B for subsequent pairing.
Meanwhile, the mobile phone B can also set the connection distance with the Bluetooth equipment, and when the connection distance exceeds the set distance, the mobile phone B is disconnected with the Bluetooth equipment. Under the condition, the Bluetooth equipment still sends a broadcast packet to the surrounding, after the mobile phone B enters the set connection distance, the broadcast is captured and analyzed, whether the Bluetooth equipment information exists in a white list is judged according to the analyzed mac address, and if the Bluetooth equipment information exists, the Bluetooth equipment is reconnected with the Bluetooth equipment according to the Bluetooth equipment information.
According to the communication method for pairing the Bluetooth devices, the ID information of the client to be shared, which is required to be shared, is acquired from the connected client, the Bluetooth device information paired with the connected client is sent to the client to be shared according to the ID information, the Bluetooth device information at least comprises a secret key used for communication between the client to be shared and the Bluetooth devices, and the client to be shared can be paired with the Bluetooth devices according to the Bluetooth device information. Therefore, by adopting the technical scheme, one Bluetooth device can be paired with a plurality of clients, and the function that the paired clients share the Bluetooth device with the new unpaired client is realized.
Due to the hardware of the bluetooth device, the information of the clients that can be stored in the bluetooth device is limited, that is, only a certain number of clients can be paired, in a specific implementation, if one bluetooth device is paired with too many clients, the pressure on the device may be increased, and if the number of the paired clients is small, the actual use may be affected.
Fig. 3 is a flowchart of a communication method for pairing bluetooth devices according to another embodiment of the present application, and as shown in fig. 3, on the basis of the foregoing embodiment, in this embodiment, after acquiring ID information of a to-be-shared client sent by a connected client, the method further includes:
s101: judging whether the number of the ID information in the sharing list is larger than a threshold value, if so, entering a step S102; if not, the process proceeds to step S103.
S102: and deleting the ID information of the client to be shared.
S103: and sending the ID information of the client to be shared to the sharing list.
The sharing list is used for storing the number of the clients paired with the Bluetooth equipment, and the ID information represents the clients. The selection of the threshold may be determined according to the storage amount of the hardware of the bluetooth device, in this embodiment, the selection threshold is 2, and it can be understood that, when 2 pieces of ID information are already stored in the sharing list, when the ID information of the client to be shared is obtained, and it is determined that the number of ID information in the sharing list is not greater than the threshold, the ID information of the client to be shared is sent to the sharing list, where the sharing list stores 3 pieces of ID information, that is, the bluetooth device may pair 3 clients; and if the ID information of the new client to be shared is obtained again, and the number of the ID information in the sharing list is larger than the threshold value, deleting the ID information of the new client to be shared.
The communication method for pairing the Bluetooth equipment provided by the embodiment of the application limits the number of clients which can be paired by the Bluetooth equipment, reasonably utilizes hardware storage of the Bluetooth equipment, and effectively prolongs the service life.
In a specific implementation, the to-be-shared client does not know that the bluetooth device is paired with a plurality of clients, and whether the user can share the to-be-shared client is determined.
As shown in fig. 3, in this embodiment, after sending the ID information of the client to be shared to the sharing list, the method further includes:
s104: and sending the sharing list to the client to be shared.
It can be understood that, the sharing list is sent to the clients to be shared, the user can check the number of the paired clients of the bluetooth device, and meanwhile, the specific paired clients can be accurately known according to the ID information in the sharing list. Certainly, the cloud server may also limit the sharing list, for example, hide ID information therein, only display the number of paired clients, and may well protect personal information of the paired clients.
According to the communication method for pairing the Bluetooth devices, the sharing list is sent to the client to be shared, so that the client to be shared can know how many clients the Bluetooth devices are paired, the client to be shared can conveniently determine whether the Bluetooth devices can be shared to other clients, and user experience is improved.
In implementations, the connected clients cannot know whether the sharing was successful.
In this embodiment, after determining whether the number of ID information in the sharing list is greater than the threshold, the method further includes:
and sending a judgment result for representing sharing success/failure to the connected client.
It can be understood that, when the determination is yes, the sharing is considered to be failed, and when the determination is no, the sharing is considered to be successful. The transmission mode may be in a text form or an audio form, and is not limited herein.
According to the communication method for pairing the Bluetooth devices, the judgment result used for representing the sharing success/failure is sent to the connected client, so that the connected client can know whether the sharing is successful, and the user experience is improved.
In specific implementation, each bluetooth device has its own pairing code for performing authentication when connected with a client, and during production, a merchant generally informs a user of the pairing code in a text form, however, when sharing, the client to be shared does not know the pairing code, and needs to be contacted with the connected client.
In this embodiment, the bluetooth device information further includes:
and matching codes.
According to the communication method for pairing the Bluetooth devices, the Bluetooth device information sent by the cloud server comprises the pairing code, the client to be shared can be directly obtained from the cloud server, and the connected client does not need to be contacted.
In the foregoing embodiment, the communication method for pairing the bluetooth devices is described in detail from the perspective of the cloud server side, and the present application also provides an embodiment corresponding to the communication method for pairing the bluetooth devices from the perspective of the to-be-shared client side.
The method comprises the following steps:
sending a request to a cloud server, wherein the request comprises ID information of a client to be shared, which is obtained by the cloud server and sent by a connected client;
acquiring Bluetooth equipment information sent by the cloud server according to the ID information, wherein the Bluetooth equipment information at least comprises a secret key used for communication between the client to be shared and the Bluetooth equipment;
and pairing with the Bluetooth equipment according to the Bluetooth equipment information.
According to the communication method for pairing the Bluetooth devices, the ID information of the client to be shared, which is required to be shared, is acquired from the connected client, the Bluetooth device information paired with the connected client is sent to the client to be shared according to the ID information, the Bluetooth device information at least comprises a secret key used for communication between the client to be shared and the Bluetooth devices, and the client to be shared can be paired with the Bluetooth devices according to the Bluetooth device information. Therefore, by adopting the technical scheme, one Bluetooth device can be paired with a plurality of clients, and the function that the paired clients share the Bluetooth device with the new unpaired client is realized.
In specific implementation, after the to-be-shared client is paired with the bluetooth device, when the to-be-shared client is offline, the bluetooth device is still in a state of being paired with the to-be-shared client, and new pairing cannot be performed, which affects use experience.
In this embodiment, after the to-be-shared client is paired with the bluetooth device, when the to-be-shared client is offline and the bluetooth device is still in a pairing state, the to-be-shared client acquires a message sent by the bluetooth device and sends a connection request; after the connection line is established, the client to be shared initiates a pairing clearing instruction for enabling the Bluetooth equipment to clear pairing; and the client to be shared acquires a clearing pairing result representing the clearing success/failure.
According to the communication method for pairing the Bluetooth devices, when the client to be shared is offline and the Bluetooth devices are still in the pairing state, the pairing of the Bluetooth devices is eliminated, so that the Bluetooth devices can be newly paired, the use efficiency of the Bluetooth devices is improved, and the user experience is improved.
The application also provides a corresponding embodiment of the communication method of the Bluetooth device pairing from the perspective of the connected client side.
The method comprises the following steps:
sending the ID information of the client to be shared to a cloud server; the cloud server responds to a request sent by the client to be shared, wherein the request comprises ID information; the method and the device for sharing the Bluetooth device are convenient for the cloud server to send the Bluetooth device information to the client to be shared according to the ID information, the client to be shared is convenient to pair with the Bluetooth device according to the Bluetooth device information, and the Bluetooth device information at least comprises a secret key used for communication between the client to be shared and the Bluetooth device.
According to the communication method for pairing the Bluetooth devices, the ID information of the client to be shared, which is required to be shared, is acquired from the connected client, the Bluetooth device information paired with the connected client is sent to the client to be shared according to the ID information, the Bluetooth device information at least comprises a secret key used for communication between the client to be shared and the Bluetooth devices, and the client to be shared can be paired with the Bluetooth devices according to the Bluetooth device information. Therefore, by adopting the technical scheme, one Bluetooth device can be paired with a plurality of clients, and the function that the paired clients share the Bluetooth device with the new unpaired client is realized.
In a specific implementation, after the connected client is paired with the bluetooth device, when the connected client is offline, the bluetooth device is still in a state of being paired with the connected client.
In the above embodiments, the detailed description is made on the communication method of bluetooth device pairing, and the present application also provides embodiments corresponding to the communication apparatus of bluetooth device pairing. It should be noted that the present application describes the embodiments of the apparatus portion from two perspectives, one from the perspective of the function module and the other from the perspective of the hardware.
Fig. 4 is a structural diagram of a communication apparatus paired with bluetooth devices according to an embodiment of the present application, and as shown in fig. 4, the apparatus includes:
the acquiring module 10 is configured to acquire ID information of a client to be shared, which is sent by a connected client;
a response module 11, configured to respond to a request sent by the client to be shared, where the request includes the ID information;
a sending module 12, configured to send bluetooth device information to the to-be-shared client according to the ID information, so that the to-be-shared client pairs with a bluetooth device according to the bluetooth device information, where the bluetooth device information at least includes a secret key used for communication between the to-be-shared client and the bluetooth device.
According to the communication device for pairing the Bluetooth devices, the ID information of the client to be shared, which is required to be shared, is acquired from the connected client, the Bluetooth device information paired with the connected client is sent to the client to be shared according to the ID information, the Bluetooth device information at least comprises a secret key used for communication between the client to be shared and the Bluetooth devices, and the client to be shared can be paired with the Bluetooth devices according to the Bluetooth device information. Therefore, by adopting the technical scheme, one Bluetooth device can be paired with a plurality of clients, and the function that the paired clients share the Bluetooth device with the new unpaired client is realized.
Since the embodiments of the apparatus portion and the method portion correspond to each other, please refer to the description of the embodiments of the method portion for the embodiments of the apparatus portion, which is not repeated here.
Fig. 5 is a structural diagram of a communication apparatus for bluetooth device pairing according to another embodiment of the present application, and as shown in fig. 5, the communication apparatus for bluetooth device pairing includes: a memory 20 for storing a computer program;
a processor 21 for implementing the steps of the communication method for pairing bluetooth devices as described in the above embodiments when executing the computer program.
The communication device paired by the bluetooth device provided by this embodiment may include, but is not limited to, a smart phone, a tablet computer, a notebook computer, or a desktop computer.
The processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 21 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor for processing a calculation operation related to machine learning.
The memory 20 may include one or more computer-readable storage media, which may be non-transitory. Memory 20 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used for storing a computer program 201, wherein after being loaded and executed by the processor 21, the computer program can implement the relevant steps of the communication method for pairing the bluetooth devices disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202, data 203, and the like, and the storage manner may be a transient storage manner or a permanent storage manner. Operating system 202 may include, among others, Windows, Unix, Linux, and the like. Data 203 may include, but is not limited to, ID information, bluetooth device information, and the like.
In some embodiments, the communication device of the bluetooth device pair may further include a display 22, an input/output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.
Those skilled in the art will appreciate that the configuration shown in fig. 5 does not constitute a limitation of the communication means of the bluetooth device pairing and may include more or fewer components than those shown.
The communication device paired with the bluetooth equipment provided by the embodiment of the application comprises a memory and a processor, wherein when the processor executes a program stored in the memory, the following method can be realized: one bluetooth device is paired with multiple clients, and the paired clients share the bluetooth device with new unpaired clients.
Finally, the application also provides a corresponding embodiment of the computer readable storage medium. The computer-readable storage medium stores a computer program, and the computer program, when executed by the processor, implements the steps described in the above method embodiments (which may be a method corresponding to a cloud server side, a method corresponding to a connected client side, or a method corresponding to a client side to be shared).
It is to be understood that if the method in the above embodiments is implemented in the form of software functional units and sold or used as a stand-alone product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium and executes all or part of the steps of the methods described in the embodiments of the present application, or all or part of the technical solutions. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The detailed description is given above to a communication method, apparatus and medium for pairing bluetooth devices provided by the present application. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.