Disclosure of Invention
The embodiment of the invention provides a connection method and device of low-power-consumption Bluetooth, which do not need to manually and additionally select the master-slave relationship of equipment, are more convenient to connect, simplify the complexity of user operation and improve the user experience.
The embodiment of the invention adopts the following technical scheme:
in a first aspect, the present technical solution provides a connection method for bluetooth low energy, including switching between a master device and a slave device;
the conversion of the master device and the slave device includes:
a. acquiring a master time slice with random length, and using a low-power-consumption Bluetooth protocol to scan slave equipment as master equipment; determining that no connection is established with the slave device within a master time slice of random length; acquiring slave time slices with random lengths, and sending out a Bluetooth broadcast signal by using a low-power Bluetooth protocol as slave equipment; determining that no connection is established with the master device in the slave time slices with random lengths, and returning to the step a; or,
c. acquiring slave time slices with random lengths, and sending out a Bluetooth broadcast signal by using a low-power Bluetooth protocol as slave equipment; determining that no connection is established with the master device within a slave time slice of random length; acquiring a master time slice with random length, and using a low-power-consumption Bluetooth protocol to scan slave equipment as master equipment; and c, determining that no connection is established with the slave equipment in the master time slice with the random length, and returning to the step c.
The method further includes that after the acquiring the master time slice with random length is used as the master device to scan the slave device by using the bluetooth low energy protocol, the method further includes:
after determining that the master device is connected with the slave device and interrupted, acquiring a slave time slice with random length, and using a low-power-consumption Bluetooth protocol as the slave device to send out a Bluetooth broadcast signal; or,
and after determining that the master device is connected with the slave device and interrupted, acquiring a master time slice with random length, and using a low-power-consumption Bluetooth protocol to scan the slave device as the master device.
The further technical scheme is that after the slave time slice with the random length is obtained and used as slave equipment to send out the Bluetooth broadcast signal by using the low-power Bluetooth protocol, the method further comprises the following steps:
after determining that the slave device is connected with the master device and interrupted, acquiring a master time slice with random length, and scanning the slave device by using a low-power-consumption Bluetooth protocol as the master device; or,
and after determining that the slave device is connected with the master device and interrupted, acquiring a slave time slice with random length, and sending out a Bluetooth broadcast signal by using a low-power Bluetooth protocol as the slave device.
The method further includes that after the acquiring the master time slice with random length is used as the master device to scan the slave device by using the bluetooth low energy protocol, the method further includes:
if at least two slave devices are detected, sequencing the Bluetooth signal intensity of the slave devices, and connecting the slave devices in sequence from strong to weak according to the Bluetooth signal intensity.
The technical scheme is that the master time slice with random length and the slave time slices with random length are random time slices obtained by a formula T2 ═ ((Rand ()% N) +1) × T1, wherein T1 is the minimum time unit for switching of the low power consumption Bluetooth device, and N is an integer greater than 1 and less than 20.
In a second aspect, the present technical solution provides a bluetooth low energy connection device, including:
a master time slice acquiring unit, configured to acquire a master time slice with a random length, as a master device, to scan a slave device using a bluetooth low energy protocol;
a first connection determination unit configured to determine that no connection is established with the slave device within a master time slice of a random length;
a first triggering unit, configured to trigger the slave time slice obtaining unit when no connection is established with the slave device within a master time slice of a random length;
a slave time slice acquiring unit for acquiring a slave time slice of a random length as a slave device for transmitting a Bluetooth broadcast signal using a Bluetooth low energy protocol;
a second connection confirming unit for determining that no connection is established with the master device within a slave time slice of random length;
and the second triggering unit is used for triggering the main time slice acquisition unit when the connection with the main equipment is not established in the slave time slices with random lengths.
The further technical scheme is that the method further comprises the following steps:
the first connection interruption unit is used for acquiring a slave time slice with random length and sending a Bluetooth broadcast signal as a slave device by using a low-power Bluetooth protocol after determining that the master device is connected with the slave device and interrupted; or, after determining that the master device is connected to the slave device and then is interrupted, acquiring a master time slice with a random length, and using a bluetooth low energy protocol to scan the slave device as the master device.
The further technical scheme is that the method further comprises the following steps:
the second connection interruption unit is used for acquiring a master time slice with random length after determining that the master device is connected with the slave device and interrupted, and the master device scans the slave device by using a low-power Bluetooth protocol; or, after determining that the slave device is connected with the master device and is interrupted, acquiring a slave time slice with a random length, and sending out a bluetooth broadcast signal by using a low-power-consumption bluetooth protocol as the slave device.
The further technical scheme is that the method further comprises the following steps:
and the signal intensity connecting unit is used for sequencing the Bluetooth signal intensities of the slave devices if at least two slave devices are detected, and sequentially connecting the slave devices according to the Bluetooth signal intensities from strong to weak.
The further technical scheme is that the random time acquiring unit is used for acquiring the master time slice with the random length and the slave time slice with the random length by a formula T2 ═ ((Rand ()% N) +1) × T1, wherein T1 is the minimum time unit for switching of the low power consumption Bluetooth device, and N is an integer greater than 1 and less than 20.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
in the technical scheme, the equipment is used as the master equipment and the slave equipment in turn in an automatic random time slice mode, the situation that the connection cannot be established between the other side because a plurality of pieces of equipment are simultaneously master equipment or simultaneously slave equipment is avoided, the time slice length is generated randomly, the connection is established when the equipment circulates to be in different master-slave modes, the connection is more convenient, the complexity of user operation is simplified, and the user experience is improved.
Detailed Description
In order to make the technical problems solved, technical solutions adopted and technical effects achieved by the present invention clearer, the technical solutions of the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Please refer to fig. 1, which is a flowchart illustrating a connection method of bluetooth low energy according to a first embodiment of the present invention. The low-power Bluetooth connection method comprises the following steps:
s100, acquiring a master time slice with a random length, and using a low-power-consumption Bluetooth protocol to scan the slave equipment as the master equipment.
The master time slice with random length is obtained by the formula T2 ═ ((Rand ()% N) +1) × T1, where T1 is the minimum time unit for switching of the bluetooth low energy device, and N is an integer greater than 1 and less than 20. In this embodiment, N is preferably 10.
The master time slice with random length is relatively short, but the time length is at least the time required for allowing the slave device to be received by other master devices, the master device can search for the time required by other slave devices, usually, a certain time is prolonged on the basis of the time, and the connection is established under the condition that the two sides are kept for several times of random, and then one master device and one slave device are respectively used.
S101, determining that no connection is established with the slave device in a master time slice with random length.
And if the Bluetooth signals of the slave devices are not scanned in the master time slice with random length, or the scanned Bluetooth signals are lower than the set value, the connection is not carried out.
And S102, acquiring a slave time slice with a random length, and sending out a Bluetooth broadcast signal by using a low-power Bluetooth protocol as a slave device.
The method for acquiring the slave time slice with the random length is the same as the method for acquiring the master time slice with the random length, and is not described in detail. Since the slave time slice with the random length and the master time slice with the random length are random within a certain range, the length of the time slice is not a fixed value, and the device is converted from the master device state to the slave device state.
S103, determining that the connection with the master device is not established in the slave time slices with random lengths, and returning to the step S100.
If the device is in the slave state and no connection is established with the master device, scanning is performed again as the master device, and thus the master device state and the slave device state are cycled until a plurality of devices are not simultaneously the master device or simultaneously the slave device can establish a connection. The connection is typically established automatically over 1-3 cycles.
In summary, in this embodiment, after the bluetooth function is turned on, the device is in the master device state, and the device is alternately used as the master device and the slave device by means of the automatic random time slice, so that it is avoided that multiple devices are simultaneously the master device or the slave device and cannot be scanned, the time slice length is generated randomly, and when the device circulates to be in different master-slave modes, the connection is established, so that the connection is more convenient, the complexity of user operation is simplified, and the user experience is improved.
Please refer to fig. 2, which is a flowchart illustrating a bluetooth low energy connection method according to a second embodiment of the present invention. The difference between the connection method of bluetooth low energy and the method shown in fig. 1 is that the connection method of bluetooth low energy of this embodiment is first in a slave device state, and the connection method of bluetooth low energy includes:
and S200, acquiring a slave time slice with a random length, and sending out a Bluetooth broadcast signal by using a low-power Bluetooth protocol as a slave device.
S201, determining that no connection is established with the master device in the slave time slices with random lengths.
S202, acquiring a master time slice with a random length, and using a low-power-consumption Bluetooth protocol to scan the slave equipment as the master equipment.
S203, determining that no connection is established with the slave device in the master time slice with the random length, and returning to the step S200.
The device is in the master state and does not scan to the slave device, or the scanned Bluetooth signal is lower than the set value and does not connect, then the device is scanned as the slave device again, and the scanning is cycled between the master state and the slave state until a plurality of devices are not the master device at the same time or the connection can be established for the slave device at the same time. The connection is typically established automatically over 1-3 cycles.
The method for acquiring the slave time slice with random length and the master time slice with random length refers to the related content of the method shown in fig. 1, and is not described herein again.
In summary, in this embodiment, after the bluetooth function is turned on, the device is in the slave device state, and the device is alternately used as the master device and the slave device by means of the automatic random time slice, so that it is avoided that multiple devices are simultaneously the master device or the slave device and cannot be scanned, the time slice length is generated randomly, and when the devices circulate to be in different master-slave modes, the connection is established, which is more convenient, simplifies the complexity of the user operation, and improves the user experience.
Please refer to fig. 3, which is a flowchart illustrating a method for bluetooth low energy connection according to a third embodiment of the present invention. The difference between this embodiment and the method shown in fig. 1 is that this embodiment performs processing after connection if it finds that the target device does not need to be connected.
The connection method of the low-power Bluetooth comprises the following steps:
s300, acquiring a master time slice with a random length, and using a low-power-consumption Bluetooth protocol to scan the slave equipment as the master equipment.
S301, after the connection between the master device and the slave device is determined and interrupted, the slave time slice with random length is obtained and used as the slave device to send out a Bluetooth broadcast signal by using a low-power Bluetooth protocol.
When the device is in the master device state, the slave device is scanned and connected with the device, at this time, the random time slice stops, after the connection, the device is confirmed not to be the target device needing to be connected through the identity information, and the device enters the slave device state.
When the identity is confirmed after the connection is established, the user can click and confirm through the touch screen, or can confirm through the body by using a preset action.
S302, determining that the connection with the master device is not established in the slave time slices with random lengths, and returning to the step S300.
To sum up, in this embodiment, after the bluetooth function is turned on, the device is in the master device state, and the device is made to alternately serve as the master device and the slave device in an automatic random time slice manner until the multiple devices are in different states to establish connection, and it is determined that the connected device is not the target device, and then the cycle of the random time slice is continued, so that the connection is more convenient, the complexity of the user operation is simplified, the user experience is improved, and the connection accuracy is ensured.
In this embodiment, preferably, when the device is in the master device state, if at least two slave devices are detected, the bluetooth signal strengths of the slave devices are sorted, and the slave devices are sequentially connected from strong to weak according to the bluetooth signal strengths. And when the connected slave equipment is not the target equipment, disconnecting and discarding the Bluetooth signal of the slave equipment, and connecting in sequence from strong to weak according to the strength of the Bluetooth signal. Ensure that the face-to-face users can successfully connect at one time when exchanging information.
Please refer to fig. 4, which is a flowchart illustrating a method for bluetooth low energy connection according to a fourth embodiment of the present invention. The difference between this embodiment and the method shown in fig. 3 is that, after connection, the present embodiment finds that the target device does not need to be connected, and then enters the master device state.
The connection method of the low-power Bluetooth comprises the following steps:
s400, acquiring a master time slice with a random length, and using a low-power-consumption Bluetooth protocol to scan the slave equipment as the master equipment.
S401, after the connection between the master device and the slave device is determined and interrupted, a master time slice with random length is obtained and used as the master device to scan the slave device by using a low-power-consumption Bluetooth protocol.
When the equipment is in the state of the master equipment, the slave equipment is scanned and connected with the slave equipment, at the moment, the random time slice stops, the slave equipment is confirmed not to be the target equipment needing to be connected through the identity information after connection, and the equipment enters the state of the master equipment.
When the identity is confirmed after the connection is established, the user can click and confirm through the touch screen, or can confirm through the body by using a preset action.
S402, determining that no connection is established with the slave device in the master time slice with the random length.
And S403, acquiring slave time slices with random lengths, and sending out a Bluetooth broadcast signal by using a low-power Bluetooth protocol as a slave device.
S404, determining that the connection with the master device is not established in the slave time slices with random lengths, and returning to the step S400.
To sum up, in this embodiment, after the bluetooth function is turned on, the device is in the master device state, and the device is made to alternately serve as the master device and the slave device in an automatic random time slice manner until the multiple devices are in different states to establish connection, and it is determined that the connected device is not the target device, and then the cycle of the random time slice is continued, so that the connection is more convenient, the complexity of the user operation is simplified, the user experience is improved, and the connection accuracy is ensured.
Please refer to fig. 5, which is a flowchart illustrating a method for bluetooth low energy connection according to a fifth embodiment of the present invention. The present embodiment is different from the method shown in fig. 2 in that the present embodiment performs processing after connection if it finds that the target device does not need to be connected.
And S500, acquiring a slave time slice with a random length, and sending out a Bluetooth broadcast signal by using a low-power Bluetooth protocol as a slave device.
S501, after the connection between the slave device and the master device is determined and interrupted, a master time slice with random length is obtained and used as the master device to scan the slave device by using a low-power-consumption Bluetooth protocol.
When the equipment is in the slave equipment state, connection is established with the master equipment, at the moment, the random time slice stops, after connection, the equipment is confirmed to be not the target equipment needing connection through the identity information, and the equipment enters the master equipment state.
When the identity is confirmed after the connection is established, the user can click and confirm through the touch screen, or can confirm through the body by using a preset action.
And S502, determining that the connection with the slave equipment is not established in the master time slice with the random length, and returning to the step S500.
To sum up, in this embodiment, after the bluetooth function is turned on, the device is in the slave device state, and the device is made to alternately serve as the master device and the slave device in an automatic random time slice manner until the multiple devices are in different states to establish connection, and it is determined that the connected device is not the target device, and then the cycle of the random time slice is continued, so that the connection is more convenient, the complexity of the user operation is simplified, the user experience is improved, and the connection accuracy is ensured.
Please refer to fig. 6, which is a flowchart illustrating a method for bluetooth low energy connection according to a sixth embodiment of the present invention. The difference between this embodiment and the method shown in fig. 5 is that, after connection, the present embodiment finds that the target device does not need to be connected, and then enters a slave device state.
S600, acquiring a slave time slice with a random length, and using the slave device to send out a Bluetooth broadcast signal by using a low-power Bluetooth protocol.
S601, after the connection between the slave device and the master device is established and interrupted, the slave time slice with random length is obtained and used as the slave device to send out Bluetooth broadcast signals by using a low-power-consumption Bluetooth protocol.
When the equipment is in the slave equipment state, connection is established with the master equipment, at this time, the random time slice stops, after connection, the equipment is confirmed to be not the target equipment needing connection through the identity information, and the equipment enters the slave equipment state.
When the identity is confirmed after the connection is established, the user can click and confirm through the touch screen, or can confirm through the body by using a preset action.
And S602, determining that no connection is established with the master device in the slave time slices with random lengths.
S603, acquiring a master time slice with a random length, and using a low-power-consumption Bluetooth protocol to scan the slave equipment as the master equipment.
S604, determining that the connection with the slave equipment is not established in the master time slice with the random length, and returning to the step S600.
To sum up, in this embodiment, after the bluetooth function is turned on, the device is in the slave device state, and the device is made to alternately serve as the master device and the slave device in an automatic random time slice manner until the multiple devices are in different states to establish connection, and it is determined that the connected device is not the target device, and then the cycle of the random time slice is continued, so that the connection is more convenient, the complexity of the user operation is simplified, the user experience is improved, and the connection accuracy is ensured.
Please refer to fig. 7, which is a flowchart illustrating a method of a bluetooth low energy connection apparatus according to a first embodiment of the present invention. This bluetooth low energy's connecting device includes:
a master time slice acquiring unit 10, configured to acquire a master time slice with a random length, as a master device, to scan a slave device using a bluetooth low energy protocol;
a first connection determination unit 20 for determining that no connection is established with the slave device within a master time slice of random length;
a first triggering unit 30 for triggering the slave time slice acquiring unit when no connection is established with the slave device within a master time slice of random length;
a slave slot acquiring unit 40 for acquiring a slave slot of a random length as a slave device for transmitting a bluetooth broadcast signal using a bluetooth low energy protocol;
a second connection confirming unit 50 for determining that no connection is established with the master device within a slave time slice of random length;
a second triggering unit 60, configured to trigger the master time slice obtaining unit when no connection is established with the master device within a slave time slice of a random length.
For details of the apparatus, please refer to the method described in fig. 1 and fig. 2, which is not described herein again.
In summary, in this embodiment, after the bluetooth function is turned on, the device is alternately used as the master device and the slave device by means of the automatic random time slice, so that it is avoided that multiple devices are simultaneously the master device or the slave device and cannot be scanned, the length of the time slice is randomly generated, and when the devices circulate to be in different master-slave modes, the connection is established, which is more convenient, simplifies the complexity of the user operation, and improves the user experience.
In other embodiments, the method further comprises:
the first connection interruption unit is used for acquiring a slave time slice with random length and sending a Bluetooth broadcast signal as a slave device by using a low-power Bluetooth protocol after determining that the master device is connected with the slave device and interrupted; or, after determining that the master device is connected to the slave device and then is interrupted, acquiring a master time slice with a random length, and using a bluetooth low energy protocol to scan the slave device as the master device.
Specifically, when the method shown in fig. 3 is used, the first connection interruption unit is configured to determine that the master device is connected to the slave device and then interrupt, and then obtain a slave time slice with a random length, and send out a bluetooth broadcast signal using a bluetooth low energy protocol as the slave device.
When the method shown in fig. 4 is used, the first connection interruption unit is configured to determine that the master device is connected to the slave device and then interrupts the connection, and then obtain a master time slice with a random length, which is used as the master device to scan the slave device by using the bluetooth low energy protocol. The accuracy of connection is improved by verifying whether the connected equipment is the target equipment.
In other embodiments, the method further comprises:
the second connection interruption unit is used for acquiring a master time slice with random length after determining that the master device is connected with the slave device and interrupted, and the master device scans the slave device by using a low-power Bluetooth protocol; or, after determining that the slave device is connected with the master device and is interrupted, acquiring a slave time slice with a random length, and sending out a bluetooth broadcast signal by using a low-power-consumption bluetooth protocol as the slave device.
Specifically, when the method shown in fig. 5 is used, the second connection interruption unit is configured to determine that the slave device is connected to the master device and then interrupts the connection, and then obtain a master time slice with a random length, and scan the slave device as the master device using the bluetooth low energy protocol.
When the method shown in fig. 6 is used, the second connection interruption unit is used for determining that the slave device is disconnected after establishing connection with the master device, and acquiring a slave time slice with random length as the slave device to send out a bluetooth broadcast signal by using a low-power bluetooth protocol. The accuracy of connection is improved by verifying whether the connected equipment is the target equipment.
Preferably, the method further comprises the following steps:
and the signal intensity connecting unit is used for sequencing the Bluetooth signal intensities of the slave devices if at least two slave devices are detected, and sequentially connecting the slave devices according to the Bluetooth signal intensities from strong to weak. Through being connected with the slave unit from strong to weak in proper order according to bluetooth signal strength, once realize connecting when guaranteeing face-to-face carrying out the information interaction, improve connection efficiency.
And a random time acquiring unit for acquiring the master time slice with the random length and the slave time slice with the random length by a formula T2 ═ ((Rand ()% N) +1) × T1, wherein T1 is a minimum time unit for switching of the low power consumption Bluetooth device, and N is an integer greater than 1 and less than 20. The master time slice with random length and the slave time slices with random length are both random time slices.
The above description is only a preferred embodiment of the present invention, and for those skilled in the art, the present invention should not be limited by the description of the present invention, which should be interpreted as a limitation.