Near-field communication method and related apparatus

By receiving and analyzing the probe frames from NFC card readers, the system automatically selects the appropriate NFC emulator card and displays the card swiping interface, solving the problem of difficulty in selecting multiple NFC emulator cards in electronic devices and improving the speed and efficiency of NFC card swiping.

WO2025261063A1PCT designated stage Publication Date: 2025-12-26HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/096294
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-12-05
Filing Date
2025-05-21
Publication Date
2025-12-26

AI Technical Summary

Technical Problem

When multiple NFC emulator cards are activated in an electronic device, the appropriate NFC emulator card cannot be automatically selected to interact with the NFC card reader, resulting in complex and inefficient card swiping operations.

Method used

By receiving the probe frame sent by the NFC card reader, sending the probe confirmation frame, and determining the appropriate target NFC card from multiple NFC simulated cards based on the device feature information of the card reader, and displaying the card swiping interface, the system achieves automatic and accurate selection and quick pop-up of the card swiping interface.

Benefits of technology

It improves the speed and efficiency of NFC card swiping, enables automatic selection and instant prompting of NFC analog cards, and simplifies the user operation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025096294_26122025_PF_FP_ABST
    Figure CN2025096294_26122025_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are a near-field communication (NFC) method and a related apparatus. When entering a radio-frequency field emitted by an NFC card reading device, an electronic device can receive a probe frame transmitted by the NFC card reading device. After the probe frame is received, the electronic device can send a probe acknowledge frame to the NFC card reading device, wherein the probe acknowledge frame can be used for indicating that the electronic device has received the probe frame. After the probe frame is received, the NFC card reading device can send a notify frame to the electronic device, wherein the notify frame carries device feature information of the NFC card reading device. After the notify frame is received, the electronic device can determine a first NFC emulated card from among one or more NFC emulated cards by means of the device feature information of the NFC card reading device. In this way, the electronic device can automatically and accurately select an appropriate NFC emulated card and quickly pop up a card-tapping interface for a first NFC emulated card, thereby improving the speed and efficiency of NFC card tapping.
Need to check novelty before this filing date? Find Prior Art

Description

A near-field communication method and related device

[0001] This application claims priority to the following Chinese patent applications filed on June 19, 2024, with application number 202410802516.1 and entitled "An NFC Analog Card Selection Method and Related Apparatus"; filed on August 14, 2024, with application number 202411118185.6 and entitled "An NFC Analog Card Selection Method and Related Apparatus"; and filed on December 5, 2024, with application number 202411785060.9 and entitled "A Near Field Communication Method and Related Apparatus", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of wireless communication technology, and in particular to a near-field communication method and related apparatus. Background Technology

[0003] With the development of wireless communication technology, near field communication (NFC) technology has been widely used. NFC technology evolved from contactless radio frequency identification (RFID) and interconnection technology. In NFC technology, NFC-enabled devices can operate in three modes when communicating via NFC: proximity coupling device (PCD) mode (also known as reader mode), proximity integrated circuit card (PICC) mode (also known as card emulation mode), and point-to-point (P2P) mode.

[0004] Currently, some NFC-enabled electronic devices (such as mobile phones, tablets, and wearable devices) support both PICC and PCD modes. Users can activate one or more NFC emulators on their electronic devices. When the electronic device is in PICC mode, it can simulate itself as a PICC device compliant with NFC standards based on the data from the NFC emulator, and interact with NFC devices in PCD mode. However, when multiple NFC emulators are activated on an electronic device, if the device is near an NFC reader, it can only use the default NFC emulator to interact with the reader in an attempt to perform NFC services. If the default NFC emulator cannot perform NFC services with the reader, the NFC service will fail. For example, an electronic device may have access control cards and bank cards activated, but the default NFC emulator is a bank card. When the user brings the electronic device close to the NFC reader at a gate, the device cannot open the door. The user needs to change the default NFC emulator to the access control card before bringing the device close to the NFC reader again to open the gate. This demonstrates that the process of swiping cards on electronic devices is complex, and the efficiency of electronic devices performing NFC services is low. Summary of the Invention

[0005] This application provides a near-field communication method and related apparatus, which can improve the speed and efficiency of NFC card swiping.

[0006] In a first aspect, this application provides a near-field communication method, comprising: upon entering the radio frequency field of an NFC card reader, receiving a probe frame sent by the NFC card reader, the probe frame indicating that the NFC card reader supports a specified NFC protocol; sending a probe ACK frame to the NFC card reader, the probe ACK frame indicating that the electronic device supports the specified NFC protocol; receiving a notification frame sent by the NFC card reader, the notification frame carrying device feature information of the NFC card reader; and, based on the device feature information of the NFC card reader, determining a first NFC emulator from one or more NFC emulators on the electronic device, wherein different device feature information corresponds to different NFC emulators, and the device feature information of the NFC card reader includes a service identifier and a device organization identifier, wherein the service identifier indicates the type of NFC service supported by the NFC card reader, and the device organization identifier indicates the manufacturer using the NFC card reader to provide NFC services.

[0007] According to the near-field communication method provided in this application, when an electronic device enters the radio frequency field emitted by an NFC reader, it can receive a probe frame emitted by the NFC reader. After receiving the probe frame, the electronic device can send a probe acknowledgement (Probe ACK) frame to the NFC reader, indicating that the electronic device has received the probe frame. After receiving the probe frame, the NFC reader can send a notification frame to the electronic device, which carries device characteristic information of the NFC reader. Upon receiving the notification frame, the electronic device can use the device characteristic information of the NFC reader to identify a first NFC emulator from one or more NFC emulators and display the swiping interface of the first NFC emulator. The electronic device can then interact with the NFC reader via NFC to complete the swiping transaction of the first NFC emulator. This allows the electronic device to automatically and accurately select the appropriate NFC emulator and quickly display the swiping interface of the first NFC emulator, improving the speed and efficiency of NFC swiping.

[0008] In one possible implementation, the device feature information of the NFC card reader also includes a device group identifier, which indicates the group to which the NFC service provided by the NFC card reader belongs. Thus, by including the service identifier, device organization identifier, and device group identifier in the device feature information, the target NFC emulated card can be accurately selected.

[0009] In one possible implementation, after identifying a first NFC emulator from one or more NFC emulators on the electronic device using the device feature information of the NFC card reader, the method further includes: outputting a swipe notification for the first NFC emulator, which indicates that the electronic device is using the first NFC emulator for swiping. This allows the swipe notification of the target NFC emulator to pop up instantly, enabling the user to immediately perceive the NFC swipe process.

[0010] In one possible implementation, after determining the first NFC emulator from one or more NFC emulators on the electronic device using the device feature information of the NFC reader, the method further includes: sending a Notify ACK frame to the NFC reader, the Notify ACK frame carrying a first notification result indicating that the electronic device has successfully selected the first NFC emulator. In this way, the electronic device can notify the NFC reader that the target NFC emulator has been successfully selected, allowing the NFC reader to promptly execute subsequent NFC command interaction procedures.

[0011] In one possible implementation, after sending a Notify ACK frame to the NFC card reader, the method further includes: interacting with the NFC card reader via NFC to complete the card swiping transaction of the first NFC analog card.

[0012] The card-swiping service can include any one of the following: opening access control, unlocking doors, unlocking vehicles, making transactions, verifying electronic tickets, verifying digital documents, and swiping transportation cards to get on and off vehicles.

[0013] In one possible implementation, the NFC card reader interacts with the NFC card reader via NFC to complete the card swiping service of the first NFC simulated card. Specifically, this includes: sending the card information of the first NFC simulated card to the NFC card reader, wherein the card information of the first NFC simulated card is used by the NFC card reader to perform the card swiping service of the first NFC simulated card; and receiving the card swiping result of the first NFC simulated card sent by the NFC card reader.

[0014] The card information of the first NFC simulated card may include one or more of the following: access control information, key information, transaction account information, and electronic ticket information. Access control information may include one or more of the following: card number, card validity period, etc. Key information may include one or more of the following: key code, key code validity period, etc. Transaction account information may include one or more of the following: transaction account identifier, remaining balance in the transaction account, etc. Electronic ticket information may include one or more of the following: electronic ticket code, electronic ticket verification time, electronic ticket validity period, etc.

[0015] In one possible implementation, before sending the card information of the first NFC emulated card to the NFC reader, the method further includes: receiving a mapping list query command sent by the NFC reader, the mapping list query command being used to request the electronic device to return a first mapping list to the NFC reader, the first mapping list being used to indicate the mapping relationship between device feature information and the identifier of a dedicated file (DF); sending a mapping list query response to the NFC reader, the mapping list query response carrying the first mapping list; receiving a Select DF command sent by the NFC reader, the Select DF command carrying the identifier of the first DF; obtaining the first DF based on the identifier of the first DF through a first applet, the first DF including the card information of the first NFC emulated card; sending a second response to the NFC reader, the second response being used to indicate that the electronic device has successfully obtained the first DF; and obtaining the card information of the first NFC emulated card from the first DF.

[0016] In this way, by using the NFC reader to determine the identifier of the first DF from the first mapping list based on the device feature information of the NFC reader, the processing and computational load of the NFC card device (e.g., electronic device, NFC tag card) can be reduced. For example, when an NFC tag card is brought close to the NFC reader, since the NFC tag card's computing power is insufficient, the NFC reader can read the first mapping list in the NFC tag card to select the first DF, thereby reducing the processing and computational load of the NFC tag card.

[0017] In one possible implementation, before receiving the mapping list query command sent by the NFC card reader, the method further includes: receiving a Select AID command sent by the NFC card reader, wherein the Select AID command carries the identifier of the first Applet; in response to the Select AID command, determining the first Applet from one or more Applets based on the identifier of the first Applet; and sending a first response to the NFC card reader, the first response indicating that the electronic device has successfully selected the first Applet. This allows the first Applet on the electronic device to be selected, enabling the first Applet to perform subsequent encryption and decryption processes related to card information of the first NFC analog card.

[0018] In one possible implementation, the Notify frame also carries an identifier of a first Applet. Before sending the card information of the first NFC emulated card to the NFC reader, the method further includes: determining the identifier of a first DF corresponding to the device feature information of the NFC reader based on the device feature information of the NFC reader and a first mapping list, wherein the first mapping list indicates the mapping relationship between the device feature information and the identifier of the dedicated file DF; obtaining the first DF based on the identifier of the first DF through a first applet; and obtaining the card information of the first NFC emulated card from the first DF. In this way, after receiving the Notify frame, the electronic device can identify the first Applet and obtain the first DF through the first Applet, improving the NFC card swiping speed.

[0019] In one possible implementation, the first DF further includes a first external authentication key; sending the card information of the first NFC simulated card to the NFC card reader specifically includes: encrypting the card information of the first NFC simulated card using the first Applet with the first external authentication key and a first random number to obtain encrypted data; sending the encrypted data to the NFC card reader, whereby the encrypted data is used by the NFC card reader to decrypt the card information of the first NFC simulated card, and the card information of the first NFC simulated card is used by the NFC card reader to perform a card swiping transaction with the first NFC simulated card. This improves the security of the card information of the first NFC simulated card during transmission.

[0020] In one possible implementation, before encrypting the card information of the first NFC analog card using the first external authentication key and the first random number to obtain encrypted data, the method further includes: receiving a card information acquisition command sent by the NFC card reader, the card information acquisition command being used to request the acquisition of the card information of the first NFC analog card; the encryption of the card information of the first NFC analog card using the first external authentication key and the first random number through the first Applet to obtain encrypted data specifically includes: in response to the card information acquisition command, encrypting the card information of the first NFC analog card stored in the first DF using the first external authentication key and the first random number to obtain encrypted data.

[0021] In one possible implementation, before receiving the card information retrieval command sent by the NFC card reader, the method further includes: receiving a random number retrieval Get Challenge command sent by the NFC card reader; generating the first random number via the first Applet in response to the Get Challenge command; sending a third response to the NFC card reader, the third response carrying the first random number; receiving an external authentication command sent by the NFC card reader, the external authentication command carrying authentication ciphertext; decrypting the first random number from the authentication ciphertext using the first external authentication key in the first DF via the first Applet; and sending a fourth response to the NFC card reader, the fourth response carrying a first authentication result, the first authentication result indicating that the electronic device has successfully decrypted the first random number from the authentication ciphertext.

[0022] In one possible implementation, after receiving the swipe result of the first NFC simulated card from the NFC card reader, the method further includes: outputting a prompt corresponding to the swipe result of the first NFC simulated card. This allows the user to know the swipe result immediately.

[0023] In one possible implementation, after receiving the swipe result of the first NFC simulated card from the NFC card reader, the method further includes: sending a fifth response to the NFC card reader, the fifth response indicating that the electronic device has successfully received the swipe result of the first NFC simulated card. This allows the NFC card reader to immediately know that the electronic device has successfully received the swipe result.

[0024] Secondly, this application provides another near-field communication method applied to an NFC card reader, comprising: sending a Probe frame, the Probe frame indicating that the NFC card reader supports a specified NFC protocol; receiving a Probe ACK frame sent by an electronic device, the Probe ACK frame indicating that the electronic device supports the specified NFC protocol; and sending a Notify frame to the electronic device, the Notify frame carrying device feature information of the NFC card reader, the Notify frame being used by the electronic device to determine a first NFC emulator card from one or more NFC emulator cards on the electronic device based on the device feature information of the NFC card reader, wherein different device feature information corresponds to different NFC emulator cards, the device feature information of the NFC card reader including a service identifier and a device organization identifier, wherein the service identifier indicates the type of NFC service supported by the NFC card reader, and the device organization identifier indicates the manufacturer using the NFC card reader to provide NFC services.

[0025] In one possible implementation, the device feature information of the NFC card reader also includes a device group identifier, which is used to indicate the group to which the NFC service provided by the NFC card reader belongs.

[0026] In one possible implementation, after sending the Notify frame to the electronic device, the method further includes: receiving a Notify ACK frame sent by the electronic device, the Notify ACK frame carrying a first notification result indicating that the electronic device has successfully selected the first NFC emulator card.

[0027] In one possible implementation, after receiving the Notify ACK frame sent by the electronic device, the method further includes: interacting with the electronic device via NFC to complete the card swiping transaction of the first NFC analog card.

[0028] In one possible implementation, the device interacts with the electronic device via NFC to complete the card swiping service of the first NFC simulated card, specifically including: receiving the card information of the first NFC simulated card sent by the electronic device; performing the card swiping service of the first NFC simulated card based on the card information of the first NFC simulated card; and sending the card swiping result of the first NFC simulated card to the electronic device.

[0029] In one possible implementation, before receiving the card information of the first NFC simulated card sent by the electronic device, the method further includes: sending a mapping list query command to the electronic device, the mapping list query command being used to request the electronic device to return a first mapping list to the NFC card reader, the first mapping list being used to indicate the mapping relationship between device feature information and the identifier of a dedicated file (DF); receiving a mapping list query response sent by the electronic device, the mapping list query response carrying the first mapping list; sending a Select DF command to the electronic device, the Select DF command carrying the identifier of the first DF, the Select DF command requesting to obtain the first DF; and receiving a second response sent by the electronic device, the second response being used to indicate that the electronic device has successfully obtained the first DF.

[0030] In one possible implementation, before sending the mapping list query command to the electronic device, the method further includes: sending a Select AID command to the electronic device, wherein the Select AID command carries an identifier of the first Applet and is used to request the electronic device to select the first Applet; and receiving a first response from the electronic device, the first response indicating that the electronic device has successfully selected the first Applet.

[0031] In one possible implementation, the Notify frame also carries an identifier of the first Applet, which is used by the electronic device to select the first Applet.

[0032] In one possible implementation, the first DF further includes a first external authentication key; the card information of the first NFC analog card received from the electronic device specifically includes: receiving encrypted data sent by the electronic device; and decrypting the card information of the first NFC analog card from the encrypted data using the first external authentication key and a first random number.

[0033] In one possible implementation, before receiving encrypted data sent by the electronic device, the method further includes sending a card information acquisition command to the electronic device, the card information acquisition command being used to request the acquisition of card information of the first NFC emulated card.

[0034] In one possible implementation, before sending the card information retrieval command to the electronic device, the method further includes: sending a Get Challenge command to the electronic device, the Get Challenge command being used to request a first Applet of the electronic device to generate the first random number; sending a third response to the NFC card reader, the third response carrying the first random number; encrypting the first random number using the first external authentication key to obtain authentication ciphertext; sending an external authentication command to the electronic device, the external authentication command carrying the authentication ciphertext; and receiving a fourth response sent by the electronic device, the fourth response carrying a first authentication result, the first authentication result being used to indicate that the electronic device has successfully decrypted the first random number from the authentication ciphertext.

[0035] In one possible implementation, after receiving the swipe result of the first NFC simulated card sent by the NFC card reader, the method further includes: receiving a fifth response sent by the electronic device, the fifth response indicating that the electronic device has successfully received the swipe result of the first NFC simulated card.

[0036] Thirdly, this application provides an NFC system, including: an electronic device and an NFC card reader; wherein the NFC card reader is configured to send a Probe frame, the Probe frame indicating that the NFC card reader supports a specified NFC protocol; the electronic device is configured to receive the Probe frame after entering the radio frequency field of the NFC card reader; the electronic device is further configured to send a Probe ACK frame to the NFC card reader after receiving the Probe frame, the Probe ACK frame indicating that the electronic device supports the specified NFC protocol; the NFC card reader is further configured to send a Notify frame to the electronic device after receiving the Probe ACK frame, the Notify frame carrying device feature information of the NFC card reader; the electronic device is further configured to determine a first NFC emulator card from one or more NFC emulator cards on the electronic device based on the device feature information of the NFC card reader, wherein different device feature information corresponds to different NFC emulator cards, and the device feature information of the NFC card reader includes a service identifier and a device organization identifier, wherein the service identifier indicates the type of NFC service supported by the NFC card reader, and the device organization identifier indicates the manufacturer using the NFC card reader to provide NFC services.

[0037] In one possible implementation, the device feature information of the NFC card reader also includes a device group identifier, which is used to indicate the group to which the NFC service provided by the NFC card reader belongs.

[0038] In one possible implementation, the electronic device is further configured to output a swipe notification for the first NFC analog card, which indicates that the electronic device is using the first NFC analog card for swiping.

[0039] In one possible implementation, the electronic device is further configured to send a Notify ACK frame to the NFC card reader after the first NFC emulator card is identified. The Notify ACK frame carries a first notification result, which indicates that the electronic device has successfully selected the first NFC emulator card.

[0040] In one possible implementation, the electronic device is further configured to interact with the NFC card reader via NFC after sending a Notify ACK frame to the NFC card reader, thereby completing the card swiping transaction of the first NFC analog card.

[0041] Fourthly, embodiments of this application provide a near-field communication method applied to an electronic device, characterized in that the method includes: after entering the radio frequency field of an NFC card reader, receiving a Probe frame sent by the NFC card reader, the Probe frame indicating that the NFC card reader supports a first NFC protocol; sending a Probe ACK frame to the NFC card reader, the Probe ACK frame indicating that the electronic device supports the first NFC protocol; receiving a Notify frame sent by the NFC card reader, the Notify frame carrying device feature information of the NFC card reader; and sending a Notify ACK frame to the NFC card reader, wherein the Notify ACK frame indicating that the electronic device has successfully received the Notify frame.

[0042] This application provides an NFC communication method. During the signaling interaction process at the access layer, a Notify frame is used to send the device characteristic information of an NFC reader to an electronic device. This allows the electronic device to determine the target NFC service based on the NFC reader's device characteristic information before data transmission at the application layer. This enables the electronic device to prepare the data required for the target NFC service or output a prompt for the target NFC service before data transmission at the application layer. Thus, the electronic device and the NFC reader can complete different types of NFC services at the application layer after the same signaling interaction process at the access layer, saving resources and costs for the electronic device.

[0043] In one possible implementation, the device characteristic information of the NFC card reader 200 includes a service identifier and a device organization identifier. The service identifier indicates the type of NFC service supported by the NFC card reader, and the device organization identifier indicates the manufacturer providing the NFC service using the NFC card reader. This allows the electronic device 100 to determine the target NFC service based on the device characteristic information of the NFC card reader 200 before data transmission at the application layer.

[0044] In one possible implementation, the device feature information of the NFC card reader also includes a device group identifier, which indicates the group to which the NFC service provided by the NFC card reader belongs. Thus, by including the service identifier, device organization identifier, and device group identifier in the device feature information, the target NFC emulated card can be accurately selected.

[0045] In one possible implementation, after receiving the Notify frame sent by the NFC card reader 200, the method further includes: determining and outputting a swipe prompt for a first NFC simulated card based on the device characteristic information of the NFC card reader 200. This swipe prompt for the first NFC simulated card is used to indicate that the electronic device is using the first NFC simulated card for swiping. In this way, the swipe prompt for the target NFC simulated card can be displayed instantly, allowing the user to immediately perceive the NFC swipe process.

[0046] In one possible implementation, after sending a Notify ACK frame to the NFC reader, the method further includes: receiving a mini-program selection command sent by the NFC reader, the mini-program selection command carrying the identifier of a first Applet; determining the first NFC emulated card corresponding to the first Applet based on the identifier of the first Applet; and sending the card information of the first NFC emulated card to the NFC reader through the first Applet, the card information of the first NFC emulated card being used by the NFC reader to perform a card-swiping transaction for the first NFC emulated card. In this way, the electronic device can determine the first NFC emulated card corresponding to the first Applet through the identifier of the first Applet.

[0047] In one possible implementation, after sending the card information of the first NFC simulated card to the NFC card reader via the first applet, the method further includes: receiving the card swiping result of the first NFC simulated card sent by the NFC card reader.

[0048] The card information of the first NFC simulated card may include one or more of the following: access control information, key information, transaction account information, and electronic ticket information. Access control information may include one or more of the following: card number, card validity period, etc. Key information may include one or more of the following: key code, key code validity period, etc. Transaction account information may include one or more of the following: transaction account identifier, remaining balance in the transaction account, etc. Electronic ticket information may include one or more of the following: electronic ticket code, electronic ticket verification time, electronic ticket validity period, etc.

[0049] In one possible implementation, determining the first NFC emulator card corresponding to the first applet based on its identifier specifically includes: identifying the first applet from one or more applets based on its identifier; and determining the first DF corresponding to the first NFC emulator card from the MF (Mean Function) of the first applet, wherein the MF of the first applet includes one or more DFs, the one or more DFs include the first DF, and the first DF includes the card information of the first NFC emulator card. This allows an electronic device to obtain the card information of the first NFC emulator card from the MF of the first applet.

[0050] In one possible implementation, determining the first DF corresponding to the first NFC emulator card from the MF (Mean Factor Map) of the first Applet specifically includes: obtaining the MF of the first Applet, which includes a first mapping list and one or more DFs; obtaining the first mapping table from the MF of the first Applet, which indicates the mapping relationship between device feature information and the identifier of the DF; determining the identifier of the first DF corresponding to the device feature information of the NFC card reader from the MF of the first Applet based on the device feature information of the NFC card reader and the first mapping list; and determining the first DF from the MF of the first Applet based on the identifier of the first DF. In this way, the first DF of the first NFC emulator card can be determined from the MF of the first Applet by combining the device information of the NFC card reader, thereby obtaining the card information of the first NFC emulator card from the first DF.

[0051] In one possible implementation, the first DF further includes a first external authentication key; sending the card information of the first NFC simulated card to the NFC card reader via the first Applet specifically includes: encrypting the card information of the first NFC simulated card stored in the first DF using the first external authentication key and a first random number via the first Applet to obtain encrypted data; sending the encrypted data to the NFC card reader, wherein the encrypted data is used by the NFC card reader to decrypt the card information of the first NFC simulated card.

[0052] In one possible implementation, before encrypting the card information of the first NFC analog card using the first external authentication key and the first random number to obtain encrypted data, the method further includes: receiving a card information acquisition command sent by the NFC card reader, the card information acquisition command being used to request the acquisition of the card information of the first NFC analog card; the encryption of the card information of the first NFC analog card using the first external authentication key and the first random number through the first Applet to obtain encrypted data specifically includes: in response to the card information acquisition command, encrypting the card information of the first NFC analog card stored in the first DF using the first external authentication key and the first random number to obtain encrypted data.

[0053] In one possible implementation, before receiving the card information retrieval command sent by the NFC card reader, the method further includes: receiving a Get Challenge command sent by the NFC card reader; generating the first random number via the first Applet in response to the Get Challenge command; sending a third response to the NFC card reader, the third response carrying the first random number; receiving an external authentication command sent by the NFC card reader, the external authentication command carrying authentication ciphertext; decrypting the first random number from the authentication ciphertext using the first external authentication key in the first DF via the first Applet; and sending a fourth response to the NFC card reader, the fourth response carrying a first authentication result, the first authentication result indicating that the electronic device has successfully decrypted the first random number from the authentication ciphertext.

[0054] In one possible implementation, after receiving the swipe result of the first NFC simulated card sent by the NFC card reader, the method further includes: outputting a prompt corresponding to the swipe result of the first NFC simulated card.

[0055] In one possible implementation, after receiving the swipe result of the first NFC simulated card from the NFC card reader, the method further includes: sending a fifth response to the NFC card reader, the fifth response indicating that the electronic device has successfully received the swipe result of the first NFC simulated card. This allows the user to be informed of the swipe result immediately.

[0056] In one possible implementation, after sending a Notify ACK frame to the NFC reader, the method further includes: receiving a parameter negotiation command sent by the NFC reader; and sending a parameter negotiation response to the NFC reader, wherein the parameter negotiation command and the parameter negotiation response are used by the NFC reader and the electronic device to negotiate data transmission parameters at the application layer.

[0057] In one possible implementation, the data transmission parameters include one or more of the maximum transmission rate and the maximum data transmission length when performing application layer data transmission.

[0058] Fifthly, embodiments of this application provide an NFC analog card selection method applied to an NFC card reader device. The method includes: sending a Probe frame, the Probe frame indicating that the NFC card reader device supports a first NFC protocol; receiving a Probe ACK frame sent by an electronic device, the Probe ACK frame indicating that the electronic device supports the first NFC protocol; sending a Notify frame to the electronic device, the Notify frame carrying device feature information of the NFC card reader device; and receiving a Notify ACK frame sent by the electronic device, wherein the Notify ACK frame indicates that the electronic device has successfully received the Notify frame.

[0059] In one possible implementation, the device feature information of the NFC card reader includes a service identifier and a device organization identifier, wherein the service identifier is used to indicate the type of NFC service supported by the NFC card reader, and the device organization identifier is used to indicate the manufacturer that provides NFC services using the NFC card reader.

[0060] In one possible implementation, the device feature information of the NFC card reader also includes a device group identifier, which is used to indicate the group to which the NFC service provided by the NFC card reader belongs.

[0061] In one possible implementation, after receiving a Notify ACK frame from the electronic device, the method further includes: sending a mini-program selection command to the electronic device, the mini-program selection command carrying the identifier of a first Applet, the mini-program selection command being used to request the electronic device to select the first Applet; receiving card information of the first NFC simulated card sent by the electronic device through the first Applet; and performing a card swiping operation of the first NFC simulated card based on the card information of the first NFC simulated card.

[0062] In one possible implementation, after receiving the card information of the first NFC simulated card sent by the electronic device through the first Applet, the method further includes: sending the swipe result of the first NFC simulated card to the electronic device.

[0063] In one possible implementation, receiving the card information of the first NFC analog card sent by the electronic device through the first applet specifically includes: receiving encrypted data sent by the electronic device through the first applet; and decrypting the card information of the first NFC analog card from the encrypted data using a first external authentication key and a first random number.

[0064] In one possible implementation, before decrypting the card information of the first NFC emulator from the encrypted data using a first external authentication key and a first random number, the method further includes: sending a card information retrieval command to the electronic device, the card information retrieval command being used to request retrieval of the card information of the first NFC emulator.

[0065] In one possible implementation, before sending the card information retrieval command to the electronic device, the method further includes: sending a Get Challenge command to the electronic device, the Get Challenge command being used to request a first Applet of the electronic device to generate the first random number; sending a third response to the NFC card reader, the third response carrying the first random number; encrypting the first random number using the first external authentication key to obtain authentication ciphertext; sending an external authentication command to the electronic device, the external authentication command carrying the authentication ciphertext; and receiving a fourth response sent by the electronic device, the fourth response carrying a first authentication result, the first authentication result being used to indicate that the electronic device has successfully decrypted the first random number from the authentication ciphertext.

[0066] In one possible implementation, after receiving the swipe result of the first NFC simulated card sent by the NFC card reader, the method further includes: receiving a fifth response sent by the electronic device, the fifth response indicating that the electronic device has successfully received the swipe result of the first NFC simulated card.

[0067] In one possible implementation, after receiving the Notify ACK frame sent by the electronic device, the method further includes: sending a parameter negotiation command to the NFC reader; and receiving a parameter negotiation response sent by the electronic device, wherein the parameter negotiation command and the parameter negotiation response are used by the NFC reader to negotiate data transmission parameters at the application layer with the electronic device.

[0068] In one possible implementation, the data transmission parameters include one or more of the maximum transmission rate and the maximum data transmission length when performing application layer data transmission.

[0069] Sixthly, embodiments of this application provide an NFC system, including an electronic device and an NFC card reader; wherein the electronic device is used to execute the near-field communication method in the fourth aspect and any possible implementation thereof; and the NFC card reader is used to execute the near-field communication method in the fifth aspect and any possible implementation thereof.

[0070] In a seventh aspect, embodiments of this application provide an electronic device including one or more processors, one or more memories, and a transceiver. The transceiver, the one or more memories, and the one or more processors are coupled together. The one or more memories are used to store a computer program. When the one or more processors execute the computer program, they perform the near-field communication method described in the first aspect and any possible implementation thereof.

[0071] Eighthly, embodiments of this application provide an NFC card reader device, including one or more processors, one or more memories, and a transceiver. The transceiver, the one or more memories, and the one or more memories are coupled to the one or more processors. The one or more memories are used to store a computer program, and when the one or more processors execute the computer program, they execute the near-field communication method in the second aspect and any possible implementation of the second aspect described above.

[0072] Ninthly, embodiments of this application provide an NFC device including one or more processors, one or more memories, and a transceiver. The transceiver, the one or more memories, and the one or more memories are coupled to the one or more processors. The one or more memories are used to store a computer program, which, when executed by the one or more processors, performs the near-field communication method described in the first aspect and any possible implementation thereof.

[0073] The NFC device can be an electronic device or an NFC tag card.

[0074] In a tenth aspect, embodiments of this application provide a computer storage medium storing a computer program that, when executed by a processor, implements the near-field communication method described in the first aspect and any possible implementation thereof.

[0075] In one aspect, embodiments of this application provide a computer storage medium storing a computer program that, when executed by a processor, implements the near-field communication method in the second aspect and any possible implementation thereof.

[0076] In a twelfth aspect, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the near-field communication method in the first aspect and any possible implementation thereof.

[0077] In a thirteenth aspect, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the near-field communication method in the second aspect and any possible implementation thereof.

[0078] In a fourteenth aspect, embodiments of this application provide a chip system including a processing circuit and an interface circuit. The interface circuit is used to receive code instructions and transmit them to the processing circuit. The processing circuit is used to execute the code instructions to perform the near-field communication method in the first aspect and any possible implementation of the first aspect.

[0079] In a fifteenth aspect, embodiments of this application provide a chip system including a processing circuit and an interface circuit. The interface circuit is used to receive code instructions and transmit them to the processing circuit. The processing circuit is used to execute the code instructions to perform the near-field communication method in the second aspect and any possible implementation thereof.

[0080] The beneficial effects of the third, fifth to fifteenth aspects and any of the possible implementations of the third, fifth to fifteenth aspects can be referred to the beneficial effects of the first and fourth aspects and any of the possible implementations of the first and fourth aspects, which will not be repeated here. Attached Figure Description

[0081] Figure 1 is a schematic diagram of the working principle of NFC provided in an embodiment of this application;

[0082] Figure 2 is a schematic diagram of the architecture of an NFC system provided in an embodiment of this application;

[0083] Figure 3 is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0084] Figure 4 is a schematic diagram of an NFC protocol stack provided in an embodiment of this application;

[0085] Figures 5A-5D are schematic diagrams illustrating a user's manual selection of an NFC analog card swiping process according to an embodiment of this application.

[0086] Figure 6 is a flowchart illustrating a near-field communication method provided in an embodiment of this application;

[0087] Figure 7A is a schematic diagram of a Probe frame format provided in an embodiment of this application;

[0088] Figure 7B is a schematic diagram of the frame format of a Notify frame provided in an embodiment of this application;

[0089] Figures 8A-8D are schematic diagrams of a set of scenarios for automatically selecting NFC simulated card swiping provided in the embodiments of this application;

[0090] Figures 9A-9D are schematic diagrams of another set of scenarios for automatically selecting NFC simulated card swiping provided in the embodiments of this application;

[0091] Figure 10 is a flowchart illustrating a near-field communication method provided in an embodiment of this application;

[0092] Figure 11 is a schematic diagram of the file structure of an MF provided in an embodiment of this application;

[0093] Figure 12 is a flowchart illustrating an NFC analog card selection method according to another embodiment of this application;

[0094] Figure 13 is a schematic diagram of the card swiping process of the second NFC protocol provided in the embodiment of this application;

[0095] Figure 14 is a flowchart illustrating the near-field communication method when the first NFC protocol and the second NFC protocol coexist, as provided in an embodiment of this application.

[0096] Figure 15 is a flowchart illustrating a near-field communication method according to another embodiment of this application;

[0097] Figure 16 is a schematic diagram of the frame format of a Notify frame provided in an embodiment of this application;

[0098] Figure 17 is a schematic diagram of the swiping process of an NFC analog card in a near-field communication method provided in an embodiment of this application;

[0099] Figure 18 is a schematic diagram of the specific card swiping process of the NFC simulated card provided in the embodiments of this application;

[0100] Figure 19 is a schematic diagram of the file structure of an MF provided in another embodiment of this application;

[0101] Figure 20A illustrates the card-swiping process of an NFC analog card in a near-field communication method provided in another embodiment of this application.

[0102] Figure 20B illustrates the card-swiping process of an NFC analog card in a near-field communication method provided in another embodiment of this application.

[0103] Figure 21 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;

[0104] Figure 22 is a schematic diagram of a communication device provided in an embodiment of this application;

[0105] Figure 23 is a schematic diagram of another communication device provided in an embodiment of this application;

[0106] Figure 24 is a schematic diagram of another communication device provided in an embodiment of this application;

[0107] Figure 25 is a schematic diagram of another communication device provided in an embodiment of this application. Detailed Implementation

[0108] The technical solutions in the embodiments of this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; the word "and / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.

[0109] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0110] The working principle of NFC in the embodiments of this application is described below.

[0111] Figure 1 shows a schematic diagram of the working principle of NFC provided in an embodiment of this application.

[0112] As shown in Figure 1, the two parties communicating using NFC technology can include a proximity coupling device (PCD) (also known as an NFC card reader) and a proximity smart card (PICC). The PCD can achieve contactless communication with the PICC in close proximity. The PCD and PICC can allow near-field communication at specific data rates (e.g., 106kbps, 212kbps, 424kbps, or 848kbps) and specific frequencies (e.g., 13.56MHz). Communication between the PCD and PICC can occur at close range, for example, within a range of approximately 2 to 4 centimeters.

[0113] The PCD (Polymer Capacitor) can generate high-frequency alternating current to produce a radio frequency (RF) field of a specified frequency (e.g., 13.56 MHz), and transmit data to the PICC (Peripherally Input Cell) via this RF field. When the PICC is near the PCD, it can sense the RF field emitted by the PCD. Upon entering the RF field, the PICC can obtain energy from the PCD's RF field through electromagnetic induction, and use this energy to generate electricity to drive the internal circuitry of the PICC, thus enabling data transmission from the PCD to the PICC. Alternatively, the PICC can also transmit data to the PCD by modulating the RF field with a load, achieving data transmission from the PICC to the PCD.

[0114] In the embodiments of this application, PICC can be a physical NFC tag card. Some NFC devices (e.g., mobile phones, tablets, smartwatches, and other electronic devices) can also simulate themselves as PICCs that conform to NFC-related standards through data from NFC emulation cards to realize the functions of PICCs and interact with PCD via NFC.

[0115] The following describes an NFC system provided in an embodiment of this application.

[0116] Figure 2 shows a schematic diagram of the architecture of an NFC system 10 provided in an embodiment of this application.

[0117] As shown in Figure 2, the NFC system 10 may include an electronic device 100 and an NFC card reader 200. The electronic device 100 can simulate itself as a PICC conforming to NFC standards by using data information from an NFC emulation card to achieve PICC functionality. The NFC card reader 200 can act as a PCD to interact with the electronic device 100 in PICC mode via NFC.

[0118] In one possible implementation, the electronic device 100 can support both PICC mode and PCD mode. In PCD mode, the electronic device 100 can act as a PCD transmitter to communicate with the PICC. In PICC mode, the electronic device 100 can act as a PICC to passively receive the radio frequency field transmitted by the PCD and perform NFC interaction with the PCD through load modulation technology.

[0119] In this embodiment, after the electronic device 100 enables the NFC function, the electronic device 100 can be in PICC mode. If the electronic device 100 supports both PCD mode and PICC mode, after enabling the NFC function, the electronic device 100 can switch between PICC mode and PCD mode in a time-sharing manner.

[0120] In this embodiment of the application, the device type of electronic device 100 can be any of the following: mobile phone, tablet computer, handheld computer, desktop computer, laptop computer, ultra-mobile personal computer (UMPC), netbook, cellular phone, personal digital assistant (PDA), as well as smart home devices such as smart screens and smart speakers, wearable devices such as smart bracelets, smartwatches, and smart glasses, extended reality (XR) devices such as augmented reality (AR), virtual reality (VR), and mixed reality (MR), in-vehicle devices, or smart city devices.

[0121] The NFC card reader device 200 can be any of the following: mobile phone, tablet computer, handheld computer, desktop computer, laptop computer, super mobile personal computer, netbook, cellular phone, personal digital assistant, as well as smart home devices such as smart screens and smart speakers, wearable devices such as smart bracelets, smartwatches, and smart glasses, extended reality devices such as augmented reality, virtual reality, and mixed reality, vehicles, gates, smart locks, card readers, payment terminals, ticket purchase and / or ticket verification terminals, bank service terminals, and document card reading devices.

[0122] The following is a schematic diagram of the structure of an electronic device 100 provided in the embodiments of this application.

[0123] Figure 3 shows a schematic diagram of the structure of an electronic device 100 provided in an embodiment of this application.

[0124] As shown in Figure 3, the electronic device 100 may include a processor 101 and an NFC module 102. The processor 101 may run one or more applications. These applications may include one or more of the following: a wallet application, one or more host-based card emulation (HCE) applications, etc. Optionally, the electronic device 100 may also include a secure element (SE) 103 and / or a subscriber identity module (SIM) card 104. The processor 101 may be connected to the NFC module 102, the SE 103, and the SIM card 104, respectively. The NFC module 102 may also be connected to the SE 103 and the SIM card 104.

[0125] The NFC module 102 may include an NFC controller (not shown in Figure 3), an NFC transceiver (not shown in Figure 3), and an NFC memory (not shown in Figure 3). The NFC controller may be connected to the processor 101, and may also be connected to the NFC transceiver and the NFC memory, respectively.

[0126] The NFC controller is primarily used for modulation and demodulation of contactless communication signals, controlling the input and output of data in the NFC memory, and interacting with the processor 101. The NFC transceiver is used to transmit and receive NFC signals (e.g., 13.56MHz radio frequency signals), and may include an electromagnetic compatibility (EMC) filter circuit, a matching circuit, a receiving circuit, and an NFC antenna, where the NFC antenna may be a loop antenna, used to enable proximity-based contactless communication capabilities of the NFC module 102. The NFC memory can be used to store data sent by the NFC module 102 to the NFC reader device 200, as well as data received from the NFC reader device 200. In some embodiments, the NFC memory can be a shared memory that can be used by the various components in the NFC module 102; for example, some data in the NFC memory can be accessed by the NFC controller, while other data can be accessed by the SE 103.

[0127] In other embodiments, the NFC memory may be a collection of multiple memories. For example, the NFC controller may include a first memory among these multiple memories. The first memory may include instructions or data that the NFC controller has used or reused. If the NFC controller needs to use the instruction or data again, it can directly retrieve it from the first memory, thus reducing the waiting time of the NFC controller. SE103 may include a second memory among these multiple memories. The second memory may include card information such as that of the NFC emulator based on the secure element. Thus, if SE103 needs to read the card information of the NFC emulator, it can read the card information of the NFC emulator from the second memory in SE103. SIM card 104 may include a third memory among these multiple memories. The third memory may include card information such as that of the NFC emulator based on the SIM card. Thus, if SIM card 104 needs to read the card information of the NFC emulator, it can read the card information of the NFC emulator from the third memory in SIM card 104.

[0128] In some embodiments, the NFC memory described above may also store routing information. In some embodiments, this routing information may be controlled or managed by the NFC controller, and may include a routing table consisting of a list of routing rules. Each routing rule contains an applet identifier (AID) and a destination; the destination is the location where the applet used to implement the business logic of the NFC emulator card runs. The destination may include an HCE application running in the processor 101 of the electronic device 100, or an SE 103 or SIM card 104 connected to the NFC controller.

[0129] The SE103 and NFC module 102 can be two separate chips. Alternatively, the SE103 and NFC module 102 can be packaged into a single chip.

[0130] Electronic device 100 can activate one or more NFC emulator cards in an application based on user input, thereby enabling electronic device 100 to support one or more NFC services. The service processing logic for the NFC emulator card within electronic device 100 is specifically implemented by an applet. The applet can be stored and run in the corresponding hardware device or software module (e.g., HCE application, SIM card, SE, etc.) of the NFC emulator card.

[0131] The card emulation modes of electronic device 100 can be divided into hardware-based virtual card mode and software-based HCE mode. Among them:

[0132] 1. In hardware-based virtual card mode, electronic device 100 can provide the operating environment for the Applet corresponding to the NFC emulator card, as well as the storage and processing of the NFC emulator card's business data, through SE103 or SIM card 104. NFC module 102, as the front end of contactless communication, receives commands from the external PCD and forwards them to SE103 or SIM card 104. The Applet in SE103 or SIM card 104 then processes the commands and sends response data to the external PCD via NFC module 102. Users can activate one or more NFC emulator cards in a wallet application, which can write the Applets and card data of one or more NFC emulator cards into SE103. Alternatively, users can activate one or more NFC emulator cards in a SIM card application, which can write the Applets and card data of one or more NFC emulator cards into SIM card 104 for storage.

[0133] 2. In software-based HCE mode, the HCE application running in processor 101 can provide the operating environment for the Applet corresponding to the NFC emulator card, as well as the storage and processing of the NFC emulator card's business data. After receiving a command from an external PCD, NFC module 102 can send the command to the HCE application. The HCE application can process the command received by the NFC module through the Applet running in the HCE application or a cloud server, and generate response data for the PCD. The HCE application can then send the response data to NFC module 102. NFC module 102 can then send the response data to the external PCD. Users can activate one or more NFC emulator cards in the HCE application. The HCE application can run one or more NFC emulator card Applets and store the NFC emulator card data on the local memory of electronic device 100 or on a cloud server.

[0134] Optionally, the processor 101 can also run an NFC basic service module. The NFC basic service module can be used to provide common management functions for one or more NFC services. These common management functions may include file management, card activation, security management, service routing management, and other functions.

[0135] For example, in the card emulation scenario described above, the electronic device 100 has a native NFC-related application installed, and users can also download and install third-party applications from app stores. Generally, the native application can use a hardware-based virtual card solution, while the third-party application can use an HCE solution. The native application can be a wallet application, etc., and the third-party application can be, for example, Alipay, PayPal, WeChat, etc. The above examples are merely for explaining this application and should not be construed as limiting it.

[0136] The following describes an NFC protocol stack provided in an embodiment of this application.

[0137] Figure 4 shows a schematic diagram of an NFC protocol stack provided in an embodiment of this application.

[0138] As shown in Figure 4, the NFC protocol stack can include a physical layer, a radio frequency layer, an access layer, a transport layer, and an application layer.

[0139] The physical layer can be used to implement the physical characteristics of NFC technology communication.

[0140] The radio frequency (RF) layer can be used to implement RF specifications for NFC technology communication, such as data rate and RF signal frequency.

[0141] The access layer can be used to implement functions such as polling and device discovery, service result notification, card conflict management, transmission protocol negotiation, timeout and retransmission mechanism, PICC / PCD mode switching, and converged card selection.

[0142] The transport layer includes a high-speed data transmission protocol, which enables data transmission between the PCD and PICC at the application layer.

[0143] The application layer can be used to implement one or more NFC services and one or more service management policies. The one or more NFC services may include codeless payment, electronic tickets, access control, digital ID cards, all-scenario contactless payment, and short-range data transmission. The one or more service management policies may include any one or more of the following: file management, card long-term activation, security management, and service routing management. The processing logic of the NFC services can be executed by Applets. In one possible implementation, the processing logic of the service management policies can be executed by the NFC basic service module.

[0144] The following describes the process by which a user manually selects an NFC analog card to swipe on an electronic device 100 in an embodiment of this application.

[0145] Figures 5A-5D illustrate a set of schematic diagrams showing the process of a user manually selecting an NFC analog card for swiping, as provided in the embodiments of this application.

[0146] As shown in Figure 5A, the electronic device 100 can display a desktop 510. The desktop 510 can include icons for one or more applications. For example, these icons may include icons for a wallet application 511, a clock application, a settings application, a voice recorder application, a dialer application, a messaging application, a contacts application, and a camera application. A status bar 512 can be displayed at the top of the desktop 510. The status bar 512 can include one or more status indicators, which may include, but are not limited to, indicators for communication signal strength (e.g., cellular network signal, WLAN signal), time indicators, battery indicators, NFC function indicators 513, and other indicators. When the electronic device 100 displays the NFC function indicator 513 in the status bar 512, it indicates that the electronic device 100 has enabled the NFC function.

[0147] The electronic device 100 can receive input from the user on the icon 511 of the wallet application (e.g., clicking), and in response to the input, the electronic device 100 can display the wallet application interface 520 as shown in Figure 5B.

[0148] As shown in Figure 5B, the wallet application interface 520 may include one or more functional controls. These functional controls may include a card holder control 521, a payment control, a ride control, and a door opening control, etc.

[0149] Electronic device 100 can receive user input (e.g., a click) to the wallet control 521, and in response to the input, electronic device 100 can display wallet interface 530 as shown in FIG5C.

[0150] As shown in Figure 5C, the card wallet interface 530 may include options for one or more types of NFC simulated cards activated by the user. These options may include options for transportation cards, access control cards, smart lock key cards, and car key cards. For example, the transportation card option may include options for Shenzhen Tong transportation cards. The access control card options may include options for access control cards for communities A, B, and C. The smart lock key card option may include options for home lock key cards. The car key card option may include options for vehicle M9 key cards.

[0151] Electronic device 100 can receive input (e.g., a click) from a user on option 531 of the access card for community A. In response to this input, electronic device 100 can display the card swiping interface 540 as shown in Figure 5D.

[0152] As shown in Figure 5D, the card swiping interface 540 may include an icon 541 for the access card of Community A. Optionally, the card swiping interface 540 may also include a card swiping prompt 542, wherein the type of the card swiping prompt 542 may include one or more of the following: text prompt, image prompt, sound prompt, vibration prompt, etc. For example, the card swiping prompt 542 may be the text prompt "Please place the back of your mobile phone on the card reader to swipe the card". Optionally, the card swiping interface 540 may also include a default card setting control 543, an editing control 544, and a deletion control 545. The default card setting control 543 can be used to set the access card of Community A as the default NFC emulator card. The editing control 544 can be used to edit the name of the access card of Community A. The deletion control 545 can be used to delete the data of the access card of Community A.

[0153] When the electronic device 100 displays the card-swiping interface 540, if it is brought close to the NFC card reader, it can interact with the NFC card reader using the data of the NFC-enabled simulated card corresponding to the card-swiping interface 540 (e.g., an access card for community A). If the NFC-enabled simulated card corresponding to the card-swiping interface 540 matches the NFC card reader, the electronic device 100 and the NFC card reader can complete the NFC service for the NFC-enabled simulated card corresponding to the card-swiping interface 540. For example, the electronic device 100 verifies the data of the access card for community A with the NFC card reader on the gate of community A, thereby opening the gate of community A.

[0154] As can be seen from the above card-swiping process, when a user wants to use electronic device 100 in PICC mode to perform a target NFC service, they need to open the application, manually select the target NFC simulation card corresponding to the target NFC service, and then bring the electronic device 100 close to the NFC card reader to complete the target NFC service. This means that every time a user wants to use the NFC service, they need to open the application and reselect the target NFC simulation card, which is very inconvenient for the user.

[0155] In one possible implementation, the user can set a frequently used NFC emulator as the default NFC emulator within the application. This way, when the electronic device 100 is near the NFC reader, it can use the data from the default NFC emulator to interact with the NFC reader. However, if the default NFC emulator is incompatible with the NFC reader, the user still needs to open the application on the electronic device 100 and reselect the target NFC emulator to interact with the NFC reader. Therefore, it's not possible for the electronic device 100 to automatically and accurately select the appropriate NFC emulator.

[0156] Therefore, this application provides an NFC emulator card selection method. When an electronic device 100 enters the radio frequency field emitted by an NFC reader 200, it can receive a probe frame emitted by the NFC reader 200. After receiving the probe frame, the electronic device 100 can send a probe acknowledgement (Probe ACK) frame to the NFC reader 200, which indicates that the electronic device 100 has received the probe frame. After receiving the probe frame, the NFC reader 200 can send a notification frame to the electronic device 100, wherein the notification frame carries the device characteristic information of the NFC reader. After receiving the notification frame, the electronic device 100 can determine the first NFC emulator card from one or more NFC emulator cards using the device characteristic information. The electronic device 100 can then interact with the NFC reader 200 via NFC to complete the swipe transaction of the first NFC emulator card. This allows the electronic device 100 to automatically and accurately select the appropriate NFC emulator card and quickly display the swipe interface of the first NFC emulator card, improving the speed and efficiency of NFC swipe transactions.

[0157] The following describes a near-field communication method provided in the embodiments of this application.

[0158] Figure 6 illustrates, by way of example, a flowchart of a near-field communication method provided in an embodiment of this application.

[0159] As shown in Figure 6, this NFC simulated card selection method can be applied to a communication system including an electronic device 100 and an NFC card reader 200. The NFC card reader 200 can operate in PCD mode. The electronic device 100, after enabling the NFC function, is in PICC mode by default. This NFC simulated card selection method may include the following steps:

[0160] S601. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0161] S602.NFC card reader 200 sends a probe frame.

[0162] The Probe frame can be used to indicate that the NFC reader 200 supports a specified NFC protocol (which may be referred to as the first NFC protocol). The NFC reader 200 can send Probe frames periodically.

[0163] For example, as shown in Figure 7A, a Probe frame may include a frame control header and a check field. The frame control header can be 3 bytes long, and the check field can be 2 bytes long. The frame control header may include a protocol identifier field, a frame type field, and a protocol version field. The NFC protocol can use cyclic redundancy check (CRC) to verify NFC transmission frames. Therefore, the check field of this Probe frame can carry a CRC code.

[0164] NFC transmission frames can include data frames, probe frames, probe ACK frames, conflict frames, conflict ACK frames, pick frames, pick ACK frames, notify frames, notify ACK frames, reset frames, reset ACK frames, command frames, and response frames. The frame type field of an NFC transmission frame indicates its frame type. For example, the frame type field in a data frame can have a value of "0x00". The frame type field in the Probe frame can have a value of "0x01", the Probe ACK frame can have a value of "0x02", the Conflict frame can have a value of "0x03", the Conflict ACK frame can have a value of "0x04", the Pick frame can have a value of "0x05", the Pick ACK frame can have a value of "0x06", the Notify frame can have a value of "0x07", the Notify ACK frame can have a value of "0x08", the Reset frame can have a value of "0x09", the Reset ACK frame can have a value of "0x0A", the Command frame can have a value of "0x0B", and the Response frame can have a value of "0x0C". The frame type field values ​​"0x0D~0x88" are reserved values ​​for use in expanding the NFC transmission frame types in the first NFC protocol. The value of the frame type field, "0x09~0xFF", can be a vendor-defined value. The above example is only for explaining this application and should not be construed as limiting it.

[0165] The protocol identifier field can have a data length of 1 byte. The protocol identifier field in the Probe frame can be used to indicate the specified NFC protocol (i.e., the first NFC protocol) used by the NFC reader device 200 when sending the Probe frame. The value of the protocol identifier field can be an identifier of the specified NFC protocol, for example, "0x7C".

[0166] The frame type field can be 1 byte long. The frame type field in a Probe frame can be used to indicate the frame type of the Probe frame. For example, the value of the frame type field in a Probe frame can be "0x01".

[0167] S603. After receiving a probe frame, electronic device 100 sends a probe ACK frame to NFC card reader 200.

[0168] The Probe ACK frame can be used to indicate that the electronic device 100 supports the specified NFC protocol indicated by the Probe frame (which may be referred to as the first NFC protocol).

[0169] If electronic device 100 does not support the specified NFC protocol indicated by the Probe frame, electronic device 100 may not send a Probe ACK frame.

[0170] S604. After receiving the Probe ACK frame, the NFC card reader 200 sends a notification frame to the electronic device 100, wherein the notification frame carries the device feature information of the NFC card reader 200.

[0171] In one possible implementation, the Probe ACK frame may carry a result indicating whether the electronic device 100 supports the specified NFC protocol. If the electronic device 100 supports the specified NFC protocol indicated by the Probe frame, the electronic device 100 may carry result A in the Probe ACK frame, indicating that the electronic device 100 supports the specified NFC protocol; if the electronic device 100 does not support the specified NFC protocol indicated by the Probe frame, the electronic device 100 may carry result B in the Probe ACK frame, indicating that the electronic device 100 does not support the specified NFC protocol. When the NFC card reader 200 receives the Probe ACK frame carrying result A sent by the electronic device 100, the NFC card reader 200 may send a Notify frame to the electronic device 100.

[0172] The device characteristic information may include the service identifier (SID) and the device organization identifier (also known as the NFC device organization unique identifier (ND_OUI)).

[0173] Optionally, device characteristic information may include one or more of the following: Service Identifier (SID), Device Organization Identifier (ND_OUI), and Device Group Identifier (also known as NFC Device Group Identifier (ND_GID)).

[0174] 1. The Service Identifier (SID) can be used to indicate the type of NFC service supported by the NFC reader device 200 on the basis of NFC functionality.

[0175] In one possible implementation, the NFC service type can include a primary service type and a sub-service type. Therefore, the service identifier can include a primary service identifier and a sub-service identifier. The primary service identifier can be used to indicate the primary service type supported by the NFC reader 200, and the sub-service identifier can be used to indicate the sub-service types supported by the NFC reader 200 under a certain primary service type. The primary service type can include one or more of the following: access control, keys, transportation, banking, digital currency, digital certificates, codeless payment, electronic tickets, wireless charging, contactless payment, multi-function cards, etc. The sub-service types corresponding to access control can include one or more of the following: community access control, enterprise access control, government access control, campus access control, etc. The sub-service types corresponding to keys can include one or more of the following: smart locks, Intelligent Car Connectivity Industry Ecosystem Alliance (ICCE) car keys, Car Connectivity Consortium (CCC) car keys, Intelligent Car Connectivity Open Alliance (ICCOA) car keys, hotel room cards, etc. The sub-service types for transportation cards can include one or more of the following: transportation cards within China and transportation cards outside China. The sub-service types for banks can include one or more of the following: UnionPay, UnionPay International, Visa, and Mastercard. The sub-service types for digital currencies can include digital currencies as defined by the People's Bank of China. The sub-service types for digital certificates can include one or more of the following: ID cards, Hong Kong and Macau travel permits, driver's licenses, social security cards, and passports. The sub-service types for code-free payment can include one or more of the following: general services, membership card discount services, and payment institution discount services. The sub-service types for electronic tickets can include electronic ticketing for park entry. The sub-service types for wireless charging can include wireless charging. The sub-service types for tap-to-pay can include one or more of the following: tap-to-pair, tap-to-multi-screen collaboration, tap-to-transfer audio, tap-to-transfer image, tap-to-add friends, and tap-to-transfer. The sub-service types for multi-functional cards can include one or more of the following: multi-functional all-in-one cards.

[0176] The main service identifier can occupy 1 byte, and the sub-service identifier can occupy 1 byte. For example, the values ​​of the main service identifier and the sub-service identifier can be shown in Table 1 below.

[0177] Table 1

[0178] It can be seen from Table 1 above:

[0179] 1.1 When the main service identifier is “0x01”, the main service type is access control.

[0180] If the sub-service identifier is "0x01", the sub-service type is community access control. If the sub-service identifier is "0x02", the sub-service type is enterprise access control. If the sub-service identifier is "0x03", the sub-service type is government access control. If the sub-service identifier is "0x04", the sub-service type is campus access control. When the main service type is access control, the sub-service identifier values ​​"0x00" and "0x05~0xFF" can be reserved for protocol extensions.

[0181] 1.2 When the primary service identifier is “0x02”, the primary service type is key.

[0182] If the sub-service identifier is "0x01", the sub-service type is a smart door lock. If the sub-service identifier is "0x02", the sub-service type is an ICCE car key. If the sub-service identifier is "0x03", the sub-service type is a CCC car key. If the sub-service identifier is "0x04", the sub-service type is an ICCOA car key. If the sub-service identifier is "0x05", the sub-service type is a hotel room key. When the main service type is a key, the sub-service identifier values ​​"0x00" and "0x06~0xFF" can be reserved for protocol extensions.

[0183] 1.3 When the primary service identifier is “0x03”, the primary service type is transportation.

[0184] If the sub-service identifier is "0x01", the sub-service type is a transportation card within China. If the sub-service identifier is "0x02", the sub-service type is a transportation card outside of China. When the main service type is transportation, the sub-service identifier values ​​"0x00" and "0x03~0xFF" can be reserved for protocol extensions.

[0185] 1.4. When the main service identifier is “0x04”, the main service type is Bank.

[0186] If the sub-service identifier is "0x01", the sub-service type is UnionPay, UnionPay International, Visa, or Mastercard. In the case where the primary service type is a bank, the sub-service identifier values ​​"0x00" and "0x02~0xFF" can be reserved for protocol extensions.

[0187] 1.5. When the main service identifier is “0x05”, the main service type is digital currency.

[0188] If the sub-service identifier is "0x00", the sub-service type is digital currency as defined by the People's Bank of China. In cases where the main service type is digital currency, the sub-service identifier value "0x01~0xFF" can be reserved for protocol extensions.

[0189] 1.6 When the main service identifier is “0x06”, the main service type is digital certificate.

[0190] If the sub-service identifier is "0x01", the sub-service type is ID card. If the sub-service identifier is "0x02", the sub-service type is Mainland Travel Permit for Hong Kong and Macao Residents. If the sub-service identifier is "0x03", the sub-service type is driver's license. If the sub-service identifier is "0x04", the sub-service type is social security card. If the sub-service identifier is "0x05", the sub-service type is passport. When the main service type is digital document, the sub-service identifier values ​​"0x00" and "0x06~0xFF" can be reserved for protocol extensions.

[0191] 1.7 When the main service identifier is “0x07”, the main service type is codeless payment.

[0192] If the sub-service identifier is "0x01", the sub-service type is a general service. If the sub-service identifier is "0x02", the sub-service type is a membership card discount service. If the sub-service identifier is "0x03", the sub-service type is a payment institution discount service. When the main service type is codeless payment, the sub-service identifier values ​​"0x00" and "0x04~0xFF" can be reserved for protocol extensions.

[0193] 1.8 When the main service identifier is “0x08”, the main service type is electronic ticket.

[0194] If the sub-service identifier is "0x01", the sub-service type is electronic ticket entry service. In the case where the main service type is electronic ticket, the sub-service identifier values ​​"0x00" and "0x04~0xFF" can be reserved for protocol extensions.

[0195] 1.9 When the main service identifier is “0x09”, the main service type is wireless charging.

[0196] If the sub-service identifier is "0x00", the sub-service type is wireless charging. When the main service type is wireless charging, the sub-service identifier value "0x01~0xFF" can be reserved for protocol extensions.

[0197] 1.10. When the main service identifier is “0x0A”, the main service type is the tap-to-win function.

[0198] If the sub-service identifier is "0x01", the sub-service type is one-touch pairing. If the sub-service identifier is "0x02", the sub-service type is one-touch multi-screen collaboration. If the sub-service identifier is "0x03", the sub-service type is one-touch audio transmission. If the sub-service identifier is "0x04", the sub-service type is one-touch image transmission. If the sub-service identifier is "0x05", the sub-service type is one-touch adding friends. If the sub-service identifier is "0x06", the sub-service type is one-touch data transfer. When the main service type is the "touch-to-touch" function, the sub-service identifier values ​​"0x00" and "0x07~0xFF" can be reserved for protocol extensions.

[0199] 1.11. When the primary service identifier is “0x0B”, the primary service type is a multi-function card.

[0200] If the sub-service identifier is "0x01", the sub-service type is a multi-functional all-in-one card. In the case where the main service type is a multi-functional card, the sub-service identifier values ​​"0x00" and "0x02~0xFF" can be reserved for protocol extensions.

[0201] 1.12 The values ​​of the main service identifier "0x00" and "0x0B~0xFF" can be reserved for protocol extensions.

[0202] The examples shown in Table 1 above are for illustrative purposes only and should not be construed as limiting the scope of this application.

[0203] 2. The Device Organization Identifier (ND_OUI) can be used to indicate the manufacturer providing NFC services using the NFC card reader device 200. The NFC protocol standards organization's registration management agency can assign different Device Organization Identifiers to different manufacturers. For example, manufacturers providing NFC services may include one or more smart lock manufacturers, one or more property management companies, one or more automotive parts manufacturers, one or more transportation card management departments, etc.

[0204] For example, if the NFC service of the NFC card reader 200 is for community access control, the device organization identifier of the NFC card reader 200 can be the organization identifier applied for by the property management company to which the NFC card reader 200 belongs to the NFC standards organization. For example, the device organization identifier applied for by Vanke Property Management Company to the registration management agency of the NFC standards organization can be "0x1A3B27".

[0205] If the NFC service provided by the NFC reader 200 is for smart locks, the device organization identifier of the NFC reader 200 can be the organization identifier applied for by the smart lock manufacturer to which the NFC reader 200 belongs from the NFC standards organization.

[0206] If the NFC service provided by the NFC reader 200 is a car key, the device organization identifier of the NFC reader 200 can be the organization identifier applied for by the vehicle manufacturer to which the NFC reader 200 belongs from the NFC standards organization.

[0207] If the NFC service provided by the NFC card reader 200 is a multi-functional all-in-one card, the device organization identifier of the NFC card reader 200 can be the organization identifier applied for by the all-in-one card issuing organization to the NFC standards organization. The PICC corresponding to the multi-functional all-in-one card can include campus cards, employee cards, and other cards with multiple functions such as access control, stored value, and consumption. The all-in-one card issuing organization to which the NFC card reader 200 belongs can include organizations such as companies and schools.

[0208] The above examples are merely for explaining this application and should not be construed as limiting this application.

[0209] 3. The Device Group Identifier (ND_GID) can be used to indicate the group to which the NFC services provided by the NFC reader 200 belong. The Device Group Identifier can be assigned based on the purpose and location of the NFC reader 200. Different NFC services can be assigned to different groups.

[0210] For example, if the NFC service provided by the NFC reader 200 is community access control, the device group identifier of the NFC reader 200 may include a hash value obtained by hashing the city name and the community name together, and a random number. For instance, the data length of the device group identifier of the NFC reader 200 can be 6 bytes, the hash value obtained by hashing the city name and the community name together can be located in the first 4 bytes of the device group identifier, and the random number can be located in the last 2 bytes of the device group identifier.

[0211] If the NFC service provided by the NFC reader 200 is a smart lock, the device group identifier of the NFC reader 200 may include the hash value obtained by hashing the serial number (SN) of the NFC reader 200, and a random number. For example, the data length of the device group identifier of the NFC reader 200 can be 6 bytes, the hash value obtained by hashing the serial number (SN) of the NFC reader 200 can be located in the first 4 bytes of the device group identifier, and the random number can be located in the last 2 bytes of the device group identifier.

[0212] If the NFC service provided by the NFC reader 200 is a car key, the device group identifier of the NFC reader 200 may include the hash value obtained by hashing the vehicle identification number (VIN) of the NFC reader 200, and a random number. For example, the data length of the device group identifier of the NFC reader 200 can be 6 bytes, the hash value obtained by hashing the vehicle identification number of the NFC reader 200 can be located in the first 4 bytes of the device group identifier, and the random number can be located in the last 2 bytes of the group identifier.

[0213] If the NFC service provided by the NFC card reader 200 is a multi-functional all-in-one card, the device group identifier of the NFC card reader 200 can be a preset value.

[0214] The above examples are merely for explaining this application and should not be construed as limiting this application.

[0215] As shown in Figure 7B, a Notify frame may include a frame control header, a device identifier element, and a checksum field. The frame control header of a Notify frame can be 4 bytes long and may include a protocol identifier field, a frame type field, a control information field, and a frame length field.

[0216] The protocol identifier field in the Notify frame can be 1 byte long. This field indicates the specific NFC protocol used by the NFC reader 200 when sending the Notify frame. The value of this protocol identifier field can be an identifier for the specified NFC protocol, such as "0x7C".

[0217] The frame type field in a Notify frame can be 1 byte long. The frame type field in a Notify frame indicates the frame type of the Notify frame. For example, the value of the frame type field in a Notify frame can be "0x05".

[0218] The control information field in the Notify frame can be 1 byte long. This field can be used to indicate whether multiple PICC devices are conflicting. PICC devices include physical NFC tags, electronic devices in PICC mode, etc.

[0219] The frame length field in a Notify frame can have a data length of 1 byte. The frame length field in a Notify frame can be used to indicate the data length of the device identifier element.

[0220] The device identification element may include device characteristic information. This device characteristic information may include a Service Identifier (SID) and a Device Organization Identifier (ND_OUI). Optionally, the device characteristic information may also include a Device Group Identifier (ND_GID). The Service Identifier (SID) can be 2 bytes long, the Device Organization Identifier (ND_OUI) can be 3 bytes long, and the Device Group Identifier (ND_GID) can be 6 bytes long.

[0221] Optionally, the device identification elements may also include element code, identification mask, device type identifier, and device individual identifier.

[0222] Element codes are used to identify control elements. These control elements can include one or more of the following: device identification elements, card identification elements, transmission capability elements, and security algorithm elements. Control elements can be flexibly combined and carried in the NFC control frame. Since the Notify frame carries the device identification element, the element code in the Notify frame is used to indicate the identification of this element. The element code can be 1 byte long; for example, the element code for the device identification element can be "0x00", the element code for the card identification element can be "0x01", the element code for the transmission capability element can be "0x02", and the element code for the security algorithm element can be "0x03". The values ​​of the element code "0x04~0xFF" can be reserved for protocol extensions or manufacturer-defined uses.

[0223] The identifier mask in the device identifier element can be used to indicate the type of device identifier carried in the device identifier element. The data length of the identifier mask can be 1 byte.

[0224] Device identifiers may include one or more of the following: device type identifier (also known as NFC device type identifier (ND_TID)), service identifier (SID), device organization identifier (ND_OUI), device group identifier (ND_GID), and device private identifier (also known as NFC device private identifier (ND_PID)).

[0225] The device type identifier can be used to indicate the device type of the NFC card reader 200. The device type indicated in the device type identifier can include any of the following: mobile phone, wearable device, card reader that does not require interaction with electronic devices, or card reader that requires interaction with electronic devices. The correspondence between the device type identifier and the device type is shown in Table 2 below.

[0226] Table 2

[0227] As shown in Table 2 above, when the device type identifier is "0x01", it indicates that the device type of the NFC card reader 200 is a mobile phone. When the device type identifier is "0x02", it indicates that the device type of the NFC card reader 200 is a wearable device. When the device type identifier is "0x03", it indicates that the device type of the NFC card reader 200 is a card reader that does not require NFC interaction with electronic devices, such as security gates and wireless charging devices. When the device type identifier is "0x04", it indicates that the device type of the NFC card reader 200 is a card reader that requires NFC interaction with electronic devices, such as access control devices, transportation card readers, and vehicles. The device type identifier values ​​"0x00" and "0x05~0xFF" are reserved for protocol extensions. Table 2 above is used to explain this application and should not be construed as limiting this application.

[0228] The Device Individual Identifier (ND_PID) can be used to indicate the individual identifier of the NFC card reader 200 within a class of card readers under the same device organization identifier and the same device group identifier. The manufacturer of the NFC card reader 200 needs to ensure that the device individual identifiers of card readers within a class of card readers with the same device organization identifier and the same device group identifier are different.

[0229] In the embodiments of this application, the format of the Notify frame shown in FIG7B above is an example for explaining this application and should not be construed as limiting this application.

[0230] S605. Based on the device feature information of the NFC card reader 200, the electronic device 100 determines the first NFC emulated card from one or more NFC emulated cards on the electronic device 100.

[0231] The electronic device 100, after activating one or more NFC simulation cards, can store the device feature information corresponding to each of the one or more NFC simulation cards. Different NFC simulation cards correspond to different device feature information. For example, the correspondence between device feature information and NFC simulation cards can be shown in Table 3 below:

[0232] Table 3

[0233] As shown in Table 3 above, device feature information 1 corresponds to the access card of Community A. The main service identifier of device feature information 1 can be "0x01", the sub-service identifier can be "0x01", the device organization identifier can be "0x1A3B27", and the device group identifier can be "0x18ed29d7c6d5". Device feature information 2 corresponds to the access card of Community B. The main service identifier of device feature information 2 can be "0x01", the sub-service identifier can be "0x01", the device organization identifier can be "0x1A3B27", and the device group identifier can be "0x89b6337b0006". Device feature information 3 corresponds to the access card of Community C. The main service identifier of device feature information 3 can be "0x01", the sub-service identifier can be "0x01", the device organization identifier can be "0x1A3B29", and the device group identifier can be "0x7b04481a15c0". Device characteristic information 4 corresponds to the Shenzhen Tong transportation card. The main service identifier for device characteristic information 4 can be "0x03", the sub-service identifier can be "0x01", and the device organization identifier can be "0x2C3D11". Device characteristic information 5 corresponds to the home door lock key card. The main service identifier for device characteristic information 5 can be "0x02", the sub-service identifier can be "0x01", the device organization identifier can be "0x332A99", and the device group identifier can be "0x5ea970d54450". Device characteristic information 6 corresponds to the vehicle M9 key card. The main service identifier for device characteristic information 6 can be "0x02", the sub-service identifier can be "0x02", the device organization identifier can be "0x37BCA1", and the device group identifier can be "0x38d112bd15d3".

[0234] For example, the device feature information of the NFC card reader 200 is the device feature information 1 shown in Table 3 above. After receiving the Notify frame carrying the NFC card reader 200, the electronic device 100 determines that the first NFC analog card matching the device feature information of the NFC card reader 200 is the access card of community A.

[0235] The examples shown in Table 3 above are only for explaining this application and should not be construed as limiting this application.

[0236] In one possible implementation, the correspondence between device feature information and NFC emulator cards can be managed and stored by the NFC module 102 (e.g., stored internally in the NFC module 102 or in the SE). Upon receiving a Notify frame, the NFC module 102 in the electronic device 100 can determine the first NFC emulator card from one or more NFC emulator cards in the electronic device 100 based on the device feature information of the NFC card reader 200. Then, the NFC module 102 can send the identifier of the first NFC emulator card to an application running in the processor 101 (e.g., a wallet application), causing the application to display a swipe notification for the first NFC emulator card.

[0237] In one possible implementation, the mapping between device feature information and NFC emulator cards can be stored by an application running in processor 101 (e.g., stored within the application or in the processor's trusted execution environment (TEE)). Upon receiving a Notify frame, the NFC module 102 in electronic device 100 can send the device feature information of the NFC reader 200 to the application running in processor 101. The application running in processor 101 can then determine the first NFC emulator card from one or more NFC emulator cards in electronic device 100 based on the device feature information of the NFC reader 200. The application running in processor 101 (e.g., a wallet application) can then display a swipe notification for the first NFC emulator card.

[0238] S606. After identifying the first NFC emulated card, the electronic device 100 outputs a card swiping prompt for the first NFC emulated card.

[0239] The swipe notification of the first NFC simulated card can be used to indicate that an electronic device is using the first NFC simulated card for swiping. The swipe notification of the first NFC simulated card can include one or more of the following: image notification, text notification, audio notification, and vibration notification. Image notifications include one or more of the following: static image notification, dynamic image notification, and video notification.

[0240] For example, after identifying the first NFC simulated card, the electronic device 100 can display a card-swiping interface for the first NFC simulated card. This interface may include information about the first NFC simulated card. For instance, the information could be a card-shaped icon displaying the name of the first NFC simulated card. The card-swiping interface can be used to notify the user that the electronic device 100 is using the first NFC simulated card.

[0241] S607. After identifying the first NFC emulated card, the electronic device 100 sends a Notify ACK frame to the NFC card reader 200. This Notify ACK frame carries a first notification result. The first notification result can be used to indicate that the electronic device 100 has successfully selected the first NFC emulated card.

[0242] If electronic device 100 fails to select an NFC analog card from one or more NFC analog cards that matches the device feature information of NFC card reader 200, electronic device 100 may send a notification confirmation frame carrying a second notification result. The second notification result indicates that electronic device 100 failed to select an NFC analog card. After receiving the notification confirmation frame carrying the second notification result, NFC card reader 200 periodically sends probe frames.

[0243] S608. Electronic device 100 and NFC card reader 200 interact via NFC to complete the card swiping transaction of the first NFC simulated card.

[0244] The card-swiping service can include any one of the following: opening access control, unlocking doors, unlocking vehicles, making transactions, verifying electronic tickets, verifying digital documents, and swiping transportation cards to get on and off vehicles.

[0245] Specifically, electronic device 100 can send the card information of the first NFC simulated card to NFC card reader 200 via NFC data interaction. NFC card reader 200 can then perform a card swiping transaction based on the card information of the first NFC simulated card. NFC card reader 200 can also send the card swiping result of the first NFC simulated card to electronic device 100 via NFC command interaction.

[0246] The card information of the first NFC simulated card may include one or more of the following: access control information, key information, transaction account information, and electronic ticket information. Access control information may include one or more of the following: card number, card validity period, etc. Key information may include one or more of the following: key code, key code validity period, etc. Transaction account information may include one or more of the following: transaction account identifier, remaining balance in the transaction account, etc. Electronic ticket information may include one or more of the following: electronic ticket code, electronic ticket verification time, electronic ticket validity period, etc.

[0247] This application provides a near-field communication method. When an electronic device 100 enters the radio frequency field emitted by an NFC card reader 200, it can receive a probe frame emitted by the NFC card reader 200. Upon receiving the probe frame, the electronic device 100 can send a probe acknowledgement (Probe ACK) frame to the NFC card reader 200, indicating that it has received the probe frame. After receiving the probe frame, the NFC card reader 200 can send a notification frame to the electronic device 100, which carries device characteristic information of the NFC card reader 200. Upon receiving the notification frame, the electronic device 100 can use the device characteristic information of the NFC card reader 200 to identify a first NFC simulated card from one or more NFC simulated cards and display the card-swiping interface of the first NFC simulated card. The electronic device 100 can interact with the NFC card reader 200 via NFC to complete the card-swiping transaction of the first NFC simulated card. This allows the electronic device 100 to automatically and accurately select the appropriate NFC simulation card and quickly display the card swiping interface for the first NFC simulation card, thus improving the speed and efficiency of NFC card swiping.

[0248] Figures 8A-8D illustrate a set of scenario diagrams for automatically selecting NFC simulated card swiping provided in the embodiments of this application.

[0249] For example, as shown in Figure 8A, the NFC card reader 200 can be an access control gate. When a physical NFC tag card or an electronic device 100 in PICC mode is brought close to the card-swiping area of ​​the NFC card reader 200, the physical NFC tag card or the electronic device 100 in PICC mode can interact with the NFC card reader 200 via NFC. The electronic device 100 can be in PICC mode after enabling the NFC function. The electronic device 100 can have one or more NFC analog cards activated. For example, these one or more NFC analog cards can include a Shenzhen Tong transportation card, an access control card for residential area A, an access control card for residential area B, an access control card for residential area C, a home door lock key card, and a vehicle M9 key card, etc.

[0250] As shown in Figure 8B, when the screen is off, the electronic device 100 can be placed close to the card-swiping area of ​​the NFC card reader 200. After detecting the electronic device 100, the NFC card reader 200 can perform NFC signaling interaction with the electronic device 100.

[0251] As shown in Figure 8C, after receiving a Notify frame from the NFC card reader 200, the electronic device 100 can select the access card for community A that matches the NFC card reader 200 from one or more NFC analog cards based on the device feature information of the NFC card reader 200 carried in the Notify frame. The electronic device 100 can then turn on its screen and display a card swiping interface 810. The card swiping interface 810 displays a card icon 811 corresponding to the access card for community A. This card icon 811 can be used to indicate to the user that the electronic device 100 is using the access card for community A.

[0252] As shown in Figure 8D, electronic device 100 can send the card information of access card for community A to NFC card reader 200 for verification. If NFC card reader 200 successfully verifies the card information of access card for community A, it sends a card swipe result 1 to electronic device 100 and opens the gate of NFC card reader 200. Card swipe result 1 indicates that the NFC analog card was swiped successfully. After receiving card swipe result 1, electronic device 100 can display a prompt 812 on the card swipe interface 810. Prompt 812 can be used to notify the user that the gate of NFC card reader 200 has been successfully opened. Prompt 812 can be one or more of the following: text prompt, image prompt, audio prompt, vibration prompt, etc. For example, prompt 812 can be the text prompt "Access control successful" and an image prompt with a checkmark pattern.

[0253] If the NFC card reader 200 fails to verify the access card information of community A, it sends a card swipe result 2 to the electronic device 100. Card swipe result 2 indicates that the NFC simulated card swipe failed.

[0254] Figures 9A-9D illustrate another set of scenarios for automatically selecting NFC analog card swiping provided in the embodiments of this application.

[0255] For example, as shown in Figure 9A, the NFC card reader 200 can be a smart door lock. When a physical NFC tag card or an electronic device 100 in PICC mode is brought close to the card-swiping area of ​​the NFC card reader 200, the physical NFC tag card or the electronic device 100 in PICC mode can interact with the NFC card reader 200 via NFC. The electronic device 100 can be in PICC mode after enabling the NFC function. The electronic device 100 can have one or more NFC analog cards activated. For example, these one or more NFC analog cards can include a Shenzhen Tong transportation card, an access card for residential area A, an access card for residential area B, an access card for residential area C, a home door lock key card, and a vehicle M9 key card, etc.

[0256] As shown in Figure 9B, when the screen is off, the electronic device 100 can be placed close to the card-swiping area of ​​the NFC card reader 200. After detecting the electronic device 100, the NFC card reader 200 can perform NFC signaling interaction with the electronic device 100.

[0257] As shown in Figure 9C, after receiving a Notify frame from the NFC card reader 200, the electronic device 100 can select a matching home lock key card from one or more NFC analog cards based on the device feature information of the NFC card reader 200 carried in the Notify frame. The electronic device 100 can then light up its screen and display a card swiping interface 910. The card swiping interface 910 displays a card icon 911 corresponding to the home lock key card. This card icon 911 serves to indicate to the user that the electronic device 100 is using the home lock key card for swiping.

[0258] As shown in Figure 9D, electronic device 100 can send the card information of a home door lock key card to NFC card reader 200 for verification. If NFC card reader 200 successfully verifies the home door lock key card information, it sends a card swipe result 1 to electronic device 100 and unlocks the door lock of NFC card reader 200. Card swipe result 1 indicates that the NFC analog card was successfully swiped. After receiving card swipe result 1, electronic device 100 can display a prompt 912 on the card swiping interface 910. Prompt 912 can be used to notify the user that the NFC card reader 200's door has been successfully unlocked. Prompt 912 can be one or more of the following: text prompt, image prompt, audio prompt, vibration prompt, etc. For example, prompt 912 can be the text prompt "Door access successful" and an image prompt with a checkmark pattern.

[0259] If the NFC card reader 200 fails to verify the card information of the home lock key card, it sends a card swipe result 2 to the electronic device 100. Card swipe result 2 indicates that the NFC analog card swipe failed.

[0260] It should be noted that, in this embodiment, the electronic device 100 has one or more NFC emulator cards activated. The electronic device 100 can be brought close to the NFC reader 200 when the screen is off, locked, or the desktop is displayed, without any NFC emulator card swiping interface, thereby entering the NFC reader 200's radio frequency field. The NFC reader 200 can interact with the electronic device 100 via NFC signaling, allowing the electronic device 100 to obtain the device feature information of the NFC reader 200 from the Notify frames sent by the NFC reader 200. Based on the device feature information of the NFC reader 200, after determining the first NFC emulator card from the one or more activated NFC emulator cards, the electronic device 100 can output a swiping prompt for the first NFC emulator card. This allows the user to automatically and accurately select the NFC emulator card matching the NFC reader 200 without needing to pre-select a specific NFC emulator card.

[0261] The following describes a near-field communication method provided in the embodiments of this application, using NFC signaling interaction as an example.

[0262] Figure 10 illustrates, by way of example, a flowchart of a near-field communication method provided in an embodiment of this application.

[0263] As shown in Figure 10, this NFC simulated card selection method can be applied to a communication system including an electronic device 100 and an NFC card reader 200. The NFC card reader 200 can operate in PCD mode. The electronic device 100, after enabling the NFC function, is in PICC mode by default. This NFC simulated card selection method may include the following steps:

[0264] S1001. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0265] S1002.NFC card reader 200 sends a probe frame.

[0266] S1003. After receiving the probe frame, the electronic device 100 sends a probe ACK frame to the NFC card reader 200.

[0267] S1004. After receiving the Probe ACK frame, the NFC card reader 200 sends a notification frame to the electronic device 100, wherein the notification frame carries the device feature information of the NFC card reader 200.

[0268] S1005. Based on the device feature information of the NFC card reader 200, the electronic device 100 determines the first NFC emulated card from one or more NFC emulated cards on the electronic device 100.

[0269] S1006. After identifying the first NFC emulated card, the electronic device 100 outputs a card swiping prompt for the first NFC emulated card.

[0270] S1007. After identifying the first NFC emulated card, the electronic device 100 sends a Notify ACK frame to the NFC card reader 200. This Notify ACK frame carries a first notification result. The first notification result can be used to indicate that the electronic device 100 has successfully selected the first NFC emulated card.

[0271] The specific details of steps S1001 to S1007 can be found in steps S601 to S607 of the embodiment shown in Figure 6 above, and will not be repeated here.

[0272] After receiving the notification confirmation frame, the S1008.NFC card reader 200 sends a Select AID command to the electronic device 100, wherein the Select AID command carries the identifier of the first Applet.

[0273] S1009. Electronic device 100, based on the identifier of the first applet, determines the first applet from one or more applets and runs the first applet.

[0274] In electronic device 100, the service processing logic of the NFC emulator card is specifically implemented by an applet. The applet can be stored and run in the corresponding hardware device or software module (e.g., NFC module 102, HCE application, SIM card, SE, etc.) of the NFC emulator card. Since one or more NFC emulator cards are activated on electronic device 100, there can be one or more applets on electronic device 100. One NFC emulator card corresponds to one applet. The applets corresponding to different NFC emulator cards may be different or the same.

[0275] For example, the correspondence between NFC analog cards and Applets can be shown in Table 4 below:

[0276] Table 4

[0277] As shown in Table 4 above, the Applet identifier (AID) for Jiangsu Transportation Smart Card is “A00000063201010530013000FFFFFFFF”. The Applet identifier (AID) for Shenzhen Tong Transportation Card is “535A542E57414C4C45542E454E56”, the Applet identifier (AID) for Lingnan Transportation Card is “5943542E55534552”, and the Applet identifier (AID) for Wuhan Tong Transportation Card is “A00000534257485448”. The Applet's identifier (AID) for Chongqing Transportation Card is "4351515041592E5359533331", the Applet's identifier (AID) for Shanghai Public Transportation Card is "A0000003330101020063485750415902", the Applet's identifier (AID) for UnionPay is "A0000003330053440121561126241000", and the Applet's identifier (AID) for Bank of China Card is "A00000000353504200080822". China Construction Bank... Let the Applet's identifier (AID) be "A00000000353504200080807", the Applet's identifier (AID) be "A0000003330101010003080000030801", the Applet's identifier (AID) be "A00000000353504200080836", and the Applet's identifier (AID) be "F0000000485750415906000002029703". The Applet's identifier (AID) for Vanke Property's access control card is "B00000007819392019283".

[0278] The examples shown in Table 4 above are only for explaining this application and should not be construed as limiting this application.

[0279] S1010. After determining the first applet, the electronic device 100 sends a response 1 to the NFC card reader 200, wherein the response 1 is used to indicate that the electronic device 100 has successfully selected the first applet.

[0280] S1011. After receiving response 1, the NFC card reader 200 sends a mapping list query command to the electronic device 100.

[0281] The mapping list query command is used to request the electronic device 100 to return the first mapping list to the NFC card reader 200.

[0282] S1012. After receiving the mapping list query command, the electronic device 100 can send a mapping list query response to the NFC card reader 200. The mapping list query response carries a first mapping list, which indicates the mapping relationship between device feature information and the identifier of a dedicated file (DF).

[0283] Electronic device 100 can store data from one or more NFC emulator cards via a file tree. The data from the NFC emulator card can include device characteristic information, keys, and permission information associated with the NFC emulator card. The file tree can include a master file (MF), a dedicated file (DF), and an elementary file (EF). The MF directory can contain one or more EFs and one or more DFs, and each DF directory can contain one or more EFs. One NFC emulator card corresponds to one DF, and different NFC emulator cards correspond to different DFs. Since one NFC emulator card can correspond to one or more card information entries, a DF can store one or more card information entries (EF) for storing card information (e.g., a DF can support storing up to 8 card information entries, each with a data length of 4 bytes) and one or more external authentication keys corresponding to card information entries (EF). The external authentication keys corresponding to different card information entries (EF) within the same DF may be the same or different.

[0284] For example, as shown in Figure 11, the NFC analog cards activated on electronic device 100 can include access cards for community A, community B, community C, Shenzhen Tong transportation cards, and home door lock keys. Therefore, the MF directory can store key EF1, Applet identity public key EF, Applet identity private key EF, mapping table EF, DF1, DF2, DF3, DF4, and DF5. Among them:

[0285] 1. Key EF1 may include a master key and a maintenance key. The master key in key EF1 can be used for encryption and decryption during data updates. The maintenance key in key EF1 can be used for encryption and decryption during data updates in the Applet identity public key EF, Applet identity private key EF, and mapping table EF.

[0286] 2. The Applet Identity Private Key (EF) can be used to store the identity private key used by one or more Applets.

[0287] 3. The Applet identity public key EF can be used to store the identity public key used by one or more Applets.

[0288] 4. The mapping list EF can be used to store the first mapping list mentioned above. The first mapping list indicates the mapping relationship between device feature information and the identifier of DF. For example, device feature information 1 corresponds to DF1, and DF1 can be used to store the access card data for community A. Device feature information 2 corresponds to DF2, and DF2 can be used to store the access card data for community B. Device feature information 3 corresponds to DF3, and DF3 can be used to store the access card data for community C. Device feature information 4 corresponds to DF4, and DF4 can be used to store the data for the Shenzhen Tong transportation card. Device feature information 5 corresponds to DF5, and DF5 can be used to store the data for the home door lock key card.

[0289] 5. DF1 stores key EF11, device feature information EF12, file permission list EF13, and X card information EFs. X is a positive integer. Key EF11 may include a master control key, a maintenance key, and X external authentication keys. The master control key in key EF11 can be used for encryption and decryption when the data in key EF11 is updated. The maintenance key in key EF11 can be used for encryption and decryption when the device feature information EF12, file permission list EF13, and X card information EFs in DF1 are updated. The X external authentication keys in DF1 correspond to the X card information EFs in DF1, with one external authentication key corresponding to one card information EF. Different card information EFs in DF1 may correspond to the same or different external authentication keys. For example, DF1 may include card information EF storing card information 1 and card information EF storing card information 2. Card information 1 can be used to open the access control system of building 1 in community A, and card information 2 can be used to open the access control system of building 2 in community A. Device feature information EF12 can be used to store the device feature information corresponding to DF1. File permission list EF13 can be used to indicate the read and write permissions for X card information EF in DF1.

[0290] 6. DF2 stores key EF21, device characteristic information EF22, file permission list EF23, and Y card information EFs. Y is a positive integer. Key EF21 may include a master control key, a maintenance key, and Y external authentication keys. The master control key in key EF21 can be used for encryption and decryption during data updates. The maintenance key in key EF21 can be used for encryption and decryption during data updates to device characteristic information EF22, file permission list EF23, and the Y card information EFs in DF2. The Y external authentication keys in DF2 correspond to the Y card information EFs in DF2, with one external authentication key corresponding to one card information EF. Different card information EFs in DF2 may have the same or different external authentication keys. For example, DF2 may include card information EF storing card information 3, which can be used to open all access control systems within cell B. Device characteristic information EF22 can be used to store device characteristic information corresponding to DF2. File permission list EF23 can be used to indicate read and write permissions for the Y card information EFs in DF2.

[0291] 7. DF3 stores key EF31, device feature information EF32, file permission list EF33, and Z card information EFs. Z is a positive integer. Key EF31 may include a master control key, a maintenance key, and Z external authentication keys. The master control key in key EF31 can be used for encryption and decryption during data updates. The maintenance key in key EF31 can be used for encryption and decryption during data updates to device feature information EF32, file permission list EF33, and the Z card information EFs in DF3. The Z external authentication keys in DF3 correspond to the Z card information EFs in DF3, with one external authentication key corresponding to one card information EF. Different card information EFs in DF3 may have the same or different external authentication keys. For example, DF3 may include card information EF storing card information 4, which can be used to open all access control systems within cell C. Device feature information EF32 can be used to store device feature information corresponding to DF3. File permission list EF33 can be used to indicate read and write permissions for the Z card information EFs in DF3.

[0292] 8. DF4 stores key EF41, device feature information EF42, file permission list EF43, and L card information EFs. L is a positive integer. Key EF41 may include a master key, a maintenance key, and L external authentication keys. The master key in key EF41 can be used for encryption and decryption when the data in key EF41 is updated. The maintenance key in key EF41 can be used for encryption and decryption when the device feature information EF42, file permission list EF43, and L card information EFs in DF4 are updated. The L external authentication keys in DF4 correspond to the L card information EFs in DF4, with one external authentication key corresponding to one card information EF. Different card information EFs in DF4 may have the same or different external authentication keys. For example, DF4 may include card information EF storing card information 5, which can be used for public transportation payments within Shenzhen. Device feature information EF42 can be used to store the device feature information corresponding to DF4. File permission list EF43 can be used to indicate the read and write permissions of the L card information EFs in DF4.

[0293] 9. DF5 stores key EF51, device characteristic information EF52, file permission list EF53, and M card information EFs. M is a positive integer. Key EF51 may include a master key, a maintenance key, and M external authentication keys. The master key in key EF51 can be used for encryption and decryption when the data in key EF51 is updated. The maintenance key in key EF51 can be used for encryption and decryption when the device characteristic information EF52, file permission list EF53, and M card information EFs in DF5 are updated. The M external authentication keys in DF5 correspond to the M card information EFs in DF5, with one external authentication key corresponding to one card information EF. Different card information EFs in DF5 may have the same or different external authentication keys. For example, DF5 may include card information EF storing card information 6, which can be used to unlock a door lock. Device characteristic information EF52 can be used to store the device characteristic information corresponding to DF5. File permission list EF53 can be used to indicate the read and write permissions of the M card information EFs in DF5.

[0294] The example shown in Figure 11 above is only for explaining this application and should not be construed as limiting this application.

[0295] After receiving the mapping list query command, the electronic device 100 can obtain the first mapping list from the mapping list EF under the MF directory shown in Figure 11, and then send a mapping list query response carrying the first mapping list to the NFC card reader 200.

[0296] In some embodiments, the card emulation mode of the electronic device 100 may include a hardware-based virtual card mode and a software-based HCE mode. In the hardware-based virtual card mode, the data of one or more NFC emulated cards can be stored in a device such as an SE or SIM card in the file tree format shown in Figure 11. In the software-based HCE mode, the data of one or more NFC emulated cards can be saved by the HCE application in the file tree format shown in Figure 11. Optionally, the HCE application can store the data of one or more NFC emulated cards in the read-only memory (ROM) of the electronic device 100 in the file tree format; alternatively, the HCE application can store the data of one or more NFC emulated cards in the file tree format on a cloud server.

[0297] S1013. After receiving the mapping list query response, the NFC card reader 200 can determine the identifier of the first DF from the first mapping list based on the device feature information of the NFC card reader 200.

[0298] In this way, by having the NFC card reader 200 determine the identifier of the first DF from the first mapping list based on the device feature information of the NFC card reader 200, the processing and computational load of the NFC card device (e.g., electronic device 100, NFC tag card) can be reduced. For example, when a physical NFC tag card is brought close to the NFC card reader 200, since the computing power of the NFC tag card is insufficient, the NFC card reader 200 can read the first mapping list in the NFC tag card to select the first DF, thereby reducing the processing and computational load of the NFC tag card.

[0299] S1014. The NFC card reader 200 sends a Select DF command to the electronic device 100, wherein the Select DF command carries the identifier of the first DF.

[0300] S1015. After receiving the Select DF command, the electronic device 100 obtains the first DF based on the identifier of the first DF through the first Applet.

[0301] The electronic device 100 can locate the first DF in the MF file directory from the file tree shown in Figure 11 above based on the identifier of the first DF.

[0302] S1016. After obtaining the first DF from the MF file through the first Applet, the electronic device 100 sends a response 2 to the NFC card reader 200, wherein the response 2 is used to indicate that the electronic device 100 has successfully obtained the first DF.

[0303] After receiving response 2, the S1017.NFC card reader 200 sends a random number acquisition (Get Challenge) command to the electronic device 100.

[0304] S1018. Electronic device 100 generates a first random number via a first applet.

[0305] S1019. Electronic device 100 sends response 3 to NFC card reader 200, wherein response 3 carries a first random number.

[0306] After receiving response 3, the S1020 NFC card reader 200 encrypts the first random number with the first external authentication key to obtain the authentication ciphertext.

[0307] S1021. The NFC card reader 200 sends an external authentication command to the electronic device 100, wherein the external authentication command carries authentication ciphertext.

[0308] S1022. After receiving an external authentication command, the electronic device 100 decrypts the first random number from the authentication ciphertext using the first external authentication key in the first DF through the first Applet.

[0309] Since the first DF can include one or more card information EFs, where each card information EF corresponds to an external authentication key, the first DF can also include one or more external authentication keys. The electronic device 100 can use the first applet to sequentially decrypt the authentication ciphertext using one or more external authentication keys in the first DF. When the first random number is successfully decrypted using one of the external authentication keys in the first DF, it indicates that the external authentication key is the first external authentication key, and the electronic device 100 has successfully authenticated the NFC card reader 200.

[0310] S1023. After electronic device 100 decrypts the first random number from the authentication ciphertext using the first external authentication key in the first DF via the first Applet, it sends a response (Response) 4, wherein the response 4 carries the first authentication result. The first authentication result is used to indicate that electronic device 100 has successfully decrypted the first random number from the authentication ciphertext.

[0311] S1024. After receiving the response 4 carrying the first authentication result, the NFC card reader 200 sends a card information acquisition command to the electronic device 100.

[0312] The card information acquisition command is used to retrieve the card information of the first NFC analog card stored in the first DF.

[0313] S1025. After receiving the card information acquisition command, the electronic device 100 uses the first external authentication key and the first random number to encrypt the card information of the first NFC analog card stored in the first DF through the first Applet to obtain encrypted data.

[0314] S1026. Electronic device 100 sends encrypted data to NFC card reader 200.

[0315] S1027. After receiving encrypted data, the NFC card reader 200 can use a first external authentication key and a first random number to decrypt the card information of the first NFC simulated card from the encrypted data, and perform the card swiping service of the first NFC simulated card based on the card information of the first NFC simulated card.

[0316] In one possible implementation, the first NFC simulated card may have one or more card information entries. If one or more external authentication keys stored in the first DF are identical and all refer to the aforementioned first external authentication key, then the electronic device 100 can use the first Applet to encrypt one or more card information entries of the first NFC simulated card stored in the first DF using the first external authentication key, obtaining encrypted data. After receiving the encrypted data, the NFC card reader 200 can use the first external authentication key to decrypt one or more card information entries of the first NFC simulated card from the first DF. The NFC card reader 200 can perform a card swiping transaction based on one or more card information entries of the first NFC simulated card. If the NFC card reader 200 successfully swipes a card based on any one of the one or more card information entries of the first NFC simulated card, it indicates that the first NFC simulated card swipe was successful. If the NFC card reader 200 fails to swipe a card based on any one or more of the one or more card information entries of the first NFC simulated card, it indicates that the first NFC simulated card swipe failed.

[0317] In one possible implementation, the first NFC emulated card may have multiple card information entries, and the multiple external authentication keys stored in the first DF are not all the same. After determining the first external authentication key from the multiple external authentication keys, the electronic device 100 can determine one or more card information entries EF corresponding to the first external authentication key, and obtain one or more target card information entries of the first NFC emulated card from the one or more card information entries EF corresponding to the first external authentication key. The electronic device 100 can encrypt the one or more target card information entries of the first NFC emulated card using the first external authentication key via a first applet to obtain encrypted data. After receiving the encrypted data, the NFC card reader 200 can decrypt the one or more target card information entries from the first DF using the first external authentication key. The NFC card reader 200 can perform a card swiping operation based on the one or more target card information entries of the first NFC emulated card. If the NFC card reader 200 successfully swipes a card based on any one of the one or more target card information entries of the first NFC emulated card, it indicates that the first NFC emulated card swiping was successful. If the NFC card reader 200 fails to swipe a card based on any one or more target card information entries of the first NFC emulated card, it indicates that the first NFC emulated card swiping failed.

[0318] The card-swiping service can include any one of the following: opening access control, unlocking doors, unlocking vehicles, making transactions, verifying electronic tickets, verifying digital documents, and swiping transportation cards to get on and off vehicles.

[0319] The card information of the first NFC simulation card may include one or more of the following: access control information, key information, transaction account information, and electronic ticket information. Access control information may include one or more of the following: card number, card validity period, etc. Key information may include one or more of the following: key code, key code validity period, etc. Transaction account information may include one or more of the following: transaction account identifier, remaining balance in the transaction account, etc. Electronic ticket information may include one or more of the following: electronic ticket code, electronic ticket verification time, electronic ticket validity period, etc.

[0320] S1028. NFC card reader 200 sends the card swipe result to electronic device 100.

[0321] The card swipe result includes either a first card swipe result or a second card swipe result. The first card swipe result indicates that the first NFC simulated card was swiped successfully, while the second card swipe result indicates that the first NFC simulated card was swiped unsuccessfully. If the NFC card reader 200 successfully performs the card swipe transaction based on the card information of the first NFC simulated card, the NFC card reader 200 can send the first card swipe result.

[0322] If the NFC card reader 200 fails to perform a card swiping transaction based on the card information of the first NFC simulated card, the NFC card reader 200 can send a second card swiping result.

[0323] After receiving the card swipe result, the electronic device 100 can output a prompt corresponding to the card swipe result. For details, please refer to the embodiments shown in Figure 8D or Figure 9D above, which will not be repeated here.

[0324] S1029. After receiving the card swipe result, the electronic device 100 can send a response 5 to the NFC card reader 200, wherein the response 5 is used to indicate that the electronic device 100 has successfully received the card swipe result.

[0325] In one possible implementation, step S1006 is optional, and the electronic device 100 may not output a swipe prompt for the first NFC simulated card. When the physical NFC tag card is brought close to the NFC card reader 200, since the NFC tag card does not have a display screen or audio output module, the NFC tag card can perform other steps performed by the electronic device 100 besides step S1006.

[0326] In one possible implementation, steps S1017 to S1023 are optional, and the NFC card reader 200 can directly execute step S1024 after receiving response 2. After receiving the card information acquisition command, the electronic device 100 can send the card information of the first NFC simulated card directly to the NFC card reader 200 without encrypting it. After receiving the card information of the first NFC simulated card, the NFC card reader 200 can perform a card swiping transaction based on that information.

[0327] In the embodiments of this application, the above-mentioned response 1 can be referred to as the first response, the above-mentioned response 2 can be referred to as the second response, the above-mentioned response 3 can be referred to as the third response, the above-mentioned response 4 can be referred to as the fourth response, and the above-mentioned response 5 can be referred to as the fifth response.

[0328] This application provides a near-field communication method. When an electronic device 100 enters the radio frequency field emitted by an NFC reader 200, it can receive a probe frame emitted by the NFC reader 200. Upon receiving the probe frame, the electronic device 100 can send a probe acknowledgement (Probe ACK) frame to the NFC reader 200, indicating that it has received the probe frame. After receiving the probe frame, the NFC reader 200 can send a notification frame to the electronic device 100, carrying device feature information of the NFC reader 200. Upon receiving the notification frame, the electronic device 100 can use the device feature information of the NFC reader 200 to identify a first NFC emulator from one or more NFC emulators and display the card-swiping interface of the first NFC emulator. The NFC reader 200 can obtain a first mapping list in the electronic device 100 and identify a first DF (Device Detector) storing the card information of the first NFC emulator from the first mapping list. Then, the NFC card reader 200 can obtain the card information of the first NFC simulated card stored in the first DF from the electronic device 100, and thus complete the card swiping transaction of the first NFC simulated card. In this way, the electronic device 100 can automatically and accurately select the appropriate NFC simulated card, quickly pop up the card swiping interface of the first NFC simulated card and complete the card swiping transaction, thereby improving the speed and efficiency of NFC card swiping.

[0329] The following describes a near-field communication method provided in another embodiment of this application, using NFC signaling interaction as an example.

[0330] Figure 12 illustrates, by way of example, a flowchart of an NFC analog card selection method provided in an embodiment of this application.

[0331] As shown in Figure 12, this NFC simulated card selection method can be applied to a communication system including an electronic device 100 and an NFC card reader 200. The NFC card reader 200 can operate in PCD mode. The electronic device 100, after enabling the NFC function, is in PICC mode by default. This NFC simulated card selection method may include the following steps:

[0332] S1201. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0333] S1202.NFC card reader 200 sends a probe frame.

[0334] S1203. After receiving the probe frame, the electronic device 100 sends a probe ACK frame to the NFC reader device 200.

[0335] The specific details of steps S1201 to S1203 can be found in steps S601 to S603 of the embodiment shown in Figure 6 above, and will not be repeated here.

[0336] S1204. After receiving the Probe ACK frame, the NFC card reader 200 sends a Notify frame to the electronic device 100. The Notify frame carries the device feature information of the NFC card reader 200 and the identifier of the first Applet.

[0337] S1205. Based on the device feature information of the NFC card reader 200, the electronic device 100 determines the first NFC emulated card from one or more NFC emulated cards on the electronic device 100.

[0338] For details, please refer to step S605 in the embodiment shown in Figure 6 above, which will not be repeated here.

[0339] S1206. After identifying the first NFC emulated card, the electronic device 100 outputs a card swiping prompt for the first NFC emulated card.

[0340] For details, please refer to step S606 in the embodiment shown in Figure 6 above, which will not be repeated here.

[0341] S1207. Electronic device 100 determines the identifier of the first DF based on the device feature information of NFC card reader 200 and the first mapping list, wherein the first mapping list is used to indicate the mapping relationship between device feature information and the identifier of DF.

[0342] For a detailed textual description of the first mapping list, please refer to the embodiment shown in Figure 11 above, which will not be repeated here.

[0343] S1208. After identifying the first NFC emulated card, the electronic device 100 sends a Notify ACK frame to the NFC card reader 200. This Notify ACK frame carries a first notification result. The first notification result can be used to indicate that the electronic device 100 has successfully selected the first NFC emulated card.

[0344] After receiving response 2, the S1209 NFC card reader 200 sends a random number acquisition (Get Challenge) command to the electronic device 100.

[0345] S1210. Electronic device 100 generates a first random number via a first applet.

[0346] S1211. Electronic device 100 sends response 3 to NFC card reader 200, wherein response 3 carries a first random number.

[0347] After receiving response 3, the S1212.NFC card reader 200 encrypts the first random number with the first external authentication key to obtain the authentication ciphertext.

[0348] S1213. The NFC card reader 200 sends an external authentication command to the electronic device 100, wherein the external authentication command carries authentication ciphertext.

[0349] S1214. After receiving an external authentication command, the electronic device 100 obtains the first DF based on the identifier of the first DF through the first Applet, and decrypts the first random number from the authentication ciphertext using the first external authentication key in the first DF.

[0350] S1215. After electronic device 100 decrypts the first random number from the authentication ciphertext using the first external authentication key in the first DF via the first Applet, it sends a response (Response) 4, wherein response 4 carries the first authentication result. The first authentication result is used to indicate that electronic device 100 has successfully decrypted the first random number from the authentication ciphertext.

[0351] S1216. After receiving the response 4 carrying the first authentication result, the NFC card reader 200 sends a card information acquisition command to the electronic device 100.

[0352] The card information acquisition command is used to retrieve the card information of the first NFC analog card stored in the first DF.

[0353] S1217. After receiving the card information acquisition command, the electronic device 100 uses the first external authentication key and the first random number to encrypt the card information of the first NFC analog card stored in the first DF through the first Applet to obtain encrypted data.

[0354] S1218. Electronic device 100 sends encrypted data to NFC card reader 200.

[0355] S1219. After receiving encrypted data, the NFC card reader 200 can use a first external authentication key and a first random number to decrypt the card information of the first NFC simulated card from the encrypted data, and perform the card swiping service of the first NFC simulated card based on the card information of the first NFC simulated card.

[0356] S1220. NFC card reader 200 sends the card swipe result to electronic device 100.

[0357] S1221. After receiving the card swipe result, the electronic device 100 can send a response 5 to the NFC card reader 200, wherein the response 5 is used to indicate that the electronic device 100 has successfully received the card swipe result.

[0358] The specific details of steps S1209 to S1221 can be found in steps S1017 to S1029 of the embodiment shown in Figure 10 above, and will not be repeated here.

[0359] In one possible implementation, step S1206 is optional, and the electronic device 100 may not output a swipe prompt for the first NFC simulated card. When the physical NFC tag card is brought close to the NFC card reader 200, since the NFC tag card does not have a display screen or audio output module, the NFC tag card can perform other steps performed by the electronic device 100 besides step S1206.

[0360] In one possible implementation, steps S1209 to S1215 are optional. The NFC card reader 200 can directly execute step S1216 after receiving the Notify ACK frame. After obtaining the card information acquisition command, the electronic device 100 can send the card information of the first NFC simulated card directly to the NFC card reader 200 without encrypting it. After receiving the card information of the first NFC simulated card, the NFC card reader 200 can perform a card swiping operation based on the card information of the first NFC simulated card.

[0361] In the embodiments of this application, response 3 can be referred to as the third response, response 4 can be referred to as the fourth response, and response 5 can be referred to as the fifth response.

[0362] This application provides a near-field communication method. When an electronic device 100 enters the radio frequency field emitted by an NFC reader 200, it can receive a probe frame emitted by the NFC reader 200. Upon receiving the probe frame, the electronic device 100 can send a probe acknowledgement (Probe ACK) frame to the NFC reader 200, indicating that it has received the probe frame. After receiving the probe frame, the NFC reader 200 can send a notification frame to the electronic device 100, carrying device feature information of the NFC reader 200 and an identifier of a first applet. Upon receiving the notification frame, the electronic device 100 can use the device feature information of the NFC reader 200 to identify the first NFC simulated card from one or more NFC simulated cards and display the card-swiping interface of the first NFC simulated card. The electronic device 100 can use the first applet to determine the first DF (Device Detector) storing the card information of the first NFC simulated card from a first mapping list based on the device feature information of the NFC reader 200. Then, the electronic device 100 can send the card information of the first NFC simulated card stored in the first DF to the NFC card reader 200, thereby enabling the NFC card reader 200 to complete the card swiping transaction of the first NFC simulated card. In this way, the electronic device 100 can automatically and accurately select the appropriate NFC simulated card, quickly pop up the card swiping interface of the first NFC simulated card, and complete the card swiping transaction, thus improving the speed and efficiency of NFC card swiping.

[0363] In the embodiments of this application, the NFC protocol in the embodiments shown in Figures 6, 10 and 12 above can be referred to as the first NFC protocol.

[0364] The second NFC protocol provided in the embodiments of this application is described below.

[0365] Figure 13 is a schematic diagram of the card swiping process of the second NFC protocol provided in the embodiments of this application.

[0366] As shown in Figure 13, the card-swiping process of this second NFC protocol can be applied to an NFC system including electronic device 100 and NFC card reader 200. Electronic device 100 can be in PICC mode; for example, electronic device 100 is in PICC mode by default after enabling NFC. NFC card reader 200 can be in PCD mode. The card-swiping process of the second NFC protocol can include signaling interaction at the access layer and data transmission at the application layer. The signaling interaction at the access layer in the second NFC protocol can refer to the standard protocol "ISO / IEC 14443-3". The data transmission at the application layer in the second NFC protocol can refer to the standard protocol "ISO / IEC 14443-4".

[0367] The card-swiping process of the second NFC protocol may include the following steps S1301 to S1313. Specifically, the access layer protocol process in the second NFC protocol may include steps S1302 to S1307. The data transmission process of the application layer in the second NFC protocol may include steps S1308 to S1313.

[0368] S1301. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0369] S1302. The NFC card reader 200 can send a request command for the second NFC protocol to the electronic device 100.

[0370] In some embodiments of this application, the NFC card reader 200 in PCD mode can broadcast a request command through the radio frequency field. When the electronic device 100 in PICC mode enters the radio frequency field of the NFC card reader 200, the electronic device 100 can receive the request command broadcast by the NFC card reader 200.

[0371] In some embodiments of this application, the request command may be a type A request command (REQA) or a type B request command (REQB) in the ISO14443-3 protocol / IEC14443-3 protocol.

[0372] S1303. Electronic device 100 can send a request-response command of the second NFC protocol to NFC card reader 200.

[0373] In some embodiments of this application, the request-response command can be a Type A request-response command (ATQA) or a Type B request-response command (ATQB) in the ISO / IEC 14443-3 protocol. In the ISO / IEC 14443-3 protocol, an NFC device in PICC mode that receives a REQA / REQB response can return ATQA / ATQB if it supports the ISO / IEC 14443-3 protocol. In some embodiments of this application, the electronic device 100 includes an NFC analog card that supports NFC protocols (e.g., the ISO / IEC 14443 protocol). Therefore, after receiving a request command broadcast by the NFC card reader 200, the electronic device 100 can send a request-response command to the NFC card reader 200.

[0374] In some embodiments of this application, electronic device 100 can generate a request-response command based on the request-response command parameters in the NFC parameters of an active NFC emulator card, and send the request-response command to NFC reader device 200. In some examples, the request-response command sent by electronic device 100 can indicate whether the active NFC emulator card in electronic device 100 supports anti-collision mechanisms in the access layer protocol process, such as the bit-oriented anti-collision mechanism in the ISO / IEC 14443-3 protocol. In some examples, the request-response command sent by electronic device 100 can include the length of the unique identifier (UID) of the active NFC emulator card in electronic device 100.

[0375] In some embodiments of this application, the NFC card reader 200 can determine whether the electronic device 100 supports the anti-collision mechanism in the access layer protocol process based on the request-response command sent by the electronic device 100. If the determination result is yes, the request-response command sent by the electronic device 100 passes the verification; otherwise, the request-response command fails the verification.

[0376] In some embodiments of this application, the NFC card reader 200 can not only determine whether the electronic device 100 supports the anti-collision mechanism in the access layer protocol, but also determine whether the length of the UID carried in the request-response command (i.e., the UID of the NFC analog card in the active state of the electronic device 100) conforms to the preset length range of the NFC card reader 200. For example, the preset length range is the range of the UID length of the target PICC required by the NFC card reader 200. When the electronic device 100 supports the anti-collision mechanism in the access layer protocol, and the length of the UID carried in the request-response command conforms to the preset length range of the NFC card reader 200, the NFC card reader 200 verifies the request-response command sent by the electronic device 100; otherwise, the verification fails.

[0377] In some embodiments of this application, when the NFC card reader 200 verifies the request-response command sent by the electronic device 100, the NFC card reader 200 can continue to perform subsequent processes of the access layer protocol, such as executing S1304.

[0378] S1304. NFC card reader 200 can send anti-collision commands to electronic device 100.

[0379] In some embodiments of this application, the anti-collision command can instruct an NFC device in PICC mode to return the entire UID. In some embodiments of this application, the SEL field in the anti-collision command has a value of 93, and the NVB field has a value of 20. In some embodiments of this application, the anti-collision command can also be called a select command. The anti-collision command and the select command described in S1306 can be different select commands, for example, they may include different fields and have different values.

[0380] S1305. Electronic device 100 can send the UID of an active NFC analog card to NFC card reader 200.

[0381] In some embodiments of this application, electronic device 100 may send the UID parameter from the NFC parameters of an active NFC analog card to NFC reader device 200.

[0382] S1306. The NFC card reader 200 can send a select command to the electronic device 100.

[0383] In some embodiments of this application, the NFC card reader 200 can determine the selected electronic device 100 and therefore can send a selection command to the electronic device 100. In some examples, after the NFC card reader 200 sends an anti-collision command, it receives a UID sent by an electronic device 100, and there is no conflict between multiple NFC devices in PICC mode (i.e., no card conflict). Therefore, the NFC card reader 200 can determine the selected electronic device 100.

[0384] In some embodiments of this application, the selection command may include the SEL field, the NVB field, the complete UID and CRC code of the selected electronic device 100, the SEL field may be 20, and the NVB field may be 70.

[0385] S1307. Electronic device 100 can send a select acknowledge (SAK) command to NFC card reader 200. The select acknowledge command is used to indicate support for the application layer protocol process.

[0386] Since the NFC analog card in the active state of the electronic device 100 supports the second NFC protocol, that is, the application layer protocol process, the selection confirmation command sent by the electronic device 100 to the NFC card reader 200 indicates support for the application layer protocol process. Therefore, when the received selection confirmation command indicates support for the application layer protocol process, the NFC card reader 200 can verify the selection confirmation command.

[0387] In some embodiments of this application, when the NFC card reader 200 verifies the selection confirmation command sent by the electronic device 100, the NFC card reader 200 can initiate an application layer protocol process, such as executing S1308.

[0388] The S1308 NFC card reader 200 can send a request for answer to select (RATS) command to the electronic device 100.

[0389] S1309. Electronic device 100 can send an answer to select (ATS) command to NFC card reader 200.

[0390] In some embodiments of this application, the electronic device 100 includes an NFC analog card that supports application layer protocols. Therefore, after receiving the RATS command sent by the NFC card reader 200, the electronic device 100 can send an ATS command to the NFC card reader 200.

[0391] In some embodiments of this application, the ATS command can be used to negotiate communication parameters used in the communication process of the application layer protocol between the electronic device 100 and the NFC card reader 200. The ATS command may include communication parameters in the electronic device 100 for implementing the communication process of the application layer protocol, such as length byte (indicating frame length), interface byte 1 (indicating rate), interface byte 2 (indicating frame wait time (FWT) and start frame guard time (SFGT)), interface byte 3 (indicating whether logical channel identity (CID) is supported), and history byte, etc.

[0392] In some embodiments of this application, the NFC card reader 200 can obtain communication parameters from the electronic device 100 for implementing the communication process of the application layer protocol according to the Select Response (ATS) command. Furthermore, the NFC card reader 200 can determine whether the communication parameters meet its preset requirements. For example, it can determine whether the communication parameters are the same as the communication parameters required by the NFC card reader 200 for implementing the application layer protocol. If the determination result is yes, the verification passes; otherwise, the verification fails. When the NFC card reader 200 passes the ATS command verification, the NFC card reader 200 and the electronic device 100 can transmit application protocol data units (APDUs) in the application layer protocol, for example, by executing S1310.

[0393] S1310. The NFC reader device 200 can send a Select AID command to the electronic device 100, wherein the Select AID command can carry the identifier of the first Applet.

[0394] S1311. Electronic device 100 determines the target NFC analog card corresponding to the first Applet based on the identifier of the first Applet.

[0395] S1312. Electronic device 100 sends card information of target NFC analog card to NFC card reader 200 via first applet.

[0396] In some embodiments of this application, the electronic device 100 can obtain the identifier of the first Applet carried in the selectAID command and determine whether there is an NFC simulation card corresponding to the first Applet among one or more NFC simulation cards included in the electronic device 100. When the electronic device 100 has an NFC simulation card corresponding to the first Applet activated, the electronic device 100 can send the card information of the target NFC simulation card corresponding to the first Applet to the NFC card reader 200.

[0397] In some examples, the card information of an NFC emulator card may include one or more of the following: access control information, key information, transaction account information, and e-ticket information. Access control information may include one or more of the following: card number, card expiration date, etc. Key information may include one or more of the following: key code, key code expiration date, etc. Transaction account information may include one or more of the following: transaction account identifier, remaining balance in the transaction account, etc. E-ticket information may include one or more of the following: e-ticket code, e-ticket verification time, e-ticket expiration date, etc.

[0398] S1313.NFC card reader 200 performs card swiping operations on the target NFC emulator card based on the card information of the target NFC emulator card.

[0399] The card-swiping service can include any one of the following: opening access control, unlocking doors, unlocking vehicles, making transactions, verifying electronic tickets, verifying digital documents, and swiping transportation cards to get on and off vehicles.

[0400] Specifically, electronic device 100 can send the card information of the target NFC simulated card to NFC card reader 200 via NFC data interaction. NFC card reader 200 can then perform a card swiping transaction on the target NFC simulated card based on the card information. NFC card reader 200 can also send the card swiping result of the target NFC simulated card to electronic device 100 via NFC command interaction.

[0401] The target NFC simulated card's card information may include one or more of the following: access control information, key information, transaction account information, and electronic ticket information. Access control information may include one or more of the following: card number, card validity period, etc. Key information may include one or more of the following: key code, key code validity period, etc. Transaction account information may include one or more of the following: transaction account identifier, remaining balance in the transaction account, etc. Electronic ticket information may include one or more of the following: electronic ticket code, electronic ticket verification time, electronic ticket validity period, etc.

[0402] The following describes the process of selecting an NFC analog card in a scenario where the NFC card reader 200 simultaneously supports the first NFC protocol and the second NFC protocol, and the electronic device 100 also simultaneously supports the first NFC protocol and the second NFC protocol, according to an embodiment of this application.

[0403] Figure 14 shows a flowchart of the near-field communication method when the first NFC protocol and the second NFC protocol coexist, as provided in an embodiment of this application.

[0404] As shown in Figure 14, electronic device 100 can be in PICC mode. For example, electronic device 100 is in PICC mode by default after NFC is enabled, and NFC card reader 200 can be in PCD mode. Electronic device 100 supports card swiping processes using both the first NFC protocol and the second NFC protocol, which may include the following steps:

[0405] S1401. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0406] S1402. The NFC card reader 200 sends a first NFC protocol probe frame to the electronic device 100.

[0407] S1403. The NFC card reader 200 sends a request command for the second NFC protocol to the electronic device 100.

[0408] Since the NFC reader 200 supports both the first NFC protocol and the second NFC protocol, it can periodically poll and send probe frames for the first NFC protocol and request commands for the second NFC protocol. Specifically, it sends one probe frame for the first NFC protocol or one request command for the second NFC protocol in each polling cycle.

[0409] S1404. Electronic device 100 sends a first NFC protocol probe ACK frame to NFC reader device 200.

[0410] If electronic device 100 receives a probe frame of the first NFC protocol and a request command of the second NFC protocol in two consecutive polling cycles after entering the radio frequency field of NFC reader 200, it can be determined that NFC reader 200 supports both the first and second NFC protocols. Therefore, electronic device 100 can send a notification frame of the first NFC protocol to NFC reader 200.

[0411] If electronic device 100 receives probe frames for the first NFC protocol in two consecutive polling cycles after entering the radio frequency field of NFC reader 200, it can be determined that NFC reader 200 only supports the first NFC protocol. Therefore, electronic device 100 can send a notification frame for the first NFC protocol to NFC reader 200.

[0412] If electronic device 100 receives probe frames of the second NFC protocol in two consecutive polling cycles after entering the radio frequency field of NFC reader 200, it can be determined that NFC reader 200 only supports the second NFC protocol. Therefore, electronic device 100 can send a request-response command of the second NFC protocol to NFC reader 200. After receiving the request-response command of the second NFC protocol, NFC reader 200 can execute steps S1304 to S1313 in the embodiment shown in FIG13 with electronic device 100, which will not be described again here.

[0413] S1405. The NFC card reader 200 sends a first NFC protocol notification frame to the electronic device 100, wherein the notification frame carries the device feature information of the NFC card reader 200.

[0414] The format of the Notify frame can be referred to in the embodiment shown in Figure 6 above, and will not be repeated here.

[0415] S1406. The NFC card reader 200 determines whether there is a first NFC analog card among one or more NFC analog cards on the electronic device 100 that support the first NFC protocol, and whether the first NFC analog card matches the device feature information of the NFC card reader 200.

[0416] S1407. If one or more NFC analog cards on the electronic device 100 that support the first NFC protocol contain a first NFC analog card that matches the device feature information of the NFC card reader 200, the electronic device 100 may send a first notification confirmation frame to the NFC card reader 200, wherein the first notification confirmation frame carries a first notification result, and the first notification result is used to indicate that the electronic device 100 has successfully selected the first NFC analog card that matches the device feature information of the NFC card reader 200.

[0417] After receiving the first notification confirmation frame, the S1408.NFC card reader 200 can interact with the electronic device 100 via NFC to perform a card swiping transaction of the first NFC simulated card.

[0418] In this process, the NFC card reader 200 and the electronic device 100 interact with each other via NFC to execute the card swiping business of the first NFC simulated card. This can be referred to as step S608 in Figure 6 above, or steps S1008 to S1029 in the embodiment shown in Figure 10, or steps S1209 to S1221 in the embodiment shown in Figure 12. These steps will not be repeated here.

[0419] S1409. If none of the one or more NFC analog cards supporting the first NFC protocol on the electronic device 100 are first NFC analog cards that match the device feature information of the NFC card reader 200, the electronic device 100 can determine whether there are one or more NFC analog cards supporting the second NFC protocol on the electronic device 100.

[0420] S1410. If the electronic device 100 does not have one or more NFC analog cards that support the second NFC protocol, the electronic device 100 may send a second notification confirmation frame to the NFC card reader 200, wherein the second notification confirmation frame carries a second notification result, which is used to indicate that the electronic device 100 failed to select an NFC analog card.

[0421] Upon receiving a second notification confirmation frame, the NFC reader 200 can terminate the NFC interaction process with the electronic device 100. After terminating the NFC interaction process with the electronic device 100, the NFC reader 200 can periodically poll and send a probe frame of the first NFC protocol and a request command of the second NFC protocol.

[0422] S1411. If the electronic device 100 has one or more NFC analog cards that support the second NFC protocol, the electronic device 100 may send a third notification confirmation frame to the NFC card reader 200, wherein the third notification confirmation frame carries a third notification result, which is used to indicate that the electronic device 100 failed to select an NFC analog card that supports the first NFC protocol, but the electronic device 100 has an NFC analog card that supports the second NFC protocol.

[0423] S1412. After receiving the third notification frame, the NFC card reader 200 can send a Select AID command to the electronic device 100, wherein the Select AID command can carry the identifier of the first Applet.

[0424] In one possible implementation, if one or more NFC analog cards supporting the first NFC protocol on electronic device 100 do not have a first NFC analog card matching the device feature information of NFC reader 200, but electronic device 100 has one or more NFC analog cards supporting the second NFC protocol, electronic device 100 can send the aforementioned first notification confirmation frame to NFC reader 200. After receiving the first notification frame, NFC reader 200 can send a Select AID command to electronic device 100, wherein the Select AID command can carry the identifier of the first Applet.

[0425] S1413. The electronic device 100 determines the second NFC emulator corresponding to the first Applet from one or more NFC emulators that support the second NFC protocol, based on the identifier of the first Applet.

[0426] In one possible implementation, if the electronic device 100 does not have a first applet, that is, if one or more NFC emulators supporting the second NFC protocol do not have a second NFC emulator corresponding to the first applet, then the electronic device 100 can send an applet selection failure response to the NFC reader 200. This applet selection failure response indicates that the electronic device 100 does not have a first applet. Upon receiving the applet selection failure response, the NFC reader 200 can terminate the NFC interaction process with the electronic device 100. After terminating the NFC interaction process with the electronic device 100, the electronic device 100 can periodically poll and send probe frames of the first NFC protocol and request commands of the second NFC protocol.

[0427] S1414. Electronic device 100 sends card information of the second NFC analog card to NFC card reader 200 via the first applet.

[0428] S1415. NFC card reader 200 performs card swiping operations on the second NFC simulated card based on the card information of the second NFC simulated card.

[0429] The card-swiping service can include any one of the following: opening access control, unlocking doors, unlocking vehicles, making transactions, verifying electronic tickets, verifying digital documents, and swiping transportation cards to get on and off vehicles.

[0430] Specifically, electronic device 100 can send the card information of the second NFC simulated card to NFC card reader 200 via NFC data interaction. NFC card reader 200 can then perform a card swiping transaction on the target NFC simulated card based on the card information of the second NFC simulated card. NFC card reader 200 can also send the card swiping result of the second NFC simulated card to electronic device 100 via NFC command interaction.

[0431] The card information of the second NFC simulation card may include one or more of the following: access control information, key information, transaction account information, and electronic ticket information. Access control information may include one or more of the following: card number, card validity period, etc. Key information may include one or more of the following: key code, key code validity period, etc. Transaction account information may include one or more of the following: transaction account identifier, remaining balance in the transaction account, etc. Electronic ticket information may include one or more of the following: electronic ticket code, electronic ticket verification time, electronic ticket validity period, etc.

[0432] The NFC emulator card selection method provided in this application embodiment enables electronic device 100 to send the card information of the second NFC emulator card supporting the second NFC protocol to the NFC reader 200 even when there is no first NFC emulator card among one or more NFC emulator cards supporting the first NFC protocol on the electronic device 100, but the electronic device 100 has one or more NFC emulator cards supporting the second NFC protocol. This allows the electronic device 100 to attempt to perform the card swiping service of the second NFC emulator card, thus avoiding the need to re-execute the access layer protocol process in the second NFC protocol and saving the time of the electronic device 100 swiping the card on the NFC reader 200.

[0433] The following describes the flow of a near-field communication method provided in another embodiment of this application.

[0434] Because existing NFC protocols differ in their access layer signaling interaction processes, and these access layer signaling interactions are forcibly bound to the application layer NFC services, different types of NFC services require different NFC protocols. Some mobile phones and other electronic devices can support multiple NFC services, thus requiring support for multiple NFC protocols. This places high demands on the resource and cost of these electronic devices.

[0435] Therefore, this application provides a near-field communication method that enables electronic device 100 to receive a probe frame emitted by NFC reader 200 when entering the radio frequency field emitted by NFC reader 200. After receiving the probe frame, electronic device 100 can send a probe ACK frame to NFC reader 200, which indicates that electronic device 100 has received the probe frame. After receiving the probe frame, NFC reader 200 can send a notification frame to electronic device 100, wherein the notification frame carries device feature information of NFC reader 200. After receiving the notification frame, electronic device 100 can return a Notify ACK frame to NFC reader 200. After receiving the Notify ACK frame, NFC reader 200 can perform application-layer data transmission with electronic device 100. In this way, through the signaling interaction process at the access layer in the NFC communication method, the device characteristic information of the NFC reader 200 is sent to the electronic device 100 using a Notify frame. This allows the electronic device 100 to determine the target NFC service based on the device characteristic information of the NFC reader 200 before data transmission at the application layer. This allows the electronic device 100 to prepare the data required for the target NFC service or output a prompt for the target NFC service before data transmission at the application layer. Thus, the electronic device 100 and the NFC reader 200 can complete different types of NFC services at the application layer after the same signaling interaction process at the access layer, saving resources and costs for the electronic device.

[0436] Figure 15 shows a flowchart of a near-field communication method provided in an embodiment of this application.

[0437] As shown in Figure 15, this near-field communication method can be applied to an NFC system including an electronic device 100 and an NFC card reader 200. The electronic device 100 can be in PICC mode; for example, the electronic device 100 is in PICC mode by default after enabling NFC. The NFC card reader 200 can be in PCD mode.

[0438] The NFC communication method may include the following steps S1501 to S1508. The NFC communication method may include an access layer signaling interaction process and an application layer data transmission process. The access layer signaling interaction may include the following steps S1502 to S1508. In the access layer signaling interaction process of the first NFC protocol, steps S1506 and S1507 are optional.

[0439] S1501. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0440] The S1502 NFC reader device 200 can send probe frames.

[0441] The Probe frame can be used to indicate that the NFC reader 200 supports a specified NFC protocol (which may be referred to as the first NFC protocol). The NFC reader 200 can send Probe frames periodically.

[0442] For a description of the structure of the Probe frame, please refer to the text section of the embodiment shown in Figure 7A above, which will not be repeated here.

[0443] S1503. After receiving the probe frame, the electronic device 100 sends a probe ACK frame to the NFC card reader 200.

[0444] The Probe ACK frame can be used to indicate that the electronic device 100 supports the specified NFC protocol indicated by the Probe frame (which may be referred to as the first NFC protocol).

[0445] If electronic device 100 does not support the specified NFC protocol indicated by the Probe frame, electronic device 100 may not send a Probe ACK frame.

[0446] S1504. After receiving the Probe ACK frame, the NFC card reader 200 sends a Notify frame to the electronic device 100.

[0447] The Notify frame carries device characteristic information of the NFC reader 200. The device characteristic information may include one or more of the following: Service Identifier (SID), Device Organization Identifier (ND_OUI), and Device Group Identifier (also known as NFC Device Group Identifier (ND_GID)).

[0448] 1. The Service Identifier (SID) can be used to indicate the type of NFC service supported by the NFC reader device 200 on the basis of NFC functionality.

[0449] 2. The Device Organization Identifier (ND_OUI) can be used to indicate the manufacturer providing NFC services using the NFC card reader device 200. The NFC protocol standards organization's registration management agency can assign different Device Organization Identifiers to different manufacturers. For example, manufacturers providing NFC services may include one or more smart lock manufacturers, one or more property management companies, one or more automotive parts manufacturers, one or more transportation card management departments, etc.

[0450] 3. The Device Group Identifier (ND_GID) can be used to indicate the group to which the NFC services provided by the NFC reader 200 belong. The Device Group Identifier can be assigned based on the purpose and location of the NFC reader 200. Different NFC services can be assigned to different groups.

[0451] For a detailed description of the Service Identifier (SID), Device Organization Identifier (ND_OUI), and Device Group Identifier (also known as NFC Device Group Identifier (ND_GID)), please refer to the embodiment shown in Figure 6 above, which will not be repeated here.

[0452] A Notify frame may include a frame control header, a device identification element, and a checksum field. The frame control header of the Notify frame can be 4 bytes long and may include a protocol identifier field, a frame type field, a control information field, and a frame length field. Optionally, the device identification element may also include an element code, an identifier mask, a device type identifier, and a device individual identifier. For a detailed description of the Notify frame format, please refer to the embodiment shown in Figure 7B above; it will not be repeated here.

[0453] In one possible implementation, after the electronic device 100 obtains the device feature information of the NFC card reader 200 from the Notify ACK frame, it can execute the action corresponding to the device feature information of the NFC card reader 200. The action corresponding to the device feature information of the NFC card reader 200 may include outputting an NFC service prompt. For example, the NFC service prompt may be any one or more of the following: a swipe prompt for an NFC analog card (e.g., access card, key card, transportation card, bank card), a wireless charging prompt, a codeless payment prompt, an electronic ticket prompt, a tap-to-pay function prompt, or a multi-function card prompt.

[0454] S1505. After receiving the Notify frame, the electronic device 100 sends a Notify ACK frame to the NFC reader device 200.

[0455] The Notify ACK frame is used to indicate that the electronic device 100 has received the Notify frame sent by the NFC reader device 200.

[0456] For example, as shown in Figure 16, the Notify ACK frame may include a frame control header and a checksum field. The frame control header and checksum field may each have a data length of 2 bytes. The frame control header may include a protocol identifier field, a frame type field, and a protocol version field. The protocol identifier field and frame type field may each have a data length of 1 byte. In this embodiment, Cyclic Redundancy Check (CRC) can be used to verify the NFC transmission frame. Therefore, the checksum field of the Notify frame may carry a CRC code. The protocol identifier field in the Notify ACK frame can be used to indicate the first NFC protocol used by the NFC reader device 200 when sending the Notify ACK frame. The value of the protocol identifier field can be the identifier of the first NFC protocol, for example, "0x7C". The frame type field in the Notify ACK frame can be used to indicate the frame type of the Notify ACK frame. For example, the value of the frame type field of the Notify ACK frame can be "0x08".

[0457] After receiving a Notify ACK frame, the S1506.NFC card reader 200 can send a parameter negotiation command to the electronic device 100.

[0458] S1507. After receiving the parameter negotiation command, the electronic device 100 can send a parameter negotiation response to the NFC card reader 200.

[0459] The parameter negotiation command can be a command frame, and the parameter negotiation response can be a response frame. These parameter negotiation commands and responses can be used by the NFC reader 200 and the electronic device 100 to negotiate data transmission parameters at the application layer. These data transmission parameters may include one or more of the following: maximum transmission rate and maximum data transmission length during application layer data transmission.

[0460] S1508. NFC card reader 200 and electronic device 100 perform application layer data transmission.

[0461] The NFC card reader 200 and the electronic device 100 can perform application layer data transmission according to the data transmission parameters negotiated through parameter negotiation commands and parameter negotiation responses.

[0462] In one possible implementation, steps S1506 and S1507 are optional. If the NFC card reader 200 does not need to send a parameter negotiation command to the electronic device 100 after receiving the Notify ACK frame, the NFC card reader 200 and the electronic device 100 can perform application layer data transmission using the default data transmission parameters.

[0463] This application provides an NFC communication method. During the signaling interaction process at the access layer of the NFC communication method, a Notify frame is used to send the device characteristic information of the NFC reader 200 to the electronic device 100. This allows the electronic device 100 to determine the target NFC service based on the device characteristic information of the NFC reader 200 before data transmission at the application layer. This allows the electronic device 100 to prepare the data required for the target NFC service or output a prompt for the target NFC service before data transmission at the application layer. Thus, the electronic device 100 and the NFC reader 200 can complete different types of NFC services at the application layer after the same signaling interaction process at the access layer, saving resources and costs for the electronic device.

[0464] In one example of an embodiment of this application, the Probe frame may be referred to as the first NFC frame, the Probe ACK frame may be referred to as the second NFC frame, the Notify frame may be referred to as the third NFC frame, and the Notify ACK frame may be referred to as the fourth NFC frame.

[0465] The following describes the card-swiping process of the NFC analog card in the near-field communication method provided in this application embodiment, taking the scenario where one or more NFC analog cards are activated on the electronic device 100 as an example.

[0466] Figure 17 shows a schematic diagram of the swiping process of an NFC analog card in a near-field communication method provided in an embodiment of this application.

[0467] As shown in Figure 17, the NFC simulated card swiping process in this near-field communication method can be applied to an NFC system including electronic device 100 and NFC card reader 200. Electronic device 100 can be in PICC mode; for example, electronic device 100 is in PICC mode by default after NFC is enabled. NFC card reader 200 can be in PCD mode. The NFC simulated card swiping process can include signaling interaction at the access layer and data transmission at the application layer.

[0468] The swipe process of this NFC simulated card may include the following steps S1701 to S1710. The signaling interaction process at the access layer during the swipe process may include the following steps S1702 to S1707. During the signaling interaction process at the access layer, steps S1706 and S1707 are optional. The data transmission process at the application layer during the swipe process may include the following steps S1708 to S1710.

[0469] S1701. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0470] The S1702 NFC reader device 200 can send probe frames.

[0471] S1703. After receiving a probe frame, electronic device 100 sends a probe ACK frame to NFC card reader 200.

[0472] S1704. After receiving the Probe ACK frame, the NFC card reader 200 sends a notification frame to the electronic device 100.

[0473] The Notify frame carries device feature information of the NFC card reader 200.

[0474] S1705. After receiving the Notify frame, the electronic device 100 sends a Notify ACK frame to the NFC card reader 200.

[0475] S1706. After receiving a Notify ACK frame, the NFC card reader 200 can send a parameter negotiation command to the electronic device 100.

[0476] S1707. After receiving the parameter negotiation command, the electronic device 100 can send a parameter negotiation response to the NFC card reader 200.

[0477] The process for steps S1701 to S1707 can be referred to steps S1501 to S1507 in the embodiment shown in Figure 15 above, and will not be repeated here.

[0478] S1708. After receiving the parameter negotiation response, the NFC card reader 200 sends a Select AID command to the electronic device 100. The Select AID command carries the identifier of the first Applet.

[0479] S1709. Electronic device 100 determines the first NFC analog card corresponding to the first Applet based on the identifier of the first Applet.

[0480] S1710. After determining the first NFC analog card corresponding to the first Applet, the electronic device 100 sends the card information of the first NFC analog card to the NFC card reader 200 through the first Applet.

[0481] In some embodiments of this application, the electronic device 100 can obtain the identifier of the first Applet carried in the selectAID command and determine whether there is an NFC simulation card corresponding to the first Applet among one or more NFC simulation cards included in the electronic device 100. When the electronic device 100 has an NFC simulation card corresponding to the first Applet activated, the electronic device 100 can send the card information of the target NFC simulation card corresponding to the first Applet to the NFC card reader 200.

[0482] In some examples, the card information of an NFC emulator card may include one or more of the following: access control information, key information, transaction account information, and e-ticket information. Access control information may include one or more of the following: card number, card expiration date, etc. Key information may include one or more of the following: key code, key code expiration date, etc. Transaction account information may include one or more of the following: transaction account identifier, remaining balance in the transaction account, etc. E-ticket information may include one or more of the following: e-ticket code, e-ticket verification time, e-ticket expiration date, etc.

[0483] The NFC card reader 200 performs a card swiping operation on the first NFC simulated card based on the card information of the first NFC simulated card.

[0484] The card-swiping service can include any one of the following: opening access control, unlocking doors, unlocking vehicles, making transactions, verifying electronic tickets, verifying digital documents, and swiping transportation cards to get on and off vehicles.

[0485] Specifically, electronic device 100 can send the card information of the target NFC simulated card to NFC card reader 200 via NFC data interaction. NFC card reader 200 can then perform a card swiping transaction on the target NFC simulated card based on the card information. NFC card reader 200 can also send the card swiping result of the target NFC simulated card to electronic device 100 via NFC command interaction.

[0486] The target NFC simulated card's card information may include one or more of the following: access control information, key information, transaction account information, and electronic ticket information. Access control information may include one or more of the following: card number, card validity period, etc. Key information may include one or more of the following: key code, key code validity period, etc. Transaction account information may include one or more of the following: transaction account identifier, remaining balance in the transaction account, etc. Electronic ticket information may include one or more of the following: electronic ticket code, electronic ticket verification time, electronic ticket validity period, etc.

[0487] The NFC card swiping process of the near-field communication method provided in this application embodiment involves sending the device feature information of the NFC card reader 200 to the electronic device 100 via a Notify frame during the signaling interaction process at the access layer in the NFC communication method. This allows the electronic device 100 to determine the target NFC service before data transmission at the application layer based on the device feature information of the NFC card reader 200. During data transmission at the application layer, the NFC card reader 200 can send a Select AID command to the electronic device 100. The Select AID command carries the identifier of the first Applet, allowing the electronic device 100 to determine the first NFC card corresponding to the first Applet based on the identifier and send the card information of the first NFC card to the NFC card reader 200. This allows the NFC card reader 200 to complete the card swiping service of the first NFC card based on the card information of the first NFC card. In this way, both the electronic device 100 and the NFC card reader 200 can complete card swiping operations under different NFC services.

[0488] The following section describes the swiping process of the NFC simulated card in this embodiment of the application, taking into account a scenario where one or more NFC simulated cards are activated on the electronic device 100.

[0489] Figure 18 shows a schematic diagram of the specific card-swiping process of the NFC simulation card provided in the embodiments of this application.

[0490] As shown in Figure 18, the NFC simulated card swiping process can be applied to an NFC system including electronic device 100 and NFC card reader 200. Electronic device 100 can be in PICC mode; for example, electronic device 100 is in PICC mode by default after NFC is enabled. NFC card reader 200 can be in PCD mode. Electronic device 100 can include processor 101 and NFC module 102. Processor 101 can run an application. The application can include any of the following: native NFC-related applications (e.g., wallet applications), HCE applications, etc.

[0491] The NFC analog card swiping process may include the following steps S1801 to S1828.

[0492] S1801. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0493] The S1802 NFC reader device 200 can send probe frames.

[0494] S1803. After receiving the probe frame, the NFC module 102 sends a probe ACK frame to the NFC module 102.

[0495] After receiving the Probe ACK frame, the S1804 NFC reader device 200 sends a Notify frame.

[0496] The Notify frame carries device feature information of the NFC card reader 200.

[0497] After receiving the Notify frame, the S1805 NFC module 102 sends a Notify ACK frame to the NFC reader device 200.

[0498] After receiving a Notify ACK frame, the S1806.NFC card reader 200 can send a parameter negotiation command to the NFC module 102.

[0499] After receiving the parameter negotiation command, the S1807.NFC module 102 can send a parameter negotiation response to the NFC card reader 200.

[0500] Steps S1801 to S1807 can be referred to steps S1501 to S1507 in the embodiment shown in Figure 15 above, and will not be repeated here.

[0501] After receiving a Notify frame, the S1808.NFC module 102 can send the device feature information of the NFC reader 200 to the application.

[0502] S1809. Upon receiving device feature information from the NFC card reader 200, the application can determine and output a swipe prompt for the first NFC analog card based on the device feature information of the NFC card reader 200.

[0503] The application can manage the mapping between device feature information and NFC emulator cards. For example, the mapping between device feature information and NFC emulator cards can be stored in the application or in the Trusted Execution Environment (TEE) of the processor 101. Based on the device feature information of the NFC reader 200 and the mapping between the device feature information and NFC emulator cards, the application can determine the first NFC emulator card from one or more NFC emulator cards of the electronic device 100. The application running in the processor 101 (e.g., a wallet application) can display a swipe prompt for the first NFC emulator card.

[0504] The swipe notification of the first NFC simulated card can be used to indicate that an electronic device is using the first NFC simulated card for swiping. The swipe notification of the first NFC simulated card can include one or more of the following: image notification, text notification, audio notification, and vibration notification. Image notifications include one or more of the following: static image notification, dynamic image notification, and video notification.

[0505] For example, after identifying the first NFC simulated card, the application can display a card-swiping interface for the first NFC simulated card. This interface may include information about the first NFC simulated card. For instance, the information could be a card-shaped icon displaying the name of the first NFC simulated card. The card-swiping interface can be used to indicate to the user's electronic device 100 that it is using the first NFC simulated card for swiping.

[0506] S1810. The NFC reader 200 sends a Select AID command to the NFC module 102. The Select AID command carries the identifier of the first Applet.

[0507] After receiving the Select AID command, the S1811.NFC module 102 determines the first Applet from one or more Applets based on the identifier of the first Applet.

[0508] S1812. NFC module 102 sends response 1 to NFC card reader 200, wherein response 1 is used to indicate that electronic device 100 has successfully selected the first applet.

[0509] In electronic device 100, the service processing logic of the NFC emulator card is specifically implemented by an applet. The applet can be stored and run in the corresponding hardware device or software module (e.g., NFC module 102, HCE application, SIM card, SE, etc.) of the NFC emulator card. Since one or more NFC emulator cards are activated on electronic device 100, there can be one or more applets on electronic device 100. Specifically, one NFC emulator card corresponds to one applet.

[0510] Each applet corresponds to a master file (MF), and different applets correspond to different MFs. Therefore, once the first applet is identified, the NFC module 102 can obtain the MF of the first applet through the first applet.

[0511] S1813. The NFC module 102 determines the first DF corresponding to the first NFC analog card from the MF of the first Applet.

[0512] If the MF of the first Applet includes a DF, then that DF is the first DF corresponding to the first NFC emulator card.

[0513] If the MF of the first Applet includes multiple DFs, the MF of the first Applet may also include a first mapping table, wherein the first mapping table is used to indicate the mapping relationship between device feature information and the identifier of the dedicated file (DF) in the MF of the first Applet. The first Applet can determine the first DF corresponding to the first NFC emulated card according to the device feature information of the NFC card reader 200 and the first mapping table.

[0514] The electronic device 100 can store data from one or more NFC emulator cards via a file tree. The data from the NFC emulator card can include device characteristic information, keys, and permission information associated with the NFC emulator card. The file tree can include a master file (MF), a dedicated file (DF), and an elementary file (EF). The MF directory can contain one or more EFs and one or more DFs, and each DF directory can contain one or more EFs. One NFC emulator card corresponds to one DF, and different NFC emulator cards correspond to different DFs. Since one NFC emulator card can correspond to one or more card information entries, a DF can store one or more card information entries (EF) for storing card information (e.g., a DF can support storing up to 8 card information entries, each with a data length of 4 bytes) and one or more external authentication keys corresponding to card information entries (EF). The external authentication keys corresponding to different card information entries (EF) within the same DF can be the same or different.

[0515] For example, the NFC-enabled analog cards activated on electronic device 100 can include access cards for community A, community B, community C, a Shenzhen Tong transit card, and a home door lock key card. Since all access cards can correspond to the same Applet, the card information for the access cards in community A, B, and C can all be stored under different DFs in MF1. The Shenzhen Tong transit card corresponds to another Applet, so its card information can be stored in a DF in MF2. The home door lock key card corresponds to a separate Applet, so its card information can be stored in a DF in MF3.

[0516] For example, as shown in Figure 19, MF1 may include key EF1, Applet identity public key EF, Applet identity private key EF, mapping table EF, DF1, DF2 and DF3.

[0517] 1. Key EF1 may include a master key and a maintenance key. The master key in key EF1 can be used for encryption and decryption during data updates. The maintenance key in key EF1 can be used for encryption and decryption during data updates in the Applet identity public key EF, Applet identity private key EF, and mapping table EF.

[0518] 2. The Applet Identity Private Key (EF) can be used to store the identity private key used by one or more Applets.

[0519] 3. The Applet identity public key EF can be used to store the identity public key used by one or more Applets.

[0520] 4. The mapping list EF can be used to store the first mapping list mentioned above. The first mapping list indicates the mapping relationship between device feature information and the identifier of DF. For example, device feature information 1 corresponds to DF1, and DF1 can be used to store the access card data of community A. Device feature information 2 corresponds to DF2, and DF2 can be used to store the access card data of community B. Device feature information 3 corresponds to DF3, and DF3 can be used to store the access card data of community C.

[0521] 5. DF1 stores key EF11, device feature information EF12, file permission list EF13, and X card information EFs. X is a positive integer. Key EF11 may include a master control key, a maintenance key, and X external authentication keys. The master control key in key EF11 can be used for encryption and decryption when the data in key EF11 is updated. The maintenance key in key EF11 can be used for encryption and decryption when the device feature information EF12, file permission list EF13, and X card information EFs in DF1 are updated. The X external authentication keys in DF1 correspond to the X card information EFs in DF1, with one external authentication key corresponding to one card information EF. Different card information EFs in DF1 may correspond to the same or different external authentication keys. For example, DF1 may include card information EF storing card information 1 and card information EF storing card information 2. Card information 1 can be used to open the access control system of building 1 in community A, and card information 2 can be used to open the access control system of building 2 in community A. Device feature information EF12 can be used to store the device feature information corresponding to DF1. File permission list EF13 can be used to indicate the read and write permissions for X card information EF in DF1.

[0522] 6. DF2 stores key EF21, device characteristic information EF22, file permission list EF23, and Y card information EFs. Y is a positive integer. Key EF21 may include a master control key, a maintenance key, and Y external authentication keys. The master control key in key EF21 can be used for encryption and decryption during data updates. The maintenance key in key EF21 can be used for encryption and decryption during data updates to device characteristic information EF22, file permission list EF23, and the Y card information EFs in DF2. The Y external authentication keys in DF2 correspond to the Y card information EFs in DF2, with one external authentication key corresponding to one card information EF. Different card information EFs in DF2 may have the same or different external authentication keys. For example, DF2 may include card information EF storing card information 3, which can be used to open all access control systems within cell B. Device characteristic information EF22 can be used to store device characteristic information corresponding to DF2. File permission list EF23 can be used to indicate read and write permissions for the Y card information EFs in DF2.

[0523] 7. DF3 stores key EF31, device feature information EF32, file permission list EF33, and Z card information EFs. Z is a positive integer. Key EF31 may include a master control key, a maintenance key, and Z external authentication keys. The master control key in key EF31 can be used for encryption and decryption during data updates. The maintenance key in key EF31 can be used for encryption and decryption during data updates to device feature information EF32, file permission list EF33, and the Z card information EFs in DF3. The Z external authentication keys in DF3 correspond to the Z card information EFs in DF3, with one external authentication key corresponding to one card information EF. Different card information EFs in DF3 may have the same or different external authentication keys. For example, DF3 may include card information EF storing card information 4, which can be used to open all access control systems within cell C. Device feature information EF32 can be used to store device feature information corresponding to DF3. File permission list EF33 can be used to indicate read and write permissions for the Z card information EFs in DF3.

[0524] The example shown in Figure 19 above is only for explaining this application and should not be construed as limiting this application.

[0525] If the MF corresponding to the first Applet is MF1, the first Applet can obtain the first mapping list from the mapping list EF of MF1 shown in Figure 19 after obtaining the device feature information of the NFC card reader 200 from the NFC module 102 or the application. Then, the first Applet can determine the first DF corresponding to the first NFC analog card based on the device feature information of the NFC card reader 200 and the first mapping list.

[0526] S1814. After receiving response 1, the NFC card reader 200 sends a random number acquisition (Get Challenge) command to the NFC module 102.

[0527] S1815.NFC module 102 generates a first random number via the first applet.

[0528] S1816. NFC module 102 sends response 3 to NFC card reader 200, wherein response 3 carries a first random number.

[0529] After receiving response 3, the S1817.NFC card reader 200 encrypts the first random number with the first external authentication key to obtain the authentication ciphertext.

[0530] S1818. The NFC card reader 200 sends an external authentication command to the electronic device 100, wherein the external authentication command carries authentication ciphertext.

[0531] After receiving an external authentication command, the S1819.NFC module 102 decrypts the first random number from the authentication ciphertext using the first external authentication key in the first DF through the first Applet.

[0532] S1820. After the NFC module 102 decrypts the first random number from the authentication ciphertext using the first external authentication key in the first DF via the first Applet, it sends a response (Response) 4, which carries the first authentication result. The first authentication result is used to indicate that the electronic device 100 has successfully decrypted the first random number from the authentication ciphertext.

[0533] S1821. After receiving the response 4 carrying the first authentication result, the NFC card reader 200 sends a card information acquisition command to the NFC module 102.

[0534] After receiving the card information acquisition command, the S1822 NFC module 102 uses the first Applet to encrypt the card information of the first NFC analog card stored in the first DF using the first external authentication key and the first random number to obtain encrypted data.

[0535] S1823. NFC module 102 sends encrypted data to NFC card reader 200.

[0536] S1824. After receiving encrypted data, the NFC card reader 200 can use a first external authentication key and a first random number to decrypt the card information of the first NFC simulated card from the encrypted data, and perform the card swiping service of the first NFC simulated card based on the card information of the first NFC simulated card.

[0537] S1825. NFC card reader 200 sends the card swipe result to NFC module 102.

[0538] S1826. After receiving the card swipe result, the NFC module 102 can send a response 5 to the NFC card reader 200, wherein the response 5 is used to indicate that the electronic device 100 has successfully received the card swipe result.

[0539] The specific content of steps S1814 to S1826 can be referred to steps S1017 to S1029 in the embodiment shown in Figure 10 above, and will not be repeated here.

[0540] After receiving the card swipe result from the NFC card reader 200, the S1827.NFC module 102 can send the card swipe result to the application.

[0541] S1828. After receiving the card swipe result, the application can display the card swipe result of the first NFC simulated card.

[0542] This application provides a near-field communication method. When an electronic device 100 enters the radio frequency field emitted by an NFC card reader 200, it can receive a probe frame emitted by the NFC card reader 200. Upon receiving the probe frame, the electronic device 100 can send a probe ACK frame to the NFC card reader 200, indicating that it has received the probe frame. After receiving the probe frame, the NFC card reader 200 can send a notification frame to the electronic device 100, which carries device feature information of the NFC card reader 200. Upon receiving the notification frame, the electronic device 100 can use the device feature information of the NFC card reader 200 to identify a first NFC simulated card from one or more NFC simulated cards and display a swipe prompt for the first NFC simulated card. Then, the NFC card reader 200 can retrieve the card information of the first NFC simulated card stored in a first DF (Distributed Data Store) from the electronic device 100, thereby completing the swipe transaction of the first NFC simulated card. This allows the electronic device 100 to automatically and accurately select the appropriate NFC simulation card, quickly display the card swiping prompt for the first NFC simulation card, and complete the card swiping transaction, thus improving the speed and efficiency of NFC card swiping.

[0543] The following describes the card-swiping process of the near-field communication method provided in this application embodiment, taking the scenario of an electronic device 100 having an NFC simulation card with multiple NFC protocols enabled as an example.

[0544] Scenario 1: Electronic device 100 can activate a first NFC analog card with a first NFC protocol and a third NFC analog card with a third NFC protocol. When NFC card reader 200 supports swiping the first NFC analog card with the first NFC protocol but does not support swiping the third analog card with the third NFC protocol, NFC card reader 200 and electronic device 100 can use the swiping process shown in Figure 17 or Figure 18 above to allow electronic device 100 to select the first NFC analog card to complete the swiping.

[0545] Scenario 2: Electronic device 100 can activate a first NFC emulator card with a first NFC protocol and a third NFC emulator card with a third NFC protocol. When NFC card reader 200 supports swiping the first NFC emulator card with the first NFC protocol and the third NFC emulator card with the third NFC protocol, NFC card reader 200 and electronic device 100 can follow the swiping process shown in Figure 20A below, with electronic device 100 prioritizing the selection of the first NFC emulator card to complete the swiping process.

[0546] Figure 20A illustrates the card-swiping process of an NFC analog card in a near-field communication method provided in another embodiment of this application.

[0547] As shown in Figure 20A, the NFC analog card swiping process in this near-field communication method can be applied to an NFC system including an electronic device 100 and an NFC card reader 200. The electronic device 100 can be in PICC mode; for example, the electronic device 100 is in PICC mode by default after enabling NFC. The NFC card reader 200 can be in PCD mode. The electronic device 100 can be equipped with a first NFC analog card using a first NFC protocol and a third NFC analog card using a third NFC protocol. The NFC card reader 200 supports swiping the first NFC analog card using the first NFC protocol and the third analog card using the third NFC protocol.

[0548] The swipe process for the NFC simulated card may include the following steps S2001 to S2011. The signaling interaction process of the access layer in the first NFC protocol may include the following steps S2003 to S2008. Steps S2007 and S2008 are optional during the signaling interaction process of the access layer in the first NFC protocol. The data transmission process of the application layer in the first NFC protocol may include the following steps S2009 to S2011.

[0549] S2001. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0550] The S2002.NFC card reader 200 can send a card search request using the third NFC protocol.

[0551] The S2003 NFC reader device 200 can send probe frames.

[0552] Since the NFC card reader 200 supports swiping cards using both a first NFC protocol-compliant first NFC analog card and a third NFC protocol-compliant third NFC analog card, the NFC card reader 200 can poll and send card search requests using both the third NFC protocol and the first NFC protocol. The third NFC protocol card search request can be a REQA, and the first NFC protocol card search request can be a Probe frame.

[0553] If, after entering the radio frequency field of the NFC card reader 200, the electronic device 100 receives a card search request of the third NFC protocol as its first card search request, the electronic device 100 can wait to receive a second card search request. If the second card search request is a card search request of the first NFC protocol (i.e., a Probe frame), the electronic device 100 can respond to the second card search request by sending a card search response of the first NFC protocol (i.e., a Probe ACK frame) to the NFC card reader 200.

[0554] If the electronic device 100 receives a card search request that is a card search request of the first NFC protocol after entering the radio frequency field of the NFC card reader 200, the electronic device 100 responds to the first card search request by sending a card search response of the first NFC protocol (i.e., a Probe ACK frame) to the NFC card reader 200.

[0555] In this way, when both the NFC card reader 200 and the electronic device 100 support the first NFC protocol and the third NFC protocol, the NFC card reader 200 and the electronic device 100 can prioritize using the first NFC protocol for communication.

[0556] S2004. After receiving a probe frame, electronic device 100 sends a probe ACK frame to NFC card reader 200.

[0557] S2005. After receiving the Probe ACK frame, the NFC card reader 200 sends a Notify frame to the electronic device 100.

[0558] The Notify frame carries device feature information of the NFC card reader 200.

[0559] S2006. After receiving the Notify frame, the electronic device 100 sends a Notify ACK frame to the NFC card reader 200.

[0560] S2007. After receiving a Notify ACK frame, the NFC card reader 200 can send a parameter negotiation command to the electronic device 100.

[0561] S2008. After receiving the parameter negotiation command, the electronic device 100 can send a parameter negotiation response to the NFC card reader 200.

[0562] S2009. After receiving the parameter negotiation response, the NFC card reader 200 sends a Select AID command to the electronic device 100. The Select AID command carries the identifier of the first Applet.

[0563] S2010. Electronic device 100 determines a first NFC analog card of the first NFC protocol based on the identifier of the first Applet.

[0564] S2011. After determining the first NFC simulated card of the first NFC protocol, the electronic device 100 sends the card information of the first NFC simulated card to the NFC card reader 200 through the first Applet.

[0565] The process for steps S2004 to S2011 can be referred to steps S1703 to S1710 in the embodiment shown in Figure 17 above, and will not be repeated here.

[0566] In the NFC analog card swiping process of the near-field communication method shown in Figure 20A above, when the NFC card reader 200 supports swiping the first NFC analog card of the first NFC protocol and the third analog card of the third NFC protocol, the NFC card reader 200 and the electronic device 100 can give priority to the electronic device 100 to select the first NFC analog card to complete the swiping process.

[0567] Scenario 3: Electronic device 100 has a first NFC analog card that does not support the first NFC protocol but has a third NFC analog card that supports the third NFC protocol. When NFC card reader 200 supports swiping with both the first NFC analog card and the third NFC analog card, NFC card reader 200 and electronic device 100 can follow the swiping process shown in Figure 20B, prioritizing the electronic device 100 to attempt to select the NFC analog card using the first NFC protocol for communication with NFC card reader 200. If electronic device 100 cannot select the NFC analog card using the first NFC protocol, it can terminate the communication process with NFC card reader 200 using the first NFC protocol and swipe the card using the third NFC analog card.

[0568] Figure 20B illustrates the card-swiping process of an NFC analog card in a near-field communication method provided in another embodiment of this application.

[0569] As shown in Figure 20B, the NFC analog card swiping process in this near-field communication method can be applied to an NFC system including electronic device 100 and NFC card reader 200. Electronic device 100 can be in PICC mode; for example, electronic device 100 is in PICC mode by default after enabling NFC. NFC card reader 200 can be in PCD mode. Electronic device 100 may have a first NFC analog card with the first NFC protocol but a third NFC analog card with the third NFC protocol enabled. NFC card reader 200 supports swiping both the first NFC analog card with the first NFC protocol and the third analog card with the third NFC protocol.

[0570] The swipe process for the NFC simulated card may include the following steps S2101 to S2118. The signaling interaction process of the access layer in the first NFC protocol may include the following steps S2103 to S2108. Steps S2107 and S2108 are optional during the signaling interaction process of the access layer in the first NFC protocol. The data transmission process of the application layer in the first NFC protocol may include the following steps S2109 to S2111. The data transmission process of the application layer in the first NFC protocol may include the following steps S2109 to S2111. The signaling interaction process of the access layer in the third NFC protocol may include the following steps S2112 to S2118.

[0571] S2101. Electronic device 100 enters the radio frequency field of NFC card reader 200.

[0572] The S2102.NFC card reader 200 can send request commands for a third NFC protocol.

[0573] The S2103 NFC reader device 200 can send probe frames.

[0574] Since the NFC card reader 200 supports swiping cards using both a first NFC protocol-compliant first NFC simulated card and a third NFC protocol-compliant third NFC simulated card, the NFC card reader 200 can poll and send card search requests using both the third NFC protocol and the first NFC protocol during the polling phase. The third NFC protocol card search request can be a REQA, and the first NFC protocol card search request can be a Probe frame.

[0575] If, after entering the radio frequency field of the NFC card reader 200, the electronic device 100 receives a card search request that is a card search request using the third NFC protocol, the electronic device 100 can wait to receive a second card search request. If the second card search request is a card search request using the first NFC protocol (i.e., a Probe frame), the electronic device 100 can respond to the second card search request by sending a card search response using the first NFC protocol (i.e., a Probe ACK frame) to the NFC card reader 200. If the second card search request is also a card search request using the third NFC protocol (i.e., a Probe frame), the electronic device 100 can respond to the second card search request by sending a card search response using the third NFC protocol (e.g., ATQA) to the NFC card reader 200.

[0576] If the electronic device 100 receives a card search request that is a card search request of the first NFC protocol after entering the radio frequency field of the NFC card reader 200, the electronic device 100 responds to the first card search request by sending a card search response of the first NFC protocol (i.e., a Probe ACK frame) to the NFC card reader 200.

[0577] In this way, when both the NFC card reader 200 and the electronic device 100 support the first NFC protocol and the third NFC protocol, the NFC card reader 200 and the electronic device 100 can prioritize using the first NFC protocol for communication.

[0578] S2104. After receiving a probe frame, electronic device 100 sends a probe ACK frame to NFC card reader 200.

[0579] After receiving the Probe ACK frame, the S2105 NFC card reader 200 sends a Notify frame to the electronic device 100.

[0580] The Notify frame carries device feature information of the NFC card reader 200.

[0581] S2106. After receiving the Notify frame, the electronic device 100 sends a Notify ACK frame to the NFC card reader 200.

[0582] After receiving a Notify ACK frame, the S2107.NFC card reader 200 can send a parameter negotiation command to the electronic device 100.

[0583] S2108. After receiving the parameter negotiation command, the electronic device 100 can send a parameter negotiation response to the NFC card reader 200.

[0584] After receiving the parameter negotiation response, the S2109.NFC card reader 200 sends a Select AID command to the electronic device 100. The Select AID command carries the identifier of the first Applet.

[0585] The process for steps S2104 to S2109 can be referred to steps S1703 to S1708 in the embodiment shown in Figure 17 above, and will not be repeated here.

[0586] S2110. Based on the identifier of the first applet, the electronic device 100 determines that there is no first applet on the electronic device 100.

[0587] S2111. After determining that there is no first applet on the electronic device 100 based on the identifier of the first applet, the electronic device 100 sends a response 6 to the NFC reader 200. Response 6 indicates that the electronic device 100 has not successfully selected the first applet.

[0588] Since the electronic device 100 does not have a first NFC analog card with the first NFC protocol enabled, the electronic device 100 may not have a first applet. Therefore, after determining that the electronic device 100 does not have a first applet based on the identifier of the first applet, the electronic device 100 can send response 6 to the NFC card reader 200 to terminate the communication process of the first NFC protocol. For example, the value carried in response 6 can be "6A82".

[0589] In one possible implementation, both the first NFC emulated card and the fourth NFC emulated card may correspond to the first applet. For example, different access cards under the first NFC protocol may correspond to the same applet. Therefore, when the electronic device 100 has activated the fourth NFC emulated card but not the first NFC emulated card, after receiving the applet selection (Select AID) command, the electronic device 100 can determine that it has the first applet based on its identifier. Then, the electronic device 100 can send response 1 to the NFC card reader 200. This response 1 indicates that the electronic device 100 has successfully selected the first applet. After successfully selecting the first applet, the electronic device 100 can send the card information of the fourth NFC emulated card to the NFC card reader 200 through the first applet. Since the NFC card reader 200 does not support swiping the fourth NFC emulated card, it will return a swipe failure result to the electronic device 100, thus ending the communication process of the first NFC protocol.

[0590] After the communication process of the first NFC protocol is completed, the NFC card reader 200 can return to the polling phase.

[0591] In one possible implementation, the NFC card reader 200 can determine, before entering the polling phase, whether a card swipe using the first NFC protocol failed within a certain period (e.g., 2 seconds) prior to entering the polling phase. If a card swipe using the first NFC protocol failed within that period (e.g., 2 seconds), the NFC card reader 200 can send a card search request using the third NFC protocol but not the first NFC protocol while in the polling phase. If no card swipe using the first NFC protocol failed within that period (e.g., 2 seconds), the NFC card reader 200 can poll and send both the third NFC protocol card search request and the first NFC protocol card search request while in the polling phase.

[0592] In one possible implementation, the NFC card reader 200 can send a card search request using both the third NFC protocol and the first NFC protocol during the polling phase. If the electronic device 100 receives a card search request using the third NFC protocol after entering the radio frequency field of the NFC card reader 200, the electronic device 100 can determine whether it failed to swipe a card using the first NFC protocol within a certain period of time (e.g., 2 seconds) before receiving the first card search request. If the electronic device 100 failed to swipe a card using the first NFC protocol within a certain period of time (e.g., 2 seconds) before receiving the first card search request, then the electronic device 100 can respond to the first card search request by sending a card search response using the third NFC protocol (e.g., ATQA) to the NFC card reader 200.

[0593] If electronic device 100 does not fail to swipe a card using the first NFC protocol within a certain period of time (e.g., 2 seconds) before receiving the first card search request, electronic device 100 can wait to receive the second card search request. If the second card search request is a card search request using the first NFC protocol (i.e., a Probe frame), electronic device 100 can respond to the second card search request by sending a card search response using the first NFC protocol (i.e., a Probe ACK frame) to NFC card reader 200. If the second card search request is also a card search request using the third NFC protocol, electronic device 100 can respond to the second card search request by sending a card search response using the third NFC protocol to NFC card reader 200.

[0594] Among them, the failure to swipe the card using the first NFC protocol includes: the electronic device 100 failing to select the first applet according to the identifier of the first applet carried in the Select AID command, or the electronic device 100 successfully selecting the first applet according to the identifier of the first applet carried in the Select AID command but failing to swipe the card through the first applet.

[0595] S2112. NFC card reader 200 sends a card search request using the third NFC protocol.

[0596] S2113. After receiving a card search request using the third NFC protocol, the electronic device 100 sends a card search response (e.g., ATQA) using the third NFC protocol to the NFC card reader 200.

[0597] S2114. The NFC card reader 200 can send anti-collision commands to the electronic device 100.

[0598] In some embodiments of this application, the anti-collision command can instruct an NFC device in PICC mode to return the entire UID. In some embodiments of this application, the SEL field in the anti-collision command has a value of 93, and the NVB field has a value of 20.

[0599] S2115. Electronic device 100 can send the UID of a third NFC analog card to NFC card reader 200.

[0600] Since the electronic device 100 has a third NFC emulator card that supports the third NFC protocol, the electronic device 100 can send the UID parameter from the NFC parameters of the NFC emulator card in the active state to the NFC card reader 200 after receiving the anti-collision command.

[0601] The NFC card reader 200 can determine whether the UID of the third NFC simulated card belongs to the preset UID list of the NFC card reader 200. If the determination result is yes, the UID verification of the third NFC simulated card passes. The preset UID list of the NFC card reader 200 may include one or more UIDs. For example, if the NFC card reader 200 is an access control gate for community A, the preset UID list of the NFC card reader 200 includes the UIDs of access control cards for community A.

[0602] In some embodiments of this application, when the NFC card reader 200 verifies the UID of the third NFC analog card, the NFC card reader 200 can continue to perform subsequent processes of the access layer protocol, such as executing S2116.

[0603] S2116. The NFC card reader 200 can send a Select Unique Identifier (Select UID) command to the electronic device 100.

[0604] In some embodiments of this application, the NFC card reader 200 can determine the selected electronic device 100, and therefore can send a SelectUID command to the electronic device 100. In some examples, after the NFC card reader 200 sends an anti-collision command, it receives a UID sent by an electronic device 100, and there is no conflict between multiple NFC devices in PICC mode (i.e., no card conflict). Therefore, the NFC card reader 200 can determine the selected electronic device 100.

[0605] In some embodiments of this application, the selection command may include the SEL field, the NVB field, the complete UID and CRC of the selected electronic device 100, the SEL field may be 20, and the NVB field may be 70.

[0606] S2117. Electronic device 100 can send a select acknowledge (SAK) command to NFC card reader 200.

[0607] In some embodiments of this application, the electronic device 100 can generate a selection confirmation command based on the SAK parameter in the NFC parameters of the third NFC emulator card and send the selection confirmation command to the NFC reader 200. When the third NFC emulator card in the electronic device 100 does not support the application layer protocol, the selection confirmation command sent by the electronic device 100 to the NFC reader 200 indicates that the application layer protocol is not supported. When the received selection confirmation command indicates that the application layer protocol is not supported, the NFC reader 200 can verify the selection confirmation command.

[0608] S2118. NFC card reader 200 and electronic device 100 perform card swiping services for a third NFC analog card.

[0609] Since the NFC card reader 200 successfully verifies the UID of the third NFC simulated card in S2115, and the NFC card reader successfully verifies the selection confirmation command in S2117, the NFC card reader 200 can determine that the verification of the third NFC simulated card is successful and can execute the card swiping service of the third NFC simulated card. The card swiping service can include any of the following: opening access control, unlocking door locks, unlocking vehicles, transaction payment, electronic ticket verification, digital document verification, and using a transportation card to board or alight. In some examples, the NFC card reader 200 can send the card swiping result of the third NFC simulated card to the electronic device 100. Since the NFC card reader 200 successfully verifies the third NFC simulated card, the card swiping result indicates success. However, this is not limited to this; in other examples, if the NFC card reader 200 fails to verify the third NFC simulated card, the NFC card reader 200 can send a card swiping result indicating failure to the electronic device 100.

[0610] Through the NFC-enabled card swiping process of the near-field communication method shown in Figure 20B, the electronic device 100 has a first NFC-enabled card that does not have the first NFC protocol enabled but a third NFC-enabled card that has the third NFC protocol enabled. When the NFC reader 200 supports swiping with both the first NFC-enabled card and the third NFC-enabled card, the NFC reader 200 and the electronic device 100 can, through the swiping process shown in Figure 20B, prioritize the electronic device 100 to attempt to communicate with the NFC reader 200 using the first NFC protocol. If the electronic device 100 cannot swipe with the NFC-enabled card using the first NFC protocol, the electronic device 100 can terminate the communication process with the NFC reader 200 using the first NFC protocol and swipe with the third NFC-enabled card using the third NFC protocol. In this way, the electronic device 100 can prioritize attempting to swipe with the first NFC protocol, and if swiping with the first NFC protocol fails, the electronic device 100 can promptly switch to swiping with the third NFC protocol. This improves the swiping success rate in multi-NFC protocol swiping scenarios.

[0611] The following describes another hardware structure of an electronic device 100 provided in the embodiments of this application.

[0612] Figure 21 shows a schematic diagram of the hardware structure of an electronic device 100 provided in an embodiment of this application.

[0613] The following description uses electronic device 100 as an example to illustrate the embodiment. It should be understood that the electronic device 100 shown in FIG. 21 is merely an example, and the electronic device 100 may have more or fewer components than those shown in FIG. 21, may combine two or more components, or may have different component configurations. The various components shown in FIG. 21 can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.

[0614] Electronic device 100 may include: processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include one or more of the following: pressure sensor 180A, gyroscope sensor 180B, barometric pressure sensor 180C, magnetic sensor 180D, accelerometer sensor 180E, distance sensor 180F, proximity sensor 180G, fingerprint sensor 180H, temperature sensor 180J, touch sensor 180K, ambient light sensor 180L, bone conduction sensor 180M, etc.

[0615] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0616] Processor 110 may include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution. Processor 110 may also include memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that processor 110 has just used or is recurring. If processor 110 needs to reuse the instruction or data, it can directly retrieve it from the memory. This avoids repeated access, reduces the waiting time of processor 110, and thus improves system efficiency.

[0617] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0618] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0619] The charging management module 140 receives charging input from the charger. The power management module 141 connects to the battery 142, and the charging management module 140 connects to the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, internal memory 121, external memory, display 194, camera 193, and wireless communication module 160, etc.

[0620] The wireless communication function of electronic device 100 can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor, and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.

[0621] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.

[0622] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0623] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).

[0624] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0625] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD). The display panel can also be manufactured using organic light-emitting diodes (OLEDs), active-matrix organic light-emitting diodes (AMOLEDs), flexible light-emitting diodes (FLEDs), miniled, microled, micro-OLEDs, quantum dot light-emitting diodes (QLEDs), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.

[0626] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.

[0627] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The internal memory 121 can be used to store computer-executable program code, which includes instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, phonebook, etc.). Furthermore, the internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0628] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.

[0629] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. Gyroscope sensor 180B can be used to determine the motion posture of electronic device 100. Barometric pressure sensor 180C is used to measure air pressure. Magnetic sensor 180D includes a Hall sensor. Accelerometer sensor 180E can detect the magnitude of acceleration of electronic device 100 in various directions (generally three axes). Distance sensor 180F is used to measure distance. Proximity sensor 180G may include, for example, a light-emitting diode (LED) and a photodetector, such as a photodiode. Ambient light sensor 180L is used to sense ambient light intensity. Fingerprint sensor 180H is used to collect fingerprints. Temperature sensor 180J is used to detect temperature. Touch sensor 180K, also called a "touch panel". Touch sensor 180K can be set on display screen 194, and touch sensor 180K and display screen 194 form a touch screen, also called a "touch screen". Touch sensor 180K is used to detect touch operations applied to or near it. A touch sensor can transmit detected touch operations to an application processor to determine the type of touch event. Visual output related to the touch operation can be provided via display screen 194. In some embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194. Bone conduction sensor 180M can acquire vibration signals. Buttons 190 include a power button, volume buttons, etc. Motor 191 can generate vibration cues. Indicator 192 may be an indicator light, used to indicate charging status, battery level changes, or to indicate messages, missed calls, notifications, etc.

[0630] The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to make contact with and separate from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to realize functions such as calls and data communication. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0631] In some embodiments, the wireless communication module 160 can specifically be used to establish a short-range wireless communication link with the NFC card reader 200, so that the two can perform short-range wireless data transmission with each other. Exemplarily, the aforementioned short-range wireless communication link can be a Bluetooth link, a Wi-Fi link, an NFC link, etc. Therefore, the wireless communication module 160 can specifically include a Bluetooth communication module, a Wi-Fi communication module, or an NFC module. The NFC module can include any suitable components for enabling proximity-based contactless communication between the electronic device 100 and the NFC card reader 200, thereby providing NFC functionality to the electronic device 100. A description of the NFC module can be found in the embodiment shown in FIG3 above, and will not be repeated here.

[0632] The foregoing details the method provided in this application. In order to facilitate better implementation of the above-described solutions in the embodiments of this application, the embodiments of this application also provide corresponding devices or equipment.

[0633] This application embodiment can divide the electronic device 100 and NFC card reader 200 into functional modules according to the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.

[0634] The communication device of the present application embodiment will now be described in detail with reference to Figures 22 to 25.

[0635] Referring to FIG22, which is a schematic diagram of the structure of a communication device 2200 provided in an embodiment of this application, the communication device 2200 can be the electronic device 100 in the above embodiments or an NFC tag card. Optionally, the communication device 2200 can be a chip / chip system, such as an NFC chip. As shown in FIG22, the communication device 2200 may include a transceiver unit 2210 and a processing unit 2220.

[0636] The transceiver unit 2210 can also be used to perform NFC sending and NFC receiving functions performed by the electronic device 100 in the above embodiments of this application.

[0637] Optionally, the processing unit 2220 can also be used to perform the functional steps related to NFC protocol parsing and encapsulation, NFC service processing flow and display performed by the electronic device 100 in the above embodiments of this application.

[0638] It should be understood that the communication device 2200 in this design can perform the method steps executed by the electronic device 100 in the aforementioned embodiments, and for the sake of brevity, it will not be described again here.

[0639] Referring to FIG23, which is a schematic diagram of the structure of a communication device 2300 provided in an embodiment of this application, the communication device 2300 can be the NFC card reader 200 in the above embodiments. As shown in FIG23, the communication device 2300 may include a transceiver unit 2310 and a processing unit 2320.

[0640] Optionally, the transceiver unit 2310 can also be used to perform the NFC sending and NFC receiving functions performed by the NFC card reader device 200 in the above embodiments of this application.

[0641] Optionally, the processing unit 2320 can also be used to execute the functional steps related to NFC protocol parsing and encapsulation and NFC service processing flow executed by the NFC card reader 200 in the above embodiments of this application.

[0642] It should be understood that the communication device 2300 in this design can perform the method steps executed by the NFC card reader 200 in the aforementioned embodiment, and for the sake of brevity, it will not be described again here.

[0643] The above describes the electronic device 100 and the NFC card reader 200 of the embodiments of this application. It should be understood that any product with the functions of the electronic device 100 described in FIG22 above, or any product with the functions of the NFC card reader 200 described in FIG23 above, falls within the protection scope of the embodiments of this application.

[0644] As one possible product form, the electronic device 100 described in this application embodiment can be implemented using a general bus architecture.

[0645] Referring to Figure 24, which is a schematic diagram of the structure of a communication device 2400 provided in an embodiment of this application, the communication device 2400 can be an electronic device 100 or an NFC tag card, or a device in an electronic device 100 or an NFC tag card. As shown in Figure 24, the communication device 2400 includes a processor 2401 and a transceiver 2402 internally connected and communicating with the processor 2401. The processor 2401 can be a general-purpose processor or a dedicated processor, for example, a central processing unit and / or an NFC controller. The transceiver 2402 can be referred to as a transceiver unit, transceiver, or transceiver circuit, etc., and is used to implement transceiver functions. The transceiver 2402 can include a receiver and a transmitter. The receiver can be referred to as a receiver or receiving circuit, etc., and is used to implement a receiving function, such as an NFC receiving function; the transmitter can be referred to as a transmitter or transmitting circuit, etc., and is used to implement a transmitting function, such as an NFC transmitting function. Optionally, the communication device 2400 may also include an antenna 2403 and / or a radio frequency unit (not shown in Figure 24), for example, an NFC antenna, wherein the NFC antenna can be a coil-type antenna. The antenna 2403 and / or radio frequency unit may be located inside the communication device 2400 or separate from the communication device 2400, that is, the antenna 2403 and / or radio frequency unit may be deployed remotely or in a distributed manner.

[0646] Optionally, the communication device 2400 may include one or more memories 2404, which may store instructions, which may be computer programs, that can be executed on the communication device 2400 to cause the communication device 2400 to perform the method steps described in the above embodiments of this application. Optionally, the memory 2404 may also store data. The communication device 2400 and the memory 2404 may be provided separately or integrated together.

[0647] The processor 2401, transceiver 2402, and memory 2404 can be connected via a communication bus.

[0648] In one design, the communication device 2400 can be used to perform the functions of the electronic device 100 in the foregoing embodiments: the processor 2401 can be used to perform the functional steps related to NFC protocol parsing and encapsulation, NFC service processing flow and display performed by the electronic device 100 in the foregoing embodiments of this application and / or other processes used in the technology described herein; the transceiver 2402 can be used to perform the functional steps related to NFC sending and NFC receiving performed by the electronic device 100 in the foregoing embodiments of this application and / or other processes used in the technology described herein.

[0649] In any of the above designs, the processor 2401 may include a transceiver for implementing receive and transmit functions. For example, the transceiver may be a transceiver circuit, an interface, or an interface circuit. The transceiver circuit, interface, or interface circuit for implementing receive and transmit functions may be separate or integrated. The aforementioned transceiver circuit, interface, or interface circuit may be used for reading and writing code / data, or it may be used for transmitting or relaying signals.

[0650] In any of the above designs, the processor 2401 may store instructions, which may be computer programs. These computer programs, running on the processor 2401, cause the communication device 2400 to execute the method steps performed by the electronic device 100 in the above embodiments of this application. The computer program may be embedded in the processor 2401; in this case, the processor 2401 may be implemented in hardware.

[0651] In one implementation, the communication device 2400 may include circuitry capable of performing the functions of transmitting, receiving, or communicating as described in the foregoing method embodiments. The processor and transceiver described in this application can be implemented on integrated circuits (ICs), analog ICs, radio frequency integrated circuits (RFICs), mixed-signal ICs, application-specific integrated circuits (ASICs), printed circuit boards (PCBs), electronic devices, etc. The processor and transceiver can also be manufactured using various IC process technologies, such as complementary metal-oxide-semiconductor (CMOS), n-metal-oxide-semiconductor (NMOS), p-type metal-oxide-semiconductor (PMOS), bipolar junction transistors (BJTs), bipolar CMOS (BiCMOS), silicon-germanium (SiGe), gallium arsenide (GaAs), etc.

[0652] The scope of the communication device described in this application is not limited thereto, and the structure of the communication device is not limited to that shown in FIG24. Communication device 2400 may be a standalone device or part of a larger device. For example, the communication device 2400 may be:

[0653] (1) A standalone integrated circuit IC, or chip, or chip system or subsystem; (2) A collection of one or more ICs, optionally including storage components for storing data or computer programs; (3) An ASIC, such as an NFC chip; (4) A module that can be embedded in other devices; (5) A receiver, terminal, smart terminal, cellular phone, wireless device, handheld device, mobile unit, vehicle device, network device, cloud device, artificial intelligence device, etc.; (6) Others, etc.

[0654] As a possible product form, the NFC card reader 200 described in this application embodiment can be implemented using a general bus architecture.

[0655] Referring to Figure 25, which is a schematic diagram of the structure of a communication device 2500 provided in an embodiment of this application, the communication device 2500 may be an NFC card reader device 200, or a device therein. As shown in Figure 25, the communication device 2500 includes a processor 2501 and a transceiver 2502 internally connected and communicating with the processor 2501. The processor 2501 may be a general-purpose processor or a dedicated processor, for example, an NFC controller. The transceiver 2502 may be referred to as a transceiver unit, transceiver, or transceiver circuit, etc., and is used to implement transceiver functions. The transceiver 2502 may include a receiver and a transmitter. The receiver may be referred to as a receiver or receiving circuit, etc., and is used to implement a receiving function; the transmitter may be referred to as a transmitter or transmitting circuit, etc., and is used to implement a transmitting function. Optionally, the communication device 2500 may also include an antenna 2503 and / or a radio frequency unit (not shown in the figure). The antenna 2503 and / or radio frequency unit may be located inside the communication device 2500 or separate from the communication device 2500, that is, the antenna 2503 and / or radio frequency unit may be deployed remotely or in a distributed manner.

[0656] Optionally, the communication device 2500 may include one or more memories 2504, which may store instructions, which may be computer programs, that can be executed on the communication device 2500 to cause the communication device 2500 to perform the method steps described in the above embodiments of this application. Optionally, the memory 2504 may also store data. The communication device 2500 and the memory 2504 may be provided separately or integrated together.

[0657] The processor 2501, transceiver 2502, and memory 2504 can be connected via a communication bus.

[0658] In one design, the communication device 2500 can be used to perform the functions of the NFC card reader 200 in the foregoing embodiments: the processor 2501 can be used to perform the functional steps related to NFC protocol parsing and encapsulation, NFC service processing flow and / or other processes used in the technology described herein, performed by the NFC card reader 200 in the foregoing embodiments; the transceiver 2502 can be used to perform the functional steps related to NFC sending and NFC receiving performed by the NFC card reader 200 in the foregoing embodiments and / or other processes used in the technology described herein.

[0659] In any of the above designs, the processor 2501 may include a transceiver for implementing receiving and transmitting functions. For example, the transceiver may be a transceiver circuit, an interface, or an interface circuit. The transceiver circuit, interface, or interface circuit for implementing receiving and transmitting functions may be separate or integrated. The aforementioned transceiver circuit, interface, or interface circuit may be used for reading and writing code / data, or it may be used for transmitting or relaying signals.

[0660] In any of the above designs, the processor 2501 may store instructions, which may be computer programs. These computer programs, running on the processor 2501, cause the communication device 2500 to execute the method steps performed by the NFC card reader 200 in the above method embodiments. The computer program may be embedded in the processor 2501; in this case, the processor 2501 may be implemented in hardware.

[0661] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps performed by the electronic device 100 in the above-described method embodiments.

[0662] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the steps performed by the NFC card reader 200 in the above-described method embodiments.

[0663] This application also provides a computer program product, including a computing program, which, when run on a computer, enables the computer to perform the steps executed by the electronic device 100 in the above-described method embodiments.

[0664] This application also provides a computer program product, including a computing program, which, when run on a computer, enables the computer to perform the steps executed by the NFC card reader 200 in the above-described method embodiments.

[0665] This application also provides a chip system, which includes a processing circuit interface circuit. The interface circuit receives code instructions and transmits them to the processing circuit. The processing circuit executes the code instructions to enable the chip system to perform the steps executed by the electronic device 100 in any method embodiment of this application. The chip system can be a single chip or a chip module composed of multiple chips.

[0666] This application also provides a chip system, which includes a processing circuit interface circuit. The interface circuit receives code instructions and transmits them to the processing circuit. The processing circuit executes the code instructions to enable the chip system to perform the steps executed by the NFC card reader 200 in any method embodiment of this application. The chip system can be a single chip or a chip module composed of multiple chips.

[0667] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A near-field communication method applied to electronic devices, characterized in that, The method includes: After entering the radio frequency field of the NFC card reader, a probe frame sent by the NFC card reader is received. The probe frame is used to indicate that the NFC card reader supports the specified NFC protocol. Send a Probe ACK frame to the NFC card reader, the Probe ACK frame being used to indicate that the electronic device supports the specified NFC protocol; The system receives a Notify frame sent by the NFC card reader, the Notify frame carrying the device feature information of the NFC card reader; Based on the device feature information of the NFC card reader, a first NFC emulator is determined from one or more NFC emulators on the electronic device. Different device feature information corresponds to different NFC emulators. The device feature information of the NFC card reader includes a service identifier and a device organization identifier. The service identifier is used to indicate the type of NFC service supported by the NFC card reader, and the device organization identifier is used to indicate the manufacturer that provides NFC services using the NFC card reader.

2. The method according to claim 1, characterized in that, The device feature information of the NFC card reader also includes a device group identifier, wherein the device group identifier is used to indicate the group to which the NFC service provided by the NFC card reader belongs.

3. The method according to claim 1 or 2, characterized in that, After determining the first NFC emulator card from one or more NFC emulator cards on the electronic device based on the device feature information of the NFC card reader, the method further includes: Output a swipe notification for the first NFC simulated card. The swipe notification for the first NFC simulated card is used to indicate that the electronic device is using the first NFC simulated card for swiping.

4. The method according to any one of claims 1-3, characterized in that, After determining the first NFC emulator card from one or more NFC emulator cards on the electronic device based on the device feature information of the NFC card reader, the method further includes: A Notify ACK frame is sent to the NFC card reader. The Notify ACK frame carries a first notification result, which indicates that the electronic device has successfully selected the first NFC emulated card.

5. The method according to claim 4, characterized in that, After sending a Notify ACK frame to the NFC reader, the method further includes: The device interacts with the NFC card reader via NFC to complete the card swiping transaction of the first NFC simulated card.

6. The method according to claim 5, characterized in that, The step of interacting with the NFC card reader via NFC to complete the card swiping transaction of the first NFC simulated card specifically includes: The card information of the first NFC simulated card is sent to the NFC card reader device, and the card information of the first NFC simulated card is used by the NFC card reader device to perform the card swiping service of the first NFC simulated card; Receive the swipe result of the first NFC simulated card sent by the NFC card reader device.

7. The method according to claim 6, characterized in that, Before sending the card information of the first NFC simulated card to the NFC card reader, the method further includes: Upon receiving a mapping list query command sent by the NFC card reader, the mapping list query command is used to request the electronic device to return a first mapping list to the NFC card reader, the first mapping list is used to indicate the mapping relationship between device feature information and the identifier of the dedicated file DF; Send a mapping list query response to the NFC card reader, the mapping list query response carrying the first mapping list; The NFC card reader receives a Select DF command, which carries the identifier of the first DF. The first DF is obtained through the first applet based on the identifier of the first DF, and the first DF includes the card information of the first NFC simulated card; Send a second response to the NFC card reader, the second response indicating that the electronic device has successfully acquired the first DF; The card information of the first NFC simulation card is obtained from the first DF.

8. The method according to claim 7, characterized in that, Before receiving the mapping list query command sent by the NFC card reader, the method further includes: The system receives a Select AID command from the NFC card reader, wherein the Select AID command carries the identifier of the first Applet. In response to the Select AID command in the mini-program, the first Applet is identified from one or more Applets based on the identifier of the first Applet; Send a first response to the NFC card reader, the first response indicating that the electronic device has successfully selected the first applet.

9. The method according to claim 6, characterized in that, The Notify frame also carries the identifier of the first Applet; Before sending the card information of the first NFC simulated card to the NFC card reader, the method further includes: Based on the device feature information of the NFC card reader and the first mapping list, the identifier of the first DF corresponding to the device feature information of the NFC card reader is determined. The first mapping list is used to indicate the mapping relationship between the device feature information and the identifier of the dedicated file DF. The first DF is obtained based on the identifier of the first DF through the first Applet; The card information of the first NFC simulation card is obtained from the first DF.

10. The method according to any one of claims 6-9, characterized in that, The first DF also includes a first external authentication key; Sending the card information of the first NFC simulated card to the NFC card reader specifically includes: The first Applet uses a first external authentication key and a first random number to encrypt the card information of the first NFC emulated card to obtain encrypted data; The encrypted data is sent to the NFC card reader, and the encrypted data is used by the NFC card reader to decrypt the card information of the first NFC simulated card.

11. The method according to claim 10, characterized in that, Before encrypting the card information of the first NFC analog card using the first external authentication key and the first random number to obtain encrypted data, the method further includes: The NFC card reader receives a card information acquisition command, which is used to request the acquisition of the card information of the first NFC simulated card. The step of encrypting the card information of the first NFC simulated card using the first Applet with the first external authentication key and the first random number to obtain encrypted data specifically includes: In response to the card information acquisition command, the card information of the first NFC analog card stored in the first DF is encrypted using the first external authentication key and the first random number to obtain encrypted data.

12. The method according to claim 11, characterized in that, Before receiving the card information retrieval command sent by the NFC card reader, the method further includes: Receives a Get Challenge command sent by the NFC card reader to obtain a random number; In response to the Get Challenge command, the first random number is generated through the first Applet; Send a third response to the NFC card reader, the third response carrying the first random number; The device receives an external authentication command sent by the NFC card reader, the external authentication command carrying authentication ciphertext; The first random number is decrypted from the authentication ciphertext using the first external authentication key in the first DF through the first Applet; A fourth response is sent to the NFC card reader, the fourth response carrying a first authentication result, the first authentication result being used to indicate that the electronic device has successfully decrypted the first random number from the authentication ciphertext.

13. The method according to any one of claims 6-12, characterized in that, After receiving the swipe result of the first NFC simulated card sent by the NFC card reader, the method further includes: Output the prompt corresponding to the swipe result of the first NFC simulated card.

14. The method according to any one of claims 6-13, characterized in that, After receiving the swipe result of the first NFC simulated card sent by the NFC card reader, the method further includes: A fifth response is sent to the NFC card reader, the fifth response indicating that the electronic device has successfully received the swipe result of the first NFC simulated card.

15. An NFC analog card selection method, applied to an NFC card reader device, characterized in that, The method includes: Send a Probe frame, which is used to indicate that the NFC card reader device supports the specified NFC protocol; Receive a Probe ACK frame sent by an electronic device, the Probe ACK frame being used to indicate that the electronic device supports the specified NFC protocol; A Notify frame is sent to the electronic device. The Notify frame carries the device feature information of the NFC card reader. The Notify frame is used by the electronic device to determine a first NFC emulator card from one or more NFC emulator cards on the electronic device based on the device feature information of the NFC card reader. Different device feature information corresponds to different NFC emulator cards. The device feature information of the NFC card reader includes a service identifier and a device organization identifier. The service identifier is used to indicate the type of NFC service supported by the NFC card reader, and the device organization identifier is used to indicate the manufacturer that provides NFC services using the NFC card reader.

16. The method according to claim 15, characterized in that, The device feature information of the NFC card reader also includes a device group identifier, wherein the device group identifier is used to indicate the group to which the NFC service provided by the NFC card reader belongs.

17. The method according to claim 15 or 16, characterized in that, After sending the Notify frame to the electronic device, the method further includes: The electronic device receives a Notify ACK frame, which carries a first notification result indicating that the electronic device has successfully selected the first NFC emulator card.

18. The method according to claim 17, characterized in that, After receiving the Notify ACK frame sent by the electronic device, the method further includes: The device interacts with the electronic device via NFC to complete the card swiping transaction of the first NFC simulated card.

19. The method according to claim 18, characterized in that, The step of interacting with the electronic device via NFC to complete the card swiping transaction of the first NFC simulated card specifically includes: Receives card information of the first NFC simulated card sent by the electronic device; The card swiping service of the first NFC simulated card is executed based on the card information of the first NFC simulated card; The swipe result of the first NFC simulated card is sent to the electronic device.

20. The method according to claim 19, characterized in that, Before receiving the card information of the first NFC simulated card sent by the electronic device, the method further includes: Send a mapping list query command to the electronic device. The mapping list query command is used to request the electronic device to return a first mapping list to the NFC card reader. The first mapping list is used to indicate the mapping relationship between device feature information and the identifier of the dedicated file DF. The electronic device receives a mapping list query response, which carries the first mapping list. Send a Select DF command to the electronic device, the Select DF command carrying the identifier of a first DF, the Select DF command requesting to obtain the first DF; The electronic device receives a second response, which indicates that the electronic device has successfully acquired the first DF.

21. The method according to claim 20, characterized in that, Before sending the mapping list query command to the electronic device, the method further includes: Send a Select AID command to the electronic device, wherein the Select AID command carries the identifier of the first Applet, and the Select AID command is used to request the electronic device to select the first Applet; The electronic device receives a first response, which indicates that the electronic device has successfully selected the first applet.

22. The method according to claim 19, characterized in that, The Notify frame also carries an identifier for the first Applet, which is used by the electronic device to select the first Applet.

23. The method according to any one of claims 19-22, characterized in that, The receipt of the card information of the first NFC simulated card sent by the electronic device specifically includes: Receive encrypted data sent by the electronic device; The card information of the first NFC emulator card is decrypted from the encrypted data using a first external authentication key and a first random number.

24. The method according to claim 23, characterized in that, Before receiving encrypted data sent by the electronic device, the method further includes: A card information acquisition command is sent to the electronic device, the card information acquisition command being used to request the acquisition of the card information of the first NFC simulated card.

25. The method according to claim 24, characterized in that, Before sending the card information retrieval command to the electronic device, the method further includes: Send a Get Challenge command to the electronic device, the Get Challenge command being used to request the first Applet of the electronic device to generate the first random number; Send a third response to the NFC card reader, the third response carrying the first random number; The first random number is encrypted using the first external authentication key to obtain the authentication ciphertext; Send an external authentication command to the electronic device, the external authentication command carrying the authentication ciphertext; The electronic device receives a fourth response, which carries a first authentication result, indicating that the electronic device has successfully decrypted the first random number from the authentication ciphertext.

26. The method according to any one of claims 19-25, characterized in that, After receiving the swipe result of the first NFC simulated card sent by the NFC card reader, the method further includes: The electronic device receives a fifth response, which indicates that it has successfully received the swipe result of the first NFC analog card.

27. An NFC system, characterized in that, This includes electronic devices and NFC card readers; among them, The NFC card reader is used to send a probe frame, which is used to indicate that the NFC card reader supports a specified NFC protocol; The electronic device is configured to receive the Probe frame after entering the radio frequency field of the NFC card reader; The electronic device is further configured to send a Probe ACK frame to the NFC card reader after receiving the Probe frame, the Probe ACK frame being used to indicate that the electronic device supports the specified NFC protocol; The NFC card reader is also configured to send a Notify frame to the electronic device after receiving the Probe ACK frame, the Notify frame carrying the device feature information of the NFC card reader; The electronic device is further configured to determine a first NFC emulator card from one or more NFC emulator cards on the electronic device based on the device feature information of the NFC card reader. Different device feature information corresponds to different NFC emulator cards. The device feature information of the NFC card reader includes a service identifier and a device organization identifier. The service identifier is used to indicate the type of NFC service supported by the NFC card reader, and the device organization identifier is used to indicate the manufacturer that provides NFC services using the NFC card reader.

28. The NFC system according to claim 27, characterized in that, The device feature information of the NFC card reader also includes a device group identifier, wherein the device group identifier is used to indicate the group to which the NFC service provided by the NFC card reader belongs.

29. The NFC system according to claim 27 or 28, characterized in that, The electronic device is further configured to output a swipe notification for the first NFC simulated card, which indicates that the electronic device is using the first NFC simulated card for swiping.

30. The NFC system according to any one of claims 27-29, characterized in that, The electronic device is further configured to send a Notify ACK frame to the NFC card reader after determining the first NFC emulated card. The Notify ACK frame carries a first notification result, which indicates that the electronic device has successfully selected the first NFC emulated card.

31. The NFC system according to claim 30, characterized in that, The electronic device is further configured to, after sending a Notify ACK frame to the NFC card reader, interact with the NFC card reader via NFC to complete the card swiping service of the first NFC simulated card.

32. A near-field communication method applied to electronic devices, characterized in that, The method includes: After entering the radio frequency field of the NFC card reader, a Probe frame sent by the NFC card reader is received. The Probe frame is used to indicate that the NFC card reader supports the first NFC protocol. Send a Probe ACK frame to the NFC card reader, the Probe ACK frame being used to indicate that the electronic device supports the first NFC protocol; The system receives a Notify frame sent by the NFC card reader, the Notify frame carrying the device feature information of the NFC card reader; Send a Notify ACK frame to the NFC card reader, wherein the Notify ACK frame is used to indicate that the electronic device has successfully received the Notify frame.

33. The method according to claim 32, characterized in that, The device feature information of the NFC card reader includes a service identifier and a device organization identifier. The service identifier is used to indicate the type of NFC service supported by the NFC card reader, and the device organization identifier is used to indicate the manufacturer that provides NFC services using the NFC card reader.

34. The method according to claim 32 or 33, characterized in that, The device feature information of the NFC card reader also includes a device group identifier, wherein the device group identifier is used to indicate the group to which the NFC service provided by the NFC card reader belongs.

35. The method according to any one of claims 32-34, characterized in that, After receiving the Notify frame sent by the NFC card reader, the method further includes: Based on the device feature information of the NFC card reader 200, a card swiping prompt for the first NFC simulated card is determined and output. The card swiping prompt for the first NFC simulated card is used to indicate that the electronic device is using the first NFC simulated card for card swiping.

36. The method according to any one of claims 32-35, characterized in that, After sending a Notify ACK frame to the NFC reader, the method further includes: The system receives a mini-program selection command sent by the NFC card reader, the mini-program selection command carrying the identifier of the first Applet; Based on the identifier of the first Applet, determine the first NFC emulated card corresponding to the first Applet; The first applet sends the card information of the first NFC emulator to the NFC card reader, and the card information of the first NFC emulator is used by the NFC card reader to perform the card swiping service of the first NFC emulator.

37. The method according to claim 36, characterized in that, After sending the card information of the first NFC simulated card to the NFC card reader via the first applet, the method further includes: Receive the swipe result of the first NFC simulated card sent by the NFC card reader device.

38. The method according to claim 36 or 37, characterized in that, The step of determining the first NFC emulator card corresponding to the first Applet based on the identifier of the first Applet specifically includes: Based on the identifier of the first applet, the first applet is determined from one or more applets; Using the first applet, the first DF corresponding to the first NFC emulator is determined from the MF of the first applet. The MF of the first applet includes one or more DFs, and the one or more DFs include the first DF. The first DF includes the card information of the first NFC emulator.

39. The method according to claim 38, characterized in that, The step of determining the first DF corresponding to the first NFC emulator card from the MF of the first Applet specifically includes: The MF of the first Applet is obtained through the first Applet, and the MF of the first Applet includes a first mapping list and one or more DFs; Obtain a first mapping table from the MF of the first Applet. The first mapping table is used to indicate the mapping relationship between device feature information and the identifier of DF. Based on the device feature information of the NFC card reader and the first mapping list, the identifier of the first DF corresponding to the device feature information of the NFC card reader is determined from the MF of the first Applet; The first DF is determined from the MF of the first Applet based on the identifier of the first DF.

40. The method according to claim 38 or 39, characterized in that, The first DF also includes a first external authentication key; The step of sending the card information of the first NFC simulated card to the NFC card reader via the first Applet specifically includes: The first Applet uses a first external authentication key and a first random number to encrypt the card information of the first NFC analog card stored in the first DF to obtain encrypted data; The encrypted data is sent to the NFC card reader, and the encrypted data is used by the NFC card reader to decrypt the card information of the first NFC simulated card.

41. The method according to claim 40, characterized in that, Before encrypting the card information of the first NFC analog card using the first external authentication key and the first random number to obtain encrypted data, the method further includes: The NFC card reader receives a card information acquisition command, which is used to request the acquisition of the card information of the first NFC simulated card. The step of encrypting the card information of the first NFC simulated card using the first Applet with the first external authentication key and the first random number to obtain encrypted data specifically includes: In response to the card information acquisition command, the card information of the first NFC analog card stored in the first DF is encrypted using the first external authentication key and the first random number to obtain encrypted data.

42. The method according to claim 41, characterized in that, Before receiving the card information retrieval command sent by the NFC card reader, the method further includes: Received the Get Challenge command sent by the NFC card reader; In response to the Get Challenge command, the first random number is generated through the first Applet; Send a third response to the NFC card reader, the third response carrying the first random number; The device receives an external authentication command sent by the NFC card reader, the external authentication command carrying authentication ciphertext; The first random number is decrypted from the authentication ciphertext using the first external authentication key in the first DF through the first Applet; A fourth response is sent to the NFC card reader, the fourth response carrying a first authentication result, the first authentication result being used to indicate that the electronic device has successfully decrypted the first random number from the authentication ciphertext.

43. The method according to any one of claims 37-42, characterized in that, After receiving the swipe result of the first NFC simulated card sent by the NFC card reader, the method further includes: Output the prompt corresponding to the swipe result of the first NFC simulated card.

44. The method according to any one of claims 37-43, characterized in that, After receiving the swipe result of the first NFC simulated card sent by the NFC card reader, the method further includes: A fifth response is sent to the NFC card reader, the fifth response indicating that the electronic device has successfully received the swipe result of the first NFC simulated card.

45. The method according to any one of claims 32-44, characterized in that, After sending a Notify ACK frame to the NFC reader device, the method further includes: Receive parameter negotiation command sent by the NFC card reader; Sending a parameter negotiation response to the NFC card reader, wherein the parameter negotiation command and the parameter negotiation response are used by the NFC card reader and the electronic device to negotiate data transmission parameters at the application layer.

46. ​​The method according to claim 45, characterized in that, The data transmission parameters include one or more of the maximum transmission rate and the maximum data transmission length when performing application layer data transmission.

47. An NFC analog card selection method, applied to an NFC card reader device, characterized in that, The method includes: Send a Probe frame, the Probe frame being used to indicate that the NFC card reader device supports a first NFC protocol; Receive a Probe ACK frame sent by an electronic device, the Probe ACK frame being used to indicate that the electronic device supports the first NFC protocol; Send a Notify frame to the electronic device, the Notify frame carrying the device feature information of the NFC card reader; The electronic device receives a Notify ACK frame, wherein the Notify ACK frame is used to indicate that the electronic device has successfully received the Notify frame.

48. The method according to claim 47, characterized in that, The device feature information of the NFC card reader includes a service identifier and a device organization identifier. The service identifier is used to indicate the type of NFC service supported by the NFC card reader, and the device organization identifier is used to indicate the manufacturer that provides NFC services using the NFC card reader.

49. The method according to claim 47 or 48, characterized in that, The device feature information of the NFC card reader also includes a device group identifier, wherein the device group identifier is used to indicate the group to which the NFC service provided by the NFC card reader belongs.

50. The method according to any one of claims 47-49, characterized in that, After receiving a Notify ACK frame from the electronic device, the method further includes: Send a mini-program selection command to the electronic device. The mini-program selection command carries the identifier of the first applet and is used to request the electronic device to select the first applet. The electronic device receives the card information of the first NFC simulated card sent via the first Applet. Based on the card information of the first NFC simulated card, the card swiping service of the first NFC simulated card is executed.

51. The method according to claim 50, characterized in that, After receiving card information of the first NFC simulated card sent via the first Applet through the electronic device, the method further includes: The swipe result of the first NFC simulated card is sent to the electronic device.

52. The method according to claim 50 or 51, characterized in that, The receipt of card information of the first NFC simulated card sent by the electronic device through the first Applet specifically includes: Receive encrypted data sent by the electronic device through the first applet; The card information of the first NFC emulator card is decrypted from the encrypted data using a first external authentication key and a first random number.

53. The method according to claim 52, characterized in that, Before decrypting the card information of the first NFC emulated card from the encrypted data using the first external authentication key and the first random number, the method further includes: A card information acquisition command is sent to the electronic device, the card information acquisition command being used to request the acquisition of the card information of the first NFC simulated card.

54. The method according to claim 53, characterized in that, Before sending the card information retrieval command to the electronic device, the method further includes: Send a Get Challenge command to the electronic device, the Get Challenge command being used to request the first Applet of the electronic device to generate the first random number; Send a third response to the NFC card reader, the third response carrying the first random number; The first random number is encrypted using the first external authentication key to obtain the authentication ciphertext; Send an external authentication command to the electronic device, the external authentication command carrying the authentication ciphertext; The electronic device receives a fourth response, which carries a first authentication result, indicating that the electronic device has successfully decrypted the first random number from the authentication ciphertext.

55. The method according to any one of claims 51-54, characterized in that, After receiving the swipe result of the first NFC simulated card sent by the NFC card reader, the method further includes: The electronic device receives a fifth response, which indicates that it has successfully received the swipe result of the first NFC analog card.

56. The method according to any one of claims 47-55, characterized in that, After receiving the Notify ACK frame sent by the electronic device, the method further includes: Send a parameter negotiation command to the NFC card reader; The NFC reader receives a parameter negotiation response from the electronic device. The parameter negotiation command and the parameter negotiation response are used by the NFC reader to negotiate data transmission parameters at the application layer with the electronic device.

57. The method according to claim 56, characterized in that, The data transmission parameters include one or more of the maximum transmission rate and the maximum data transmission length when performing application layer data transmission.

58. An NFC system, characterized in that, This includes electronic devices and NFC card readers; among them, The electronic device is configured to perform the near-field communication method as described in any one of claims 32-46; The NFC card reader is used to perform the near-field communication method as described in any one of claims 47-57.

59. An electronic device, characterized in that, include: One or more processors, one or more memories, and a transceiver, wherein the transceiver, the one or more memories, and the one or more processors are coupled together, the one or more memories being used to store a computer program that, when the one or more processors execute the computer program, performs the near-field communication method as described in any one of claims 1-14 or 32-46.

60. An NFC card reader device, characterized in that, include: One or more processors, one or more memories, and a transceiver, wherein the transceiver, the one or more memories, and the one or more processors are coupled together, the one or more memories being used to store a computer program that, when the one or more processors execute the computer program, performs the near-field communication method as described in any one of claims 15-26 or 47-57.

61. A computer-readable storage medium, characterized in that, The system contains a computer program that, when executed by a processor, implements the near-field communication method as described in any one of claims 1-14 or 32-46.

62. A computer-readable storage medium, characterized in that, The device contains a computer program that, when executed by a processor, implements the near-field communication method as described in any one of claims 15-26 or 47-57.

63. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the near-field communication method as described in any one of claims 1-14 or 32-46.

64. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the near-field communication method as described in any one of claims 15-26 or 47-57.

65. A chip system, characterized in that, It includes a processing circuit and an interface circuit, wherein the interface circuit is used to receive code instructions and transmit them to the processing circuit, and the processing circuit is used to execute the code instructions to perform the near-field communication method as described in any one of claims 1-14 or 32-46.

66. A chip system, characterized in that, It includes a processing circuit and an interface circuit, wherein the interface circuit is used to receive code instructions and transmit them to the processing circuit, and the processing circuit is used to execute the code instructions to perform the near-field communication method as described in any one of claims 15-26 or 47-57.

Citation Information

Patent Citations

  • Near field communication method and near field communication device

    CN103973340A

  • Method, device, terminal, card reader and system for determining near field communication card

    CN113343732A

  • Method for automatically selecting NFC (Near Field Communication) simulation card, electronic equipment and communication system

    CN114781415A

  • Communication circuit, communication apparatus, communication method and computer program

    US20160366540A1

  • Near field communication method and near field communications device

    WO2014063331A1