US-12627978-B2 - Method and apparatus for detecting communication device, communication device, and storage medium
Abstract
A communication device detection method includes: broadcasting first information by a first communication device, where the first information includes a first identifier (ID) associated with a second communication device and a public key of the first communication device; receiving second information; decrypting the second information by using a private key of the first communication device; and determining that the second communication device is detected in response to determining that the second information is successfully decrypted and a second ID included in the second information has a predetermined corresponding relation with the first ID.
Inventors
- Lei Yu
- Xiaolong Li
Assignees
- BEIJING XIAOMI MOBILE SOFTWARE CO., LTD.
Dates
- Publication Date
- 20260512
- Application Date
- 20210419
Claims (19)
- 1 . A method for detecting a communication device, executed by a first communication device, and comprising: broadcasting first information, wherein the first information comprises a first identifier (ID) associated with a second communication device and a public key of the first communication device; receiving second information; decrypting the second information by using a private key of the first communication device; and determining that the second communication device is detected in response to determining that the second information is successfully decrypted and a second ID comprised in the second information has a predetermined corresponding relation with the first ID; wherein the second information further comprises a second random number; and determining that the second communication device is detected in response to determining that the second information is successfully decrypted and the second ID has the predetermined corresponding relation with the first ID comprises: determining that the second communication device is detected in response to determining that the second information is successfully decrypted, the second ID has the predetermined corresponding relation with the first ID and the second random number is obtained for a first time.
- 2 . The method according to claim 1 , wherein integrity protection is performed on the first information by using the private key of the first communication device.
- 3 . The method according to claim 1 , wherein the first information further comprises a first random number, and the first random number is encrypted by using the public key of the first communication device; and determining that the second communication device is detected in response to determining that the second information is successfully decrypted and the second ID has the predetermined corresponding relation with the first ID comprises: determining that the second communication device is detected in response to determining that the second information is successfully decrypted, the second ID has the predetermined corresponding relation with the first ID and the second information comprises the first random number.
- 4 . The method according to claim 1 , further comprising: determining a relative distance between the first communication device and the second communication device based on a time of flight of the first information and the second information, wherein the time of flight of the first information and the second information comprises propagation duration of the first information and the second information in a medium.
- 5 . The method according to claim 4 , further comprising: determining the time of flight of the first information and the second information based on a first time interval and a second time interval, wherein the first time interval indicates a time interval from broadcasting the first information to receiving the second information by the first communication device, and the second time interval indicates a time interval from receiving the first information to broadcasting the second information by the second communication device.
- 6 . The method according to claim 5 , wherein the second information comprises first indication information, and the first indication information is configured to indicate the second time interval.
- 7 . The method according to claim 5 , further comprising: receiving third information, wherein the third information comprises second indication information, and the second indication information is configured to indicate the second time interval.
- 8 . The method according to claim 7 , wherein the third information is encrypted by using the public key of the first communication device; and the receiving third information comprises: receiving the third information; and decrypting the third information by using the private key of the first communication device.
- 9 . The method according to claim 4 , wherein the first information further comprises an application ID, and the application ID is configured to represent an application that needs the relative distance.
- 10 . The method according to claim 1 , wherein the first information further comprises a command ID, and the command ID is configured to represent the first information; and determining that the second communication device is detected in response to determining that the second information is successfully decrypted and the second ID has the predetermined corresponding relation with the first ID comprises: determining that the second communication device is detected in response to determining that the second information is successfully decrypted, the second ID has the predetermined corresponding relation with the first ID and the second information comprises the command ID.
- 11 . A non-transitory computer-readable storage medium, storing an instruction, wherein when executed by a processor, the instruction causes the processor to implements the method according to claim 1 .
- 12 . A method for transmitting information, executed by a second communication device, and comprising: receiving first information, and obtaining a first identifier (ID) and a public key of a first communication device that are comprised in the first information; and determining that the first ID and a second ID stored in the second communication device have a predetermined corresponding relation, and broadcasting second information, wherein the second information comprises the second ID, and the second information is encrypted by using the public key of the first communication device, wherein the second information further comprises a second random number; and determining that the second communication device is detected in response to determining that the second information is successfully decrypted and the second ID has the predetermined corresponding relation with the first ID comprises: determining that the second communication device is detected in response to determining that the second information is successfully decrypted, the second ID has the predetermined corresponding relation with the first ID and the second random number is obtained for a first time.
- 13 . The method according to claim 12 , further comprising: performing integrity verification on the first information by using the public key of the first communication device.
- 14 . The method according to claim 12 , wherein the second information further comprises first indication information, the first indication information is configured to indicate a second time interval, and the second time interval indicates a time interval from receiving the first information to broadcasting the second information by the second communication device.
- 15 . The method according to claim 14 , wherein the first information further comprises an application ID; and the method further comprises: determining whether to comprise the first indication information in the second information based on the application ID.
- 16 . The method according to claim 12 , further comprising: broadcasting third information, wherein the third information comprises second indication information, the second indication information is configured to indicate a second time interval, and the second time interval indicates a time interval from receiving the first information to broadcasting the second information by the second communication device.
- 17 . A communication device apparatus, comprising a processor, a memory, and an executable program that is stored in the memory and runnable by the processor, wherein the processor executes steps of the method for detecting a communication device according to claim 12 when running the executable program.
- 18 . A non-transitory computer-readable storage medium, storing an instruction, wherein when executed by a processor, the instruction causes the processor to implement the method according to claim 12 .
- 19 . A communication device apparatus, comprising a processor, a memory, and an executable program that is stored in the memory and runnable by the processor, wherein the processor is configured to: broadcast first information, wherein the first information comprises a first identifier (ID) associated with a second communication device and a public key of the first communication device; receive second information; decrypt the second information by using a private key of the first communication device; and determine that the second communication device is detected in response to determining that the second information is successfully decrypted and a second ID comprised in the second information has a predetermined corresponding relation with the first ID; wherein the second information further comprises a second random number, and the processor is further configured to: determine that the second communication device is detected in response to determining that the second information is successfully decrypted, the second ID has the predetermined corresponding relation with the first ID and the second random number is obtained for a first time.
Description
CROSS REFERENCE TO RELATED APPLICATION The present application is a U.S. National Stage of International Application No. PCT/CN2021/088202, filed on PCT Apr. 19, 2021, the contents of all of which are incorporated herein by reference in their entireties for all purposes. BACKGROUND A distance between communication devices can be measured based on the time of flight (ToF) of a signal. A measurement signal is transmitted from a measurement device to a device to be measured, and received and returned by the device to be measured, and then the distance is measured by the measurement device based on the ToF. SUMMARY In view of this, examples of the disclosure provide a method and apparatus for detecting a communication device, a communication device, and a storage medium. According to a first aspect of the example of the disclosure, a method for detecting a communication device is provided. The method is executed by a first communication device, and includes: broadcasting first information, where the first information includes a first identifier (ID) associated with a second communication device and a public key of the first communication device; receiving second information; decrypting the second information by using a private key of the first communication device; and determining that the second communication device is detected in response to determining that the second information is successfully decrypted and a second ID included in the second information has a predetermined corresponding relation with the first ID. According to a second aspect of the example of the disclosure, a method for transmitting information is provided. The method is executed by a second communication device, and includes: receiving first information, and obtaining a first identifier (ID) and a public key of a first communication device that are included in the first information; and determining that the first ID and a second ID stored in the second communication device have a predetermined corresponding relation, and broadcasting second information, where the second information includes the second ID, and the second information is encrypted by using the public key of the first communication device. According to a third aspect of the example of the disclosure, a communication device apparatus is provided. The apparatus includes a processor, a memory, and an executable program that is stored in the memory and runnable by the processor, where the processor executes steps of the method for detecting a communication device in the first aspect or steps of the method for transmitting information in the second aspect when running the executable program. According to a fourth aspect of the example of the disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores an instruction, where the instruction implements the method in the first aspect or the second aspect when executed. It should be understood that the above general description and the following detailed description are merely illustrative and explanatory, and cannot limit the example of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS The drawings here are incorporated into the description as a constituent part of the description, illustrate examples conforming to the disclosure, and serve to explain principles of the examples of the disclosure along with the description. FIG. 1 is a schematic structural diagram of a radio communication system according to an example. FIG. 2 is a schematic flowchart of a method for detecting a communication device according to an example. FIG. 3 is a schematic diagram of time of flight according to an example. FIG. 4 is a schematic flowchart of another method for transmitting information according to an example. FIG. 5 is a block diagram of an apparatus for detecting a communication device according to an example. FIG. 6 is a block diagram of another apparatus for transmitting information according to an example. FIG. 7 is a block diagram of an apparatus for detecting a communication device or transmitting information according to an example. DETAILED DESCRIPTION Examples will be described in detail here, and their instances are shown in accompanying drawings. When the following description involves the accompanying drawings, the same numerals in different accompanying drawings indicate the same or similar elements unless otherwise indicated. Embodiments described in the following examples do not represent all embodiments consistent with the examples of the disclosure. On the contrary, these embodiments are merely instances of apparatuses and methods that are detailed in the appended claims and consistent with some aspects of the examples of the disclosure. Terms used in the examples of the disclosure are merely used for describing specific examples rather than limiting the examples of the disclosure. As used in the examples and the appended claims of the disclosure, the singular forms such as “a”, “an”, “