CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a national stage of International Application No. PCT/CN2016/097723, filed on Aug. 31, 2016, which is hereby incorporated by reference in its entirety.

TECHNICAL FIELD

The present invention relates to the communications field, and in particular, to a method for discovering a Bluetooth device and a Bluetooth device.

BACKGROUND

Bluetooth (Bluetooth) is a radio technology that supports short-distance (for example, within 10 m) communication between devices. The Bluetooth technology can be used to exchange wireless information between devices such as a mobile phone, a PDA, a wireless headset, a laptop computer, and a peripheral device.

In the prior art, a Bluetooth device may discover another Bluetooth device through Bluetooth scanning, or may be discovered by another Bluetooth device through Bluetooth broadcasting. If a Bluetooth device A needs to discover a nearby Bluetooth device, the Bluetooth device A may perform Bluetooth scanning to scan broadcast frames broadcast by all surrounding Bluetooth devices. If a Bluetooth device B expects to be detected by the Bluetooth device A at any time, the Bluetooth device B needs to keep performing Bluetooth broadcasting, so that the Bluetooth device A can discover the Bluetooth device B.

Because the Bluetooth device B needs to keep performing Bluetooth broadcasting, power consumption of the Bluetooth device B is high.

SUMMARY

The present invention provides a method for discovering a Bluetooth device and a Bluetooth device, to reduce power consumption of the Bluetooth device.

According to a first aspect, a method for discovering a Bluetooth device is provided. The method includes:

receiving, by a second Bluetooth device, a first broadcast frame of a first Bluetooth device;

determining, by the second Bluetooth device, whether the first broadcast frame includes first indication information; and

if the first broadcast frame includes the first indication information, sending, by the second Bluetooth device, at least one second broadcast frame within a preset time period after receiving the first broadcast frame, where the second broadcast frame includes second indication information, and the second indication information is used to instruct a Bluetooth device receiving the second broadcast frame to exchange information with the second Bluetooth device.

The first indication information is configured to trigger a Bluetooth device receiving the first broadcast frame to broadcast.

Optionally, the second Bluetooth device may periodically send, within the preset time period after receiving the first broadcast frame, the at least one second broadcast frame at a certain interval.

After receiving the broadcast frame including the first indication information, the second Bluetooth device sends the second broadcast frame, so as to instruct the Bluetooth device receiving the second broadcast frame to exchange information with the second Bluetooth device. This avoids that the second Bluetooth device keeps broadcasting and reduces power consumption of the second Bluetooth device.

In addition, because the second Bluetooth device does not need to keep broadcasting, a risk of leaking information of the second Bluetooth device can be reduced, security performance of the second Bluetooth device can be improved, and privacy of the second Bluetooth device can be protected.

In a possible implementation, the first broadcast frame further includes characteristic information of the first Bluetooth device, and the sending, by the second Bluetooth device, a second broadcast frame includes:

determining, by the second Bluetooth device according to the characteristic information of the first Bluetooth device, whether a preset broadcast condition is met; and

if the preset broadcast condition is met, sending, by the second Bluetooth device, the second broadcast frame.

In this way, it can be avoided that the second Bluetooth device broadcasts when the preset condition is not met, and the second Bluetooth device cannot be discovered by another Bluetooth device. Therefore, security performance of the second Bluetooth device can be further improved.

In a possible implementation, the characteristic information of the first Bluetooth device includes indication information of a service that needs to be provided by another Bluetooth device and that is required by the first Bluetooth device; and the determining, by the second Bluetooth device according to the characteristic information of the first Bluetooth device, whether a preset broadcast condition is met includes:

determining, by the second Bluetooth device according to the indication information of the service, whether the service can be provided.

That the second Bluetooth device meets the preset broadcast condition includes: the second Bluetooth device can provide the service.

In this way, it can be avoided that the second Bluetooth device broadcasts when the second Bluetooth device cannot provide the service required by the first Bluetooth device, so as to reduce power consumption of the second Bluetooth device.

In a possible implementation, the characteristic information of the first Bluetooth device includes first information used to identify the first Bluetooth device; and the determining, by the second Bluetooth device according to the characteristic information of the first Bluetooth device, whether a preset broadcast condition is met includes:

determining, by the second Bluetooth device according to the first information, whether the second Bluetooth device is allowed to be discovered by the first Bluetooth device.

That the second Bluetooth device meets the preset broadcast condition includes: the second Bluetooth device is allowed to be discovered by the first Bluetooth device.

In this way, it can be avoided that the second Bluetooth device is discovered by another Bluetooth device that is not allowed to discover the second Bluetooth device. Therefore, security performance of the second Bluetooth device can be further improved.

In a possible implementation, the characteristic information of the first Bluetooth device includes second information used to identify a user of the first Bluetooth device; and the determining, by the second Bluetooth device according to the characteristic information of the first Bluetooth device, whether a preset broadcast condition is met includes:

determining, by the second Bluetooth device according to the second information, whether the user of the first Bluetooth device is a contact of a user of the second Bluetooth device.

That the second Bluetooth device meets the preset broadcast condition includes: the second Bluetooth device is the contact of the user of the second Bluetooth device.

In this way, the second Bluetooth device can only be discovered by the Bluetooth device used by the contact of the user of the second Bluetooth device, and security performance of the second Bluetooth device can be further improved.

In a possible implementation, the first broadcast frame further includes third information, and the third information is used to identify a Bluetooth device that the first Bluetooth device wants to discover; and before the sending, by the second Bluetooth device, a second broadcast frame, the method further includes:

determining, by the second Bluetooth device according to the third information, that the second Bluetooth device is the Bluetooth device that the first Bluetooth device wants to discover.

In a possible implementation, the method further includes: if the second Bluetooth device does not receive, after the preset time period, the first broadcast frame sent by the first Bluetooth device, stopping, by the second Bluetooth device, sending the second broadcast frame.

In this way, it can be avoided that the second Bluetooth device keeps sending the second broadcast frame.

In a possible implementation, the second broadcast frame further includes at least one of the following information: indication information of a service that can be provided by the second Bluetooth device, information used to identify the second Bluetooth device, or information used to identify the user of the second Bluetooth device.

In this way, the first Bluetooth device filters discovered Bluetooth devices and selects a Bluetooth device that meets the condition to exchange information.

In a possible implementation, the second indication information is used to instruct the Bluetooth device receiving the second broadcast frame to broadcast or initiate a connection to the second Bluetooth device, so as to exchange information with the second Bluetooth device.

In a possible implementation, the first Bluetooth device and the second Bluetooth device are Bluetooth low energy devices or dual-mode Bluetooth devices.

According to a second aspect, a method for discovering a Bluetooth device is provided. The method includes:

sending, by a first Bluetooth device, a first broadcast frame, where the first broadcast frame includes first indication information, and the first indication information is used to trigger a Bluetooth device receiving the first broadcast frame to broadcast;

receiving, by the first Bluetooth device, a second broadcast frame sent by a second Bluetooth device according to the first broadcast frame;

determining, by the first Bluetooth device, whether the second broadcast frame includes second indication information; and

if the second broadcast frame includes the second indication information, exchanging, by the first Bluetooth device, information with the second Bluetooth device according to the second broadcast frame.

The second indication information is used to instruct a Bluetooth device receiving the second broadcast frame to exchange information with the second Bluetooth device.

The Bluetooth device broadcasts the first broadcast frame including the first indication information, and the Bluetooth device may discover the second Bluetooth device after receiving the second broadcast frame broadcast by the second Bluetooth device according to the first broadcast frame. This avoids that the discovered second Bluetooth device keeps broadcasting, and therefore power consumption of the second Bluetooth device can be reduced.

In a possible implementation, the first broadcast frame further includes characteristic information of the first Bluetooth device.

In a possible implementation, the characteristic information of the first Bluetooth device includes at least one of the following information: indication information of a service that needs to be provided by another Bluetooth device and that is required by the first Bluetooth device, first information used to identify the first Bluetooth device, or second information used to identify a user of the first Bluetooth device.

In a possible implementation, the second broadcast frame further includes at least one of the following information: indication information of a service that can be provided by the second Bluetooth device, information used to identify the second Bluetooth device, or information used to identify a user of the second Bluetooth device.

In a possible manner, the exchanging, by the first Bluetooth device, information with the second Bluetooth device according to the second broadcast frame includes: broadcasting, by the first Bluetooth device according to the second broadcast frame, or initiating a connection to the second Bluetooth device according to the second broadcast frame, so as to exchange information with the second Bluetooth device.

In a possible implementation, the first Bluetooth device and the second Bluetooth device are Bluetooth low energy devices or dual-mode Bluetooth devices.

According to a third aspect, a Bluetooth device is provided. The Bluetooth device is configured to implement the method according to the first aspect or any one of the foregoing possible implementations of the first aspect.

Specifically, the Bluetooth device may include units configured to execute the method according to the first aspect or any possible implementation of the first aspect.

According to a fourth aspect, a Bluetooth device is provided. The Bluetooth device is configured to implement the method according to the second aspect or any one of the foregoing possible implementations of the second aspect.

Specifically, the Bluetooth device may include units configured to execute the method according to the second aspect or any possible implementation of the second aspect.

According to a fifth aspect, a Bluetooth device is provided, including: a processor, a transceiver, a memory, and a bus system. The processor, the transceiver, and the memory are connected by using the bus system. The memory is configured to store an instruction or code, and the processor is configured to execute the instruction or code stored in the memory, so that the Bluetooth device executes the method according to any one of the first aspect or any possible implementation of the first aspect.

According to a sixth aspect, a Bluetooth device is provided, including: a processor, a transceiver, a memory, and a bus system. The processor, the transceiver, and the memory are connected by using the bus system. The memory is configured to store an instruction or code, and the processor is configured to execute the instruction or code stored in the memory, so that the Bluetooth device executes the method according to any one of the second aspect or any possible implementation of the second aspect.

According to a seventh aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores a program, and the program enables a Bluetooth device to execute the method according to the first aspect or any possible implementation of the first aspect.

According to an eighth aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores a program, and the program enables a Bluetooth device to execute the method according to the second aspect or any possible implementation of the second aspect.

