Near field communication control method, device, electronic device and storage medium
By turning off the card simulation function when the NFC module disconnects the radio frequency connection from the device, and judging whether to restart the function based on the displacement data, the problem of multiple resource transfers in NFC technology is solved, and the accuracy of resource transfer and user experience are improved.
Patent Information
- Application Number
- CN202010983235.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-17
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-09-17
AI Technical Summary
Existing NFC technology is prone to inaccuracies during the transfer of numerical resources, especially when the radio frequency connection is unstable, resulting in multiple repeated transfer operations and unable to meet the actual needs of users.
Turn off the card simulation function by receiving events generated by the NFC module, obtain the device's displacement data, and reopen the card simulation function when the displacement data meets specific conditions to ensure that multiple errors under abnormal circumstances are avoided after the device is disconnected from the card reader. transfer operations.
It realizes that the card simulation function can be directly turned off when the NFC module disconnects the radio frequency connection from the device, avoiding multiple numerical resource transfers, ensuring that restarting the card simulation function after the device is far away does not affect the normal transfer operation, improving the accuracy of resource transfer and users experience.
Smart Images

Figure CN114202333B
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a control method, device, electronic device and storage medium for near field communication. Background Art
[0002] Near Field Communication (NFC) is an emerging technology that allows devices using NFC technology (such as mobile phones, smart wearable devices, etc.) to exchange data when they are close to each other. Currently, many mobile phones, wearable devices and other electronic devices have NFC functions. One of the main applications of these electronic devices with NFC functions in the market is to use NFC to simulate the functions of various cards (such as bus cards, bank cards) to transfer digital resources. The current NFC technology may result in inaccurate transfer of digital resources. Summary of the invention
[0003] The embodiments of the present application disclose a near field communication control method, device, electronic device and storage medium, which can accurately use the NFC module to transfer numerical resources and meet the actual needs of users.
[0004] The present application embodiment discloses a near field communication control method, which is applied to a first device, and the method includes:
[0005] If a first event generated by a near field communication NFC module is received, turning off the card emulation function of the NFC module, wherein the first event is used to indicate that the NFC module is disconnected from the second device through a radio frequency connection;
[0006] Acquiring displacement data of the first device;
[0007] When the displacement data meets the displacement condition, the card emulation function of the NFC module is enabled.
[0008] The present application embodiment discloses a near field communication control device, which is applied to a first device, and the device includes:
[0009] A closing module, configured to close the card emulation function of the near field communication NFC module upon receiving a first event generated by the NFC module, wherein the first event is used to indicate that the NFC module is disconnected from the second device through a radio frequency connection;
[0010] A displacement acquisition module, used to acquire displacement data of the first device;
[0011] The activation module is used to activate the card simulation function of the NFC module when the displacement data meets the displacement condition.
[0012] The embodiment of the present application discloses an electronic device, including a processor and an NFC module, wherein the processor is electrically connected to the NFC module;
[0013] The processor is configured to control the NFC module to disable a card simulation function if a first event generated by the NFC module is received, wherein the first event is used to indicate that the NFC module is disconnected from a radio frequency connection with a second device;
[0014] The processor is further configured to obtain displacement data of the first device, and when the displacement data meets a displacement condition, control the NFC module to enable the card emulation function.
[0015] An embodiment of the present application discloses an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor implements the method described above.
[0016] An embodiment of the present application discloses a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method described above is implemented.
[0017] The control method, apparatus, electronic device and storage medium of near field communication disclosed in the embodiments of the present application, if the first device receives a first event generated by the NFC module for characterizing that the NFC module is disconnected from the second device through radio frequency connection, the card simulation function of the NFC module is turned off, and the displacement data of the first device is obtained. When the displacement data meets the displacement condition, the card simulation function of the NFC module is turned on. When the NFC module is disconnected from the second device through radio frequency connection, the card simulation function of the NFC module is directly turned off. This can avoid the NFC module from performing multiple numerical resource transfer operations under abnormal circumstances. After detecting that the first device is far away from the second device using the displacement data of the first device, the card simulation function of the NFC module is restarted, which does not affect the next normal numerical resource transfer operation. The NFC module can be accurately used for numerical resource transfer, which meets the actual needs of users. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 An application scenario diagram of a near field communication control method in an embodiment;
[0020] Figure 2 is a structural block diagram of an electronic device in one embodiment;
[0021] Figure 3 is a flow chart of a method for controlling near field communication in one embodiment;
[0022] Figure 4 is a structural block diagram of an electronic device in another embodiment;
[0023] Figure 5 is a structural block diagram of an electronic device in another embodiment;
[0024] Figure 6 is a flow chart of a method for controlling near field communication in another embodiment;
[0025] Figure 7 is a flow chart of a method for controlling near field communication in another embodiment;
[0026] Figure 8 is a block diagram of a control device for near field communication in one embodiment;
[0027] Fig. 9 FIG. 4 is a structural block diagram of an electronic device in another embodiment. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0029] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present application and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.
[0030] It is understood that the terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first event may be referred to as a second event, and similarly, a second event may be referred to as a first event. Both the first event and the second event are events, but they are not the same event.
[0031] The NFC technology standard is a short-range (within 10cm) wireless communication technology initiated by Philips (later an independent NXP company) and jointly promoted by famous manufacturers such as Nokia and Sony. The operating frequency of NFC is usually 13.56MHz. NFC technology can mainly include three different modes: 1. Card simulation mode, which can use electronic devices supporting NFC technology as various cards (such as bank cards, bus cards, access cards, etc.), and perform corresponding processing in other NFC radio devices (such as electronic transfer, opening doors, etc.); 2. Card reader mode, which can read and write information from other media such as labels, stickers, business cards with NFC chips through electronic devices supporting NFC technology; 3. Peer-to-peer mode, which can be used for data exchange between different NFC devices, such as exchanging pictures and other data.
[0032] When a user uses the card simulation function of NFC technology on an electronic device, such as when taking a bus, subway or other means of transportation, there may be a situation where the user swipes the card on the electronic device once but multiple transfers of digital resources (such as deductions) occur. The main reason is that when the user places the electronic device on the NFC card reader for operation, the electronic device may lose the NFC connection with the NFC card reader due to unstable non-contact radio frequency connection and then quickly reconnect. After the electronic device re-establishes the NFC connection with the NFC card reader, a new digital resource transfer operation will be re-generated, resulting in a situation where the user swipes the card on the electronic device on the NFC card reader once, but multiple transfers of digital resources occur.
[0033] In the related art, the situation of repeated transfer of numerical resources can be avoided by temporarily turning off the NFC function of the electronic device, that is, turning on the NFC function after a delay and waiting for a period of time. However, when a user wants to transfer numerical resources multiple times (for example, he wants to swipe cards for multiple different people to take the bus), the interval time of the numerical resource transfer operation is limited, which may make the user mistakenly believe that the NFC function of the electronic device is abnormal and cannot meet the user's actual needs.
[0034] The embodiments of the present application provide a near field communication control method, device, electronic device and storage medium, which can prevent the NFC module from performing multiple numerical resource transfer operations under abnormal circumstances without affecting the next normal numerical resource transfer operation, and can accurately use the NFC module to transfer numerical resources, meeting the actual needs of users.
[0035] Figure 1 FIG. 1 is an application scenario diagram of a method for controlling near field communication in an embodiment. Figure 1As shown, the electronic device 10 supports NFC technology, and the electronic device 10 can establish an NFC communication connection with the target device 20. The electronic device 10 may include but is not limited to various electronic devices such as mobile phones, smart wearable devices, and tablet computers. The target device 20 may be an NFC radio frequency device with an NFC card reader function, and can read and write information from other media such as labels, stickers, and business cards with NFC chips.
[0036] When the NFC module of the electronic device 10 is in the card emulation mode, if the electronic device 10 receives a first event generated by the NFC module, the card emulation function of the NFC module is turned off, wherein the first event is used to indicate that the NFC module of the electronic device 10 is disconnected from the target device 20. The electronic device 10 can obtain displacement data, and when the displacement data meets the displacement condition, the card emulation function of the NFC module is turned off.
[0037] Figure 2 FIG. 1 is a structural block diagram of an electronic device in an embodiment. Figure 2 As shown, in one embodiment, the electronic device 10 may include a power management module (Power Management Unit, PMU) 110, a processor 120, an NFC module 130 and an NFC antenna 140, wherein the PMU 110 may be electrically connected to the processor 120 and the NFC module 130 respectively, and is used to provide power to the processor 120 and the NFC module 130, the NFC module 130 may be electrically connected to the processor 120 and the NFC antenna 140 respectively, the NFC antenna 140 may be used to receive a signal sent by a target device, and send a signal required to be transmitted by the NFC module 130 to the target device 20, etc., the processor 120 may be used to control the NFC module 130, and call the function of the NFC module 130 to perform a corresponding operation. Optionally, the processor 120 may include an application processor (Application Processor, AP), a central processing unit (central processing unit, CPU), etc., which are not limited here. The NFC module 130 may at least include an NFC chip, etc.
[0038] In the embodiment of the present application, when the NFC module 130 is in the card emulation mode, if it is detected that the NFC module 130 is disconnected from the target device, the processor 120 can control the NFC module to turn off the card emulation function. The processor 120 can obtain the displacement data of the electronic device 20, and when the displacement data meets the displacement condition, it can control the NFC module 130 to re-enable the card emulation function.
[0039] It should be noted that the electronic device 10 may include: Figure 2More or fewer components are shown, for example, the electronic device 10 may also include a display module, which is electrically connected to the processor 120 and can be used to display an interface of an application in the electronic device 10, etc., which is not limited here.
[0040] like Figure 3 As shown, in one embodiment, a method for controlling near field communication is provided, which can be applicable to a first device (i.e., the electronic device supporting NFC technology mentioned above), and the method may include the following steps:
[0041] Step 310: If a first event generated by a near field communication NFC module is received, the card emulation function of the NFC module is turned off, and the first event is used to indicate that the NFC module is disconnected from the second device through radio frequency connection.
[0042] The first device may refer to an electronic device that supports NFC technology. In the embodiment of the present application, the first device specifically refers to an electronic device that uses the card emulation function of the NFC module; the second device may refer to a target device. In the embodiment of the present application, the second device specifically refers to a device with an NFC card reader function.
[0043] In some embodiments, the user can select a card in an application running on the first device. After obtaining the card selected by the user, the first device can call the function function of the NFC module and pass the function parameter to the NFC module through the function function to control the NFC module to enter the card simulation mode. Optionally, the function parameter can be used to configure the mode of the NFC module. Optionally, the function parameter may include a communication mode, an operating mode, etc., but is not limited thereto. Among them, the communication mode may include active communication and passive communication. Active communication refers to the NFC module actively turning on the radio frequency field and discovering the surrounding NFC devices. The passive module refers to the NFC module not turning on the radio frequency field, but passively responding in the radio frequency field emitted by other devices. The operating mode may include Poll (discovery mode) and Listen (listening mode). As a specific implementation, the first device can configure the mode of the NFC module according to the started application when the application supporting NFC technology is started. For example, the application running the card can configure the NFC module to the card simulation mode, and the application running the card reader can configure the NFC module to the card reader mode, etc.
[0044] The NFC chip in the second device can be in active mode, constantly discovering devices entering its NFC radio frequency field, and sending Poll instructions to the discovered devices. When the NFC module of the first device is configured in card emulation mode, it can be in passive communication mode, and can passively respond after entering the radio frequency field of the second device. The NFC module of the first device is configured to Listen, and the NFC module will wait to receive the Poll instruction sent by the second device, and after receiving the instruction sent by the second device, it can establish an NFC communication connection with the second device.
[0045] After the NFC module of the first device establishes an NFC communication connection with the second device, the first device can perform a numerical resource transfer operation through the second device. The first device can obtain numerical resource transfer information, which may include the user's identity credential information, the transferred value, etc., wherein the identity credential information can be used to prove the user's identity, such as a digital signature, fingerprint information, etc. The first device can send the numerical resource transfer information to the second device via an NFC signal, and after the second device reads the numerical resource transfer information, it can upload the numerical resource transfer information to the corresponding server and complete the numerical resource transfer operation in the server.
[0046] In some embodiments, if the first device does not disconnect the NFC communication connection with the second device after completing the numerical resource transfer operation, the NFC module may maintain the current state and no longer perform the numerical resource transfer operation. The numerical resource transfer operation will only be performed again when the NFC module of the first device is reconnected to the second device.
[0047] If the first device receives the first event after completing the numerical resource transfer operation, the NFC module can be controlled to turn off the card simulation function. The first event can be used to characterize that the NFC module is disconnected from the second device. Due to the diversity of NFC readers and the non-standardization of some NFC readers, the RF connection coupling between the NFC reader and the first device may be unstable. In some embodiments, the NFC module can detect the field strength of the NFC RF field of the second device in real time, and the field strength may refer to the strength of the NFC RF magnetic field emitted by the second device. The NFC module can compare the detected field strength with a preset field strength threshold. If the detected field strength is less than the preset field strength threshold, a Field on event (i.e., the first event mentioned above) is triggered. The NFC module determines whether it is stably connected to the second device by detecting the field strength of the NFC RF field, and can accurately detect unstable phenomena.
[0048] After receiving the Field on event generated by the NFC module, the processor may send a shutdown command (such as the RF_DISCOVER_CMD command) to the NFC module. The shutdown command may carry the first function parameter of the card emulation function of the NFC module, and the first function parameter may at least include the shutdown parameter. After receiving the shutdown command, the NFC module may shut down the card emulation function according to the first function parameter carried by the shutdown command. The NFC module may return a response command (such as the RF_DISCOVER_RSP command) to the processor, and the processor may learn from the response command that the NFC module has shut down the card emulation function.
[0049] Step 320: Acquire displacement data of the first device.
[0050] After the NFC module turns off the card emulation function, the first device can detect whether it is far away from the second device. The displacement data of the first device can be obtained, and the first device can be judged whether it is far away from the second device based on the displacement data. The displacement data can be the data moved by the electronic device relative to the NFC when the card emulation function is turned off, or the data moved by the electronic device relative to the NFC when the transaction is carried out, etc., which is not limited here.
[0051] In some embodiments, the processor of the first device may calculate the displacement data based on the position data collected by the acceleration sensor. Optionally, the displacement data may be data moved by the first device relative to the NFC module when conducting a transaction. When the NFC module is activated by the NFC radio frequency field of the second device, the current position information of the first device may be obtained as the initial position information.
[0052] As a specific implementation, after the NFC module of the first device is turned on, it can detect the strength of the nearby NFC radio frequency field, and when it is detected that the strength of the nearby NFC radio frequency field is greater than the preset field strength threshold, it indicates that the first device has entered the NFC radio frequency field of the second device, and the NFC module can trigger a second event (i.e., Field on event), which can be used to characterize that the NFC module has detected the NFC radio frequency field of the second device. After the second device finds the first device entering its NFC radio frequency field, it can send an activation command (such as RF_INTF_ACTIVATED_NTF command) to the NFC module of the first device to activate the NFC module of the first device. It should be noted that the activation process of the NFC module can be understood as negotiating communication parameters (such as communication mode, transmission rate, etc.). After receiving the activation command sent by the second device, the NFC module of the first device can return a response command to the second device to complete the establishment of an NFC communication connection with the second device. After the NFC module of the first device is activated, data can be transmitted with the second device.
[0053] After turning off the card simulation function of the NFC module, the first device can obtain the real-time location information of the first device and calculate the displacement data of the real-time location information relative to the initial location information. When the NFC module receives the activation command, the processor of the first device can obtain the current location information of the first device from the acceleration sensor as the initial location information. After receiving the first event, the processor sends a shutdown command to the NFC module to control the NFC module to turn off the card simulation function, and can send a query displacement instruction to the acceleration sensor after receiving the response command from the NFC module to obtain the latest location information of the first device. Optionally, the processor can obtain the latest location information of the first device from the acceleration sensor in real time, and the processor can subtract the initial location information from the latest location information of the first device obtained in real time to obtain the displacement data of the real-time location information relative to the initial location information. In other embodiments, the processor can also obtain the latest location information of the first device from the acceleration sensor at a certain time interval, such as every 1 second, 2 seconds, etc., which is not limited here.
[0054] In the embodiment of the present application, the initial location information of the first device is obtained when the NFC module is activated, rather than when the second event is received, because when the NFC module is activated, the distance to the second device is relatively close, and the value resource transfer operation can be performed normally, while when the second event is received, the distance to the second device may be relatively far, and the initial location information obtained at this time is not accurate enough. Obtaining the initial location information of the first device when the NFC module is activated can improve the accuracy of obtaining location data.
[0055] Figure 4 FIG. 1 is a structural block diagram of an electronic device in another embodiment. Figure 4 As shown, in one embodiment, the electronic device 10 (i.e., the first device mentioned above) may include a PMU 110, a processor 120, an NFC module 130, an NFC antenna 140, and an accelerometer 150. The PMU 110 may be electrically connected to the processor 120, the NFC module 130, and the accelerometer 150, respectively, to provide power to the processor 120, the NFC module 130, and the accelerometer 150. The NFC antenna 140 may be electrically connected to the NFC module 130 to receive a signal sent by the second device, and to send a signal required to be transmitted by the NFC module to the second device.
[0056] The processor 120 may be electrically connected to the NFC module 130 and the acceleration sensor 150, respectively. Optionally, the processor 120 and the NFC module 130 may be connected via I2C (Inter-Integrated Circuit, two-wire serial bus) or SPI (Serial Peripheral Interface, serial peripheral interface), the processor 120 may transmit an enable signal (VEN) to the NFC module 130, thereby controlling the NFC module 130, and the NFC module 130 may transmit an interrupt signal (INT) to the processor 120. The processor 120 and the acceleration sensor 150 may be connected via I2C, the processor 120 may transmit an enable signal (VEN) to the acceleration sensor 150, thereby controlling the acceleration sensor 150, and the acceleration sensor 150 may also transmit an interrupt signal to the processor 120. The acceleration sensor 150 may be used to collect data such as the direction and offset of movement of the electronic device.
[0057] After the NFC module 130 receives the activation command sent by the second device, the processor 120 can obtain the current position information from the acceleration sensor 150 as the initial position information (X0, Y0, Z0), and control the NFC module 130 to transmit the corresponding data to the second device to perform the numerical resource transfer operation. When the NFC module 130 triggers the generation of the first event, the processor 120 receives the first event generated by the NFC module 130, and can obtain the real-time position information (X1, Y1, Z1) of the electronic device from the acceleration sensor 150, and calculate the displacement data of the real-time position information (X1, Y1, Z1) relative to the initial position information (X0, Y0, Z0), so that it can be judged according to the displacement data that the electronic device 10 is far away from the second device.
[0058] Figure 5 FIG. 1 is a structural block diagram of an electronic device in another embodiment. Figure 5 As shown, relative to Figure 4For example, the electronic device (i.e., the first device mentioned above) includes not only PMU 110, processor 120, NFC module 130, NFC antenna 140 and accelerometer 150, but also coprocessor 160. PMU 110 may be electrically connected to coprocessor 160 to provide power to coprocessor 160. Coprocessor 160 may be electrically connected to processor 120 and accelerometer 150, respectively, for processing position information of accelerometer 150 to obtain displacement data. Optionally, coprocessor 160 may be connected to accelerometer 150 via I2C, and may be connected to processor 120 via I2C or SPI. After NFC module 130 receives the activation command sent by the second device, processor 120 may send a position acquisition command to coprocessor 160, and coprocessor 160 may acquire current position information from accelerometer 150 as initial position information (X0, Y0, Z0) according to the acquisition command. When the processor 120 receives the first event generated by the NFC module 130, it can send a displacement acquisition command to the coprocessor 160, and the coprocessor 160 can obtain the real-time position information (X1, Y1, Z1) of the electronic device from the acceleration sensor 150 according to the displacement acquisition command, and calculate the displacement data of the real-time position information (X1, Y1, Z1) relative to the initial position information (X0, Y0, Z0). The coprocessor 160 can send the calculated displacement data to the processor 120, and the processor 120 can then determine whether the electronic device is far away from the second device based on the displacement data. By adding the coprocessor 160 to the processor 120 and the acceleration sensor 150 to process the data of the acceleration sensor 150, the data processing pressure of the processor 120 can be reduced and the processing efficiency can be improved.
[0059] It should be noted that the above-mentioned processor and coprocessor can also directly obtain the raw data (movement direction, offset, etc.) collected by the acceleration sensor, and process the raw data to obtain the position information of the first device. In addition to the acceleration sensor, the position information of the first device can also be obtained through other sensors, such as an inertial measurement unit (IMU), etc., but not limited to this.
[0060] In some embodiments, the location information of the first device when the card emulation function of the NFC module is turned off can also be used as the initial location information. The method for obtaining displacement data can be the same as the method described in the above embodiment, which will not be repeated here.
[0061] Step 330: When the displacement data meets the displacement condition, the card emulation function of the NFC module is enabled.
[0062] As another implementation, the displacement data may include a displacement distance and a displacement direction, wherein the displacement distance may be the difference between the real-time location information of the first device and the initial location information, and the displacement direction refers to the direction from the initial location information to the real-time location information. In some embodiments, the displacement condition may include that the displacement distance is greater than a distance threshold, and the displacement direction is a direction away from the second device, that is, the real-time location information of the first device moves in a direction away from the second device relative to the initial location information. When the displacement distance is greater than the distance threshold, and the displacement direction is a direction away from the second device, it means that the first device has moved significantly in a direction away from the second device, which is consistent with the actual action taken by the user after completing the transfer of the numerical resources of the card, and the card simulation function of the NFC module can be reopened.
[0063] Optionally, during the movement of the first device, its displacement direction may be a direction that approaches the second device first and then moves away from the second device relative to the second device. If the displacement direction obtained is a direction that approaches the second device first and then moves away from the second device, when the displacement distance is greater than the distance threshold, it can be determined whether the distance difference between the displacement distance and the distance threshold exceeds the set range. If it exceeds the set range, it means that the first device has moved a large amount, then it can be determined that the displacement data meets the displacement condition, and the card simulation function of the NFC module is re-enabled. If the distance difference between the displacement distance and the distance threshold is within the set range, it means that the first device is closer to the second device after receiving the second device. In order to prevent misjudgment and repeated numerical resource transfer operations, it can be determined that the displacement data does not meet the displacement condition, and the card simulation function of the NFC module is temporarily not enabled.
[0064] Optionally, the above-mentioned distance threshold may be a preset fixed value, such as 10 cm, 15 cm, 18 cm, 20 cm, etc., which is not limited here. In some embodiments, the distance threshold may also be determined according to the distance between the first device and the second device when the numerical resource transfer operation is performed. If the distance between the first device and the second device is small when the numerical resource transfer operation is performed, the first device needs to move a large distance to move away from the second device, and the corresponding distance threshold may be large. If the distance between the first device and the second device is large when the numerical resource transfer operation is performed, the first device needs to move a small distance to move away from the second device, and the corresponding distance threshold may be small.
[0065] Furthermore, when the NFC module is activated by the NFC radio frequency field of the second device, the field strength of the NFC radio frequency field detected by the NFC module can be obtained, and the distance threshold can be determined based on the field strength, and the distance threshold can be positively correlated with the field strength. The greater the field strength of the NFC radio frequency field detected by the NFC module, the closer the distance between the first device and the second device is, and the corresponding larger distance threshold can be. The smaller the field strength of the NFC radio frequency field detected by the NFC module, the farther the distance between the first device and the second device is, and the corresponding smaller distance threshold can be. By estimating the distance between the first device and the second device based on the field strength of the NFC radio frequency field detected when the NFC module is activated, thereby determining the distance threshold, it is possible to more accurately detect whether the first device is far away from the second device.
[0066] In one embodiment, after the card simulation function of the NFC module is turned off, if the displacement data of the first device is not obtained within a certain period of time, the card simulation function of the NFC module can be turned on. After the processor of the first device controls the NFC module to turn off the card simulation function, if the real-time location information of the first device is not obtained from the acceleration sensor within a certain period of time, it can be determined that an abnormality has occurred in the acceleration sensor. At this time, in order to avoid the card simulation function of the NFC module being unable to be turned on after being turned off due to failure of the acceleration sensor, the card simulation function of the NFC module can be directly reopened, and the error information of the acceleration sensor can be reported. After receiving the reported error information, the main processor of the first device can reset the acceleration sensor and perform other operations to resolve the abnormal situation of the acceleration sensor. By delaying the opening of the card simulation function of the NFC module, it is possible to avoid the situation where the card simulation function of the NFC module cannot be turned on after being turned off due to an error in the acceleration sensor.
[0067] In an embodiment of the present application, the card simulation function of the NFC module is directly turned off when the NFC module disconnects the radio frequency connection with the second device, so that the NFC module can be prevented from performing multiple numerical resource transfer operations under abnormal circumstances, and the displacement data of the first device can be obtained to accurately detect whether the first device is far away from the second device, so that after the first device is far away from the second device, the card simulation function of the NFC module can be restarted without affecting the next normal numerical resource transfer operation, and the NFC module can be accurately used to transfer numerical resources, which meets the actual needs of users.
[0068] like Figure 6 As shown, in one embodiment, another near field communication control method is provided, which can be applied to the first device mentioned above, and the method may include the following steps:
[0069] Step 602: If a first event generated by a near field communication NFC module is received, the card emulation function of the NFC module is turned off, and the first event is used to indicate that the NFC module is disconnected from the second device through radio frequency connection.
[0070] The description of step 602 may refer to the relevant description of step 310 in the above embodiment, which will not be repeated here.
[0071] In some embodiments, before step 602, the method further includes: obtaining the card type selected by the application, and if the card type is a resource transfer type, executing step 602.
[0072] The user can select a card that needs to perform a corresponding function in the application running on the first device, and the processor of the first device can obtain the card type to which the selected card in the application belongs. Optionally, the card type may include a resource transfer type and an authority verification type, wherein the resource transfer type refers to a card that can transfer numerical resources, such as a bank card, a wallet card, a payment card, a discount card, etc., and the authority verification type refers to a card that can confirm authority, such as an access card, a digital car key, an ID card, etc. Since there is no scenario in which the numerical resource transfer operation is repeated for the authority verification type card, therefore, if the card type to which the selected card belongs is the authority verification type, when the first event is received, the card simulation function of the NFC module may not be turned off. Unnecessary data processing processes (such as obtaining displacement data, etc.) can be avoided, the data processing pressure of the processor can be reduced, and the power consumption of the first device can be reduced.
[0073] If the card type of the selected card is a resource transfer type, in order to avoid repeated value resource transfer operations, the card simulation function of the NFC module may be turned off when the first event is received.
[0074] In some embodiments, when the NFC module of the first device is in the card emulation mode, the first device can perform a numerical resource transfer operation through the second device. If the processor of the first device receives the first event, it can determine whether the numerical resource transfer operation is completed. If the numerical resource transfer operation is not completed, for example, the NFC module has not successfully sent the numerical resource transfer information to the second device, that is, the communication connection with the second device is disconnected, the card emulation function of the NFC module may not be turned off, and the numerical resource transfer operation may be performed again after the NFC module re-establishes the NFC communication connection with the second device. This can ensure the normal operation of the numerical resource transfer operation.
[0075] Step 604: when it is detected that the first device leaves the NFC radio frequency field range of the second device, the card emulation function of the NFC module is enabled.
[0076] As an implementation method, when the NFC module turns off the card simulation function, it can only turn off the function of the NFC module to send data to other NFC readers, while other NFC readers can still discover the first device. At this time, the NFC module is equivalent to returning to the initialization state and is in the Listen listening mode. If the NFC module receives the Poll discovery instruction sent by the second device, it can be determined that the first device is still within the NFC radio frequency field range of the second device. If the NFC module does not receive the Poll discovery instruction sent by the second device for a period of time, it can be determined that the first device has left the NFC radio frequency field range of the second device. The period of time can be set according to actual needs, such as 3 seconds, 10 seconds, etc.
[0077] In some embodiments, when the card simulation function of the NFC module is turned off, the first device can detect whether the first device moves through the acceleration sensor. If the first device moves, it can further determine whether it leaves the NFC radio frequency field range of the second device. Optionally, the first device can turn on the camera and capture the surrounding environment image through the camera. The surrounding environment image can be used for object recognition. The image position of the second device in the surrounding environment image is determined according to the characteristics of the second device (such as NFC logo, card swiping image and other features), and the distance between the first device and the second device is determined according to the image position. If it is detected that the distance between the first device and the second device is greater than a certain threshold value according to the surrounding environment image captured by the camera, it can be determined that the first device leaves the NFC radio frequency field range of the second device. The threshold value can be set according to the NFC radio frequency field range of the second device, such as 15 cm, or it can be adjusted when the radiation energy of the NFC coil of the second device is strong, such as 20 cm, etc., which is not limited here.
[0078] As a specific implementation, when the first device detects that it has left the NFC radio frequency field range of the second device, the processor may re-send an enable command (such as an RF_DISCOVER_CMD command) to the NFC module. The enable command may carry the second functional parameter of the card emulation function of the NFC module, and the second functional parameter may at least include the enable parameter. After receiving the enable command, the NFC module may enable the card emulation function according to the second functional parameter carried by the command, and after establishing an NFC communication connection with the NFC card reader, may re-perform the numerical resource transfer operation.
[0079] In an embodiment of the present application, when the near field communication NFC module of the first device is in the card emulation mode, if a first event characterizing the disconnection of the radio frequency connection between the NFC module and the second device is received, the card emulation function of the NFC module is turned off, and when it is detected that the first device leaves the NFC radio frequency field range of the second device, the card emulation function of the NFC module is turned on. When the radio frequency connection between the NFC module and the second device is disconnected, the card emulation function of the NFC module is directly turned off, which can avoid the NFC module from performing multiple numerical resource transfer operations under abnormal circumstances, and after detecting that the first device is away from the second device, restarting the card emulation function of the NFC module will not affect the next normal numerical resource transfer operation, and can accurately use the NFC module to transfer numerical resources, which meets the actual needs of users.
[0080] like Figure 7 As shown, in one embodiment, another near field communication control method is provided, which can be applicable to the above electronic device, and the method may include the following steps:
[0081] Step 702, classify the cards in the application.
[0082] Step 704, determine whether the resource transfer type is selected, if so, execute step 708, if not, execute step 706.
[0083] Step 706, perform permission confirmation normally.
[0084] Step 708, receiving a Field on event, and transmitting signals to the target device until an activation command is received.
[0085] Step 710: query the acceleration sensor for the current position coordinates of the electronic device and mark them as the initial position point.
[0086] Step 712, complete the numerical resource transfer operation and maintain the NFC communication connection.
[0087] Step 714, determine whether a Field off event is received, if so, execute step 716, if not, execute step 712.
[0088] Step 716: Send a close command to the NFC chip to close the card emulation function.
[0089] Step 718: query the acceleration sensor for the real-time position coordinates of the electronic device and calculate the displacement relative to the initial position point.
[0090] Step 720 , determine whether the displacement is greater than the distance threshold, if so, execute step 722 , if not, execute step 718 .
[0091] Step 722: Send an enable command to the NFC chip to enable the card emulation function.
[0092] The description of steps 702 to 722 may refer to the relevant description in the above embodiments, which will not be repeated here.
[0093] In an embodiment of the present application, the card simulation function of the NFC module is directly turned off when the NFC module disconnects the radio frequency connection with the second device, so that the NFC module can be prevented from performing multiple numerical resource transfer operations under abnormal circumstances, and the displacement data of the first device can be obtained to accurately detect whether the first device is far away from the second device, so that after the first device is far away from the second device, the card simulation function of the NFC module can be restarted without affecting the next normal numerical resource transfer operation, and the NFC module can be accurately used to transfer numerical resources, which meets the actual needs of users.
[0094] like Figure 8 As shown, in one embodiment, a near field communication control device 800 is provided, which can be applied to the above-mentioned first device. The near field communication control device 800 may include a closing module 810, a displacement acquisition module 820 and an opening module 830.
[0095] The closing module 810 is used to close the card simulation function of the NFC module if a first event generated by the NFC module is received, and the first event is used to indicate that the NFC module is disconnected from the second device through radio frequency connection.
[0096] In one embodiment, the closing module 810 is further used to obtain the card type selected by the application, and if the card type is a resource transfer type, the card simulation function of the NFC module is closed when the first event generated by the NFC module is received.
[0097] The displacement acquisition module 820 is used to acquire displacement data of the first device.
[0098] In one embodiment, the displacement acquisition module 820 is also used to obtain the current location information of the first device as the initial location information when the NFC module is activated by the NFC radio frequency field of the second device, and to obtain the real-time location information of the first device after turning off the card simulation function of the NFC module by the closing module 810, and to calculate the displacement data of the real-time location information relative to the initial location information.
[0099] The enabling module 830 is used to enable the card emulation function of the NFC module when the displacement data meets the displacement condition.
[0100] In one embodiment, the displacement data includes a displacement distance and a displacement direction. The activation module 830 is further configured to activate the card emulation function of the NFC module when the displacement distance is greater than a distance threshold and the displacement direction is a direction away from the second device.
[0101] In one embodiment, the near field communication control device 800 further includes a field strength detection module and a threshold determination module.
[0102] The field strength detection module is used to obtain the field strength of the NFC radio frequency field detected by the NFC module when the NFC module is activated by the NFC radio frequency field of the second device.
[0103] The threshold determination module is used to determine the distance threshold according to the field strength, and the distance threshold is positively correlated with the field strength.
[0104] In one embodiment, the activation module 830 is further configured to activate the card emulation function of the NFC module if the displacement acquisition module fails to acquire the displacement data of the first device within a certain period of time.
[0105] In an embodiment of the present application, the card simulation function of the NFC module is directly turned off when the NFC module disconnects the radio frequency connection with the second device, so that the NFC module can be prevented from performing multiple numerical resource transfer operations under abnormal circumstances, and the displacement data of the first device can be obtained to accurately detect whether the first device is far away from the second device, so that after the first device is far away from the second device, the card simulation function of the NFC module can be restarted without affecting the next normal numerical resource transfer operation, and the NFC module can be accurately used to transfer numerical resources, which meets the actual needs of users.
[0106] In one embodiment, the near field communication control device 800 includes, in addition to the closing module 810, the displacement acquisition module 820, the opening module 830, the field strength detection module and the threshold determination module, a type acquisition module.
[0107] The type acquisition module is used to obtain the card type selected by the application.
[0108] The closing module 810 is further configured to close the card emulation function of the NFC module if a first event generated by the near field communication NFC module is received when the card type is a resource transfer type.
[0109] The enabling module 830 is further configured to enable the card emulation function of the NFC module when it is detected that the first device leaves the NFC radio frequency field range of the second device.
[0110] In an embodiment of the present application, when the near field communication NFC module of the first device is in the card emulation mode, if a first event characterizing the disconnection of the radio frequency connection between the NFC module and the second device is received, the card emulation function of the NFC module is turned off, and when it is detected that the first device leaves the NFC radio frequency field range of the second device, the card emulation function of the NFC module is turned on. When the radio frequency connection between the NFC module and the second device is disconnected, the card emulation function of the NFC module is directly turned off, which can avoid the NFC module from performing multiple numerical resource transfer operations under abnormal circumstances, and after detecting that the first device is away from the second device, restarting the card emulation function of the NFC module will not affect the next normal numerical resource transfer operation, and can accurately use the NFC module to transfer numerical resources, which meets the actual needs of users.
[0111] Fig. 9 FIG. 1 is a structural block diagram of an electronic device in another embodiment. Fig. 9 As shown, the electronic device may include: a radio frequency module 910, a memory 920, an input unit 930, a display unit 940, a sensor 950, an audio circuit 960, a WiFi (Wireless Fidelity) module 970, a processor 980, and a power supply 990. Those skilled in the art will understand that Fig. 9 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0112] The RF module 910 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 980 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF module 910 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF module 910 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communication can use any communication standard or protocol, including but not limited to the global system of mobile communication (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), long-term evolution, email, short messaging service (SMS), etc.
[0113] The memory 920 can be used to store software programs and modules. The processor 980 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 920. The memory 920 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device (such as audio data, a phone book, etc.), etc. In addition, the memory 920 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0114] The input unit 930 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the input unit 930 may include a touch panel 932 and other input devices 934. The touch panel 932, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 932 or near the touch panel 932 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 932 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 980, and can receive and execute commands sent by the processor 980. In addition, the touch panel 932 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 932, the input unit 930 may further include other input devices 934. Specifically, other input devices 934 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0115] The display unit 940 can be used to display information input by the user or information provided to the user and various menus of the electronic device. The display unit 940 may include a display panel 942. Optionally, the display panel 942 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. Further, the touch panel 932 may cover the display panel 942. When the touch panel 932 detects a touch operation on or near it, it is transmitted to the processor 980 to determine the type of touch event. Subsequently, the processor 980 provides a corresponding visual output on the display panel 942 according to the type of touch event. Although in Fig. 9 In the embodiment, the touch panel 932 and the display panel 942 are used as two independent components to implement the input and output functions of the electronic device, but in some embodiments, the touch panel 932 and the display panel 942 can be integrated to implement the input and output functions of the electronic device.
[0116] The electronic device may also include at least one sensor 950, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 942 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 942 and / or the backlight when the electronic device is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of electronic devices (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometers, tapping), etc.; as for other sensors that can be configured in electronic devices, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.
[0117] The audio circuit 960, the speaker 962, and the microphone 964 can provide an audio interface between the user and the electronic device. The audio circuit 960 can transmit the received audio data to the speaker 962 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 964 converts the collected sound signal into an electrical signal, which is received by the audio circuit 960 and converted into audio data, and then the audio data is output to the processor 980 for processing, and then sent to another electronic device through the radio frequency module 910, or the audio data is output to the memory 920 for further processing.
[0118] WiFi is a short-range wireless transmission technology. Electronic devices can help users send and receive emails, browse web pages, and access streaming media through the WiFi module 970. It provides users with wireless broadband Internet access.
[0119] The processor 980 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 920, and calling data stored in the memory 920, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 980 may include one or more processing units; preferably, the processor 980 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 980. In one embodiment, when the computer program stored in the memory 920 is executed by the processor 980, the processor 980 implements the method described in the above embodiments.
[0120] The electronic device also includes a power supply 990 (such as a battery) for supplying power to each component. Preferably, the power supply can be logically connected to the processor 980 through a power management system, so that the power management system can manage charging, discharging, and power consumption management. Although not shown, the electronic device can also include a camera, a Bluetooth module, etc., which will not be repeated here.
[0121] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program implements the methods described in the above embodiments when executed by a processor.
[0122] An embodiment of the present application discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program can be executed by a processor to implement the methods described in the above embodiments.
[0123] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM), etc.
[0124] As used herein, any reference to memory, storage, database, or other medium may include nonvolatile and / or volatile memory. Suitable nonvolatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which is used as an external cache memory. As an illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0125] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required for the present application.
[0126] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0127] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0128] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0129] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several requests for a computer device (which can be a personal computer, a server or a network device, etc., specifically a processor in a computer device) to perform some or all of the steps of the above-mentioned methods of various embodiments of the present application.
[0130] The above is a detailed introduction to a near field communication control method, device, electronic device and storage medium disclosed in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for controlling near field communication, characterized in that: Applied to a first device, the method includes: If a first event generated by a near field communication NFC module is received, turning off the card emulation function of the NFC module, wherein the first event is used to indicate that the NFC module is disconnected from the second device through a radio frequency connection; Acquire displacement data of the first device; the displacement data includes a displacement distance and a displacement direction; When the displacement distance is greater than a distance threshold, and the displacement direction is a direction away from the second device, a card emulation function of the NFC module is enabled.
2. The method according to claim 1, characterized in that Before the step of turning off the card emulation function of the NFC module if the first event generated by the NFC module is received, the method further includes: When the NFC module is activated by the NFC radio frequency field of the second device, obtaining the current location information of the first device as the initial location information; The acquiring the displacement data of the first device includes: Acquire the real-time position information of the first device, and calculate the displacement data of the real-time position information relative to the initial position information.
3. The method according to claim 1, characterized in that Before the step of turning off the card emulation function of the NFC module if the first event generated by the NFC module is received, the method further includes: When the NFC module is activated by the NFC radio frequency field of the second device, obtaining the field strength of the NFC radio frequency field detected by the NFC module; A distance threshold is determined according to the field strength, and the distance threshold is positively correlated with the field strength.
4. The method according to claim 1, characterized in that: After turning off the card emulation function of the NFC module, the method further includes: If the displacement data of the first device is not obtained within a certain period of time, the card simulation function of the NFC module is enabled.
5. The method according to any one of claims 1 to 4, characterized in that: Before the step of turning off the card emulation function of the NFC module if the first event generated by the NFC module is received, the method further includes: Get the card type selected by the application; If the card type is a resource transfer type, the step of: if a first event generated by a near field communication NFC module is received, then turning off the card emulation function of the NFC module.
6. The method according to claim 1, characterized in that After turning off the card emulation function of the NFC module, the method further includes: When it is detected that the first device leaves the NFC radio frequency field range of the second device, a card emulation function of the NFC module is enabled.
7. A near field communication control device, characterized in that: Applied to a first device, the apparatus comprises: A closing module, configured to close the card emulation function of the near field communication NFC module upon receiving a first event generated by the NFC module, wherein the first event is used to indicate that the NFC module is disconnected from the second device through a radio frequency connection; A displacement acquisition module, used to acquire displacement data of the first device; the displacement data includes a displacement distance and a displacement direction; The activation module is used to activate the card simulation function of the NFC module when the displacement distance is greater than a distance threshold and the displacement direction is a direction away from the second device.
8. An electronic device, characterized in that: It includes a processor and an NFC module, wherein the processor is electrically connected to the NFC module; The processor is configured to control the NFC module to disable a card simulation function if a first event generated by the NFC module is received, wherein the first event is used to indicate that the NFC module is disconnected from a radio frequency connection with a second device; The processor is further used to obtain displacement data of the electronic device, wherein the displacement data includes a displacement distance and a displacement direction; and when the displacement distance is greater than a distance threshold and the displacement direction is a direction away from the second device, the card simulation function of the NFC module is enabled.
9. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor implements the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
