| CPC G01R 33/0023 (2013.01) [G01R 33/0047 (2013.01); G01R 33/02 (2013.01)] | 20 Claims |

|
1. An electronic device comprising:
a magnetic sensor configured to identify an intensity of a magnetic field;
a wireless communication circuit;
a processor comprising processing circuitry; and
a memory electrically connected to the magnetic sensor, the wireless communication circuit, and the processor, and configured to store instructions,
wherein the processor is individually and/or collectively configured to cause the electronic device to:
identify a plurality of intensities of the magnetic field during a first period at least by using the magnetic sensor;
identify a first state of the electronic device indicating an attached state or a detached state of an accessory device based on a comparison result between the plurality of intensities and a reference intensity;
based on identifying the first state of the electronic device, emit a short-range wireless signal through the wireless communication circuit at a first cycle during a first time;
identify a second state of the electronic device indicating the attached state or the detached state of the accessory device based on a response signal to the wireless signal emitted at the first cycle during the first time; and
finally identify a state of the electronic device indicating the attached state or the detached state of the accessory device based on the first identification result and second identification result.
|