Proximity detection method and apparatus for near field communication
The present disclosure discloses a proximity detection method and apparatus for a near field communication, which belongs to the field of communications technologies. The method includes: sending, by a first electronic device, a signal of a detection frame; determining whether a second electronic device capable of performing the near field communication exists according to a received response frame, wherein the detection frame includes at least two symbols modulated with different frequencies. In embodiments of the present disclosure, a signal of a detection frame which includes multiple symbols modulated with different frequencies is sent, so that a peer-to-peer electronic device existing within a communicatable range can be detected for communication in a case of that these modulation frequencies suffer an interference.
1. A proximity detection method of a near field communication, applied to a first electronic device for the near field communication, wherein the method comprises:
sending a signal of a detection frame by the first electronic device, wherein the detection frame comprises at least two symbols modulated with different frequencies;
determining whether a second electronic device capable of performing the near field communication exists according to a received response frame;
wherein the detection frame comprises a first detection frame A 1 and a second detection frame A 2 , and the sending a signal of a detection frame by the first electronic device further comprises:
sending the first detection frame A 1 or the second detection frame A 2 ;
when a signal of the response frame replied by the second electronic device is received, switching a detection frame to be sent from the first detection frame A 1 to the second detection frame A 2 or from the second detection frame A 2 to the first detection frame A 1 .
2. The proximity detection method according to claim 1 , wherein the response frame comprises a first response frame B 1 and a second response frame B 2 , and the determining whether the second electronic device capable of performing the near field communication exists according to the received response frame further comprises:
increasing a first response time M 1 by 1 after receiving the response frame replied by the second electronic device;
if the response frame is the second response frame B 2 , increasing a second response time M 2 by 1, further determining whether M 2 meets a second threshold C 2 , and if yes, determining that the second electronic device is located within a near field communicatable range.
3. The proximity detection method according to claim 2 , wherein if the response frame replied by the second electronic device is not received again within a preset time, decreasing the first response time M 1 or the second response time M 2 by at least 1 time.
4. The proximity detection method according to claim 2 , wherein,
the first response frame B 1 is: [F 6 , F 5 , F 4 , F 3 , F 2 , F 1 ];
the second response frame B 2 is: [F 4 , F 5 , F 6 , F 1 , F 2 , F 3 ];
or
the first response frame B 1 is: [F 4 , F 3 , F 2 , F 1 ];
the second response frame B 2 is: [F 3 , F 4 , F 2 , F 1 ];
wherein the F 1 , F 2 , F 3 , F 4 , F 5 , F 6 are symbols modulated with different frequencies respectively.
5. The proximity detection method according to claim 1 , wherein,
the first detection frame A 1 is: [F 1 , F 2 , F 3 , F 4 , F 5 , F 6 ];
the second detection frame A 2 is: [F 3 , F 2 , F 1 , F 6 , F 5 , F 4 ];
or
the first detection frame A 1 is: [F 1 , F 2 , F 3 , F 4 ];
the second detection frame A 2 is: [F 2 , F 1 , F 4 , F 3 ];
wherein the F 1 , F 2 , F 3 , F 4 , F 5 , F 6 are symbols modulated with different frequencies respectively.
6. The proximity detection method according to claim 5 , wherein the F 1 , F 2 , F 3 , F 4 , F 5 , F 6 respectively represent symbols modulated with 450 KHz, 400 KHz, 350 KHz, 300 KHz, 250 KHz and 200 KHz, or any six neighbor frequencies in a frequency set {525 KHz, 487.5 KHz, 412.5 KHz, 375 KHz, 337.5 KHz, 262.5 KHz, 225 KHz, 187.5 KHz}.
7. A proximity detection method of a near field communication, applied to a second electronic device for the near field communication, wherein the method comprises:
receiving a signal of a detection frame sent by a first electronic device;
replying a response frame to the first electronic device, wherein the response frame comprises at least two symbols modulated with different frequencies; and
determining whether the first electronic device is within a near field communicatable range according to the received detection frame;
wherein the detection frame comprises a first detection frame A 1 and a second detection frame A 2 , and the replying the response frame to the first electronic device further comprises:
determining whether the signal of the detection frame is the first detection frame A 1 or the second detection frame A 2 after receiving the signal of the detection frame, and if the detection frame is the first detection frame A 1 and a first acknowledgement time N 1 is an even number, increasing the first acknowledgement time N 1 by 1, otherwise remaining the same; if the detection frame is the second detection frame A 2 and the first acknowledgement time N 1 is an odd number, increasing the first acknowledgement time N 1 by 1, otherwise remaining the same;
determining whether the first acknowledgement time N 1 exceeds a first threshold C 1 , and if the first acknowledgement time N 1 exceeds the first threshold C 1 , sending a second response frame B 2 to the first electronic device, otherwise, sending a first response frame B 1 to the first electronic device.
8. The proximity detection method according to claim 7 , wherein the determining whether the first electronic device is within the near field communicatable range according to the received detection frame further comprises:
when the first acknowledgement time N 1 exceeds the first threshold C 1 , if the signal of the detection frame is received, determining whether the signal of the detection frame is the first detection frame A 1 or the second detection frame A 2 , and if the detection frame is the first detection frame A 1 and a second acknowledgement time N 2 is an even number, increasing the second acknowledgement time N 2 by 1, otherwise remaining the same; if the detection frame is the second detection frame A 2 and the second acknowledgement time N 2 is an odd number, increasing the second acknowledgement time N 2 by 1, otherwise remaining the same;
determining whether the second acknowledgement time N 2 meets a second threshold C 2 , and if yes, determining that the first electronic device is located within the near field communicatable range.
9. The proximity detection method according claim 7 , wherein the detection frame comprises a first detection frame A 1 and a second detection frame A 2 , and the response frame comprises a first response frame B 1 and a second response frame B 2 , wherein:
the first detection frame A 1 is: [F 1 , F 2 , F 3 , F 4 , F 5 , F 6 ];
the second detection frame A 2 is: [F 3 , F 2 , F 1 , F 6 , F 5 , F 4 ];
the first response frame B 1 is: [F 6 , F 5 , F 4 , F 3 , F 2 , F 1 ];
the second response frame B 2 is: [F 4 , F 5 , F 6 , F 1 , F 2 , F 3 ];
or
the first detection frame A 1 is: [F 1 , F 2 , F 3 , F 4 ];
the second detection frame A 2 is: [F 2 , F 1 , F 4 , F 3 ];
the first response frame B 1 is: [F 4 , F 3 , F 2 , F 1 ];
the second response frame B 2 is: [F 3 , F 4 , F 2 , F 1 ];
wherein the F 1 , F 2 , F 3 , F 4 , F 5 , F 6 are symbols modulated with different frequencies respectively.
10. The proximity detection method according to claim 9 , wherein the F 1 , F 2 , F 3 , F 4 , F 5 , F 6 respectively represent symbols modulated with 450 KHz, 400 KHz, 350 KHz, 300 KHz, 250 KHz and 200 KHz, or any six neighbor frequencies in a frequency set {525 KHz, 487.5 KHz, 412.5 KHz, 375 KHz, 337.5 KHz, 262.5 KHz, 225 KHz, 187.5 KHz}.
11. A proximity detection method of a near field communication, applied to a first electronic device and a second electronic device for the near field communication, wherein the method comprises:
sending, by the first electronic device, a signal of a detection frame;
replying, by the second electronic device, a response frame to the first electronic device, and determining whether the first electronic device is within a near field communicatable range according to a received detection frame; and
determining, by the first electronic device, whether the second electronic device is within the near field communicatable range according to a received response frame,
wherein both the detection frame and the response frame comprise at least two symbols modulated with different frequencies;
wherein the detection frame comprises a first detection frame A 1 and a second detection frame A 2 , and the sending a signal of a detection frame by the first electronic device further comprises:
sending the first detection frame A 1 or the second detection frame A 2 ;
when a signal of the response frame replied by the second electronic device is received, switching a detection frame to be sent from the first detection frame A 1 to the second detection frame A 2 or from the second detection frame A 2 to the first detection frame A 1 .
12. A proximity detection apparatus for a near field communication, applied to a first electronic device for the near field communication, wherein the apparatus comprises:
a transmitter, configured to send a signal of a detection frame, wherein the detection frame comprises at least two symbols modulated with different frequencies;
a receiver, configured to receive a signal of a response frame replied by a second electronic device; and
a processor, configured to analyze the response frame replied by the second electronic device and determine whether the second electronic device is within a near field communicatable range according to the received response frame;
wherein the transmitter is configured to: send a first detection frame A 1 or a second detection frame A 2 ; when the signal of the response frame replied by the second electronic device is received, switch the detection frame to be sent from the first detection frame A 1 to the second detection frame A 2 or from the second detection frame A 2 to the first detection frame A 1 .
13. The proximity detection apparatus according to claim 12 , wherein the processor is configured to: when the received response frame replied by the second electronic device is a second response frame B 2 , increase a second response time M 2 by 1, further determine whether M 2 meets a second threshold C 2 , and if yes, determine that the second electronic device is located within the near field communicatable range.
14. A proximity detection apparatus for a near field communication, applied to a second electronic device for the near field communication, wherein the apparatus comprises:
a receiver, configured to receive a signal of a detection frame sent by a first electronic device;
a transmitter, configured to send a response frame to the first electronic device, wherein the response frame comprises at least two symbols modulated with different frequencies; and
a processor, configured to analyze the signal of the detection frame and determine whether the first electronic device is within a near field communicatable range according to the received detection frame;
wherein the processor is configured to: determine whether the signal of the detection frame is a first detection frame A 1 or a second detection frame A 2 after receiving the signal of the detection frame, and if the detection frame is the first detection frame A 1 and a first acknowledgement time N 1 is an even number, increase the first acknowledgement time N 1 by 1, otherwise remain the same; if the detection frame is the second detection frame A 2 and the first acknowledgement time N 1 is an odd number, increase the first acknowledgement time N 1 by 1, otherwise remain the same; and
the transmitter is configured to determine whether the first acknowledgement time N 1 exceeds a first threshold C 1 , and if the first acknowledgement time N 1 exceeds the first threshold C 1 , send a second response frame B 2 to the first electronic device, otherwise, send a first response frame B 1 to the first electronic device.
15. The proximity detection apparatus according to claim 14 , wherein the processor is configured to: when the first acknowledgement time N 1 exceeds the first threshold C 1 , if the signal of the detection frame is received, determine whether the signal of the detection frame is the first detection frame A 1 or the second detection frame A 2 , and if the detection frame is the first detection frame A 1 and a second acknowledgement time N 2 is an even number, increase the second acknowledgement time N 2 by 1, otherwise remain the same; if the detection frame is the second detection frame A 2 and the second acknowledgement time N 2 is an odd number, increase the second acknowledgement time N 2 by 1, otherwise remain the same; determine whether the second acknowledgement time N 2 meets a second threshold C 2 , and if yes, determine that the first electronic device is located within the near field communicatable range.