A near-field communication processing method, apparatus, device, medium, and product.
By acquiring and analyzing the activation response information of the second device, the near-field communication device automatically identifies the target object and switches its working mode, solving the communication efficiency and compatibility issues under multiple types of interactive objects and realizing fast and reliable data interaction.
Patent Information
- Application Number
- CN202611630755.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-21
- Publication Date
- 2026-11-17
AI Technical Summary
In existing technologies, near-field communication devices struggle to automatically identify target object characteristics and dynamically switch working modes when faced with various types of interactive objects, resulting in low communication efficiency, poor compatibility, and the need for manual intervention or repetitive operations.
By obtaining the activation response information of the second device, it is determined whether it is the target application device, and the card reader mode or card emulation mode is dynamically switched according to the result to achieve adaptive matching.
It improves the efficiency of establishing near-field communication and the compatibility with device environments, avoids manual intervention and repetitive operations, and achieves a faster and more reliable data interaction experience.
Smart Images

Figure CN123124131A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to one or more embodiments in the field of near-field communication technology, and particularly to a near-field communication processing method. This specification also relates to one or more embodiments in a near-field communication processing apparatus, a computing device, a computer-readable storage medium, and a computer program product. Background Technology
[0002] Near Field Communication (NFC) technology, as a short-range, high-frequency wireless communication method, has been widely used in smart terminals, IoT devices, and various contactless interaction scenarios. This technology typically operates in the 13.56 MHz frequency band, relying on electromagnetic induction coupling to achieve data exchange between devices, and features convenient connection, rapid response, and high physical isolation security.
[0003] With the continuous expansion of the near-field communication (NFC) service ecosystem and the increasing complexity of terminal interaction scenarios, devices may need to alternately interact with multiple types of objects within the same physical space, such as physical tags, mobile phone emulators, and external reading / writing devices. Therefore, there is a need for a NFC processing method that can automatically identify target object characteristics and dynamically switch operating modes to achieve a faster and more reliable NFC data interaction experience. Summary of the Invention
[0004] In view of the above, one or more embodiments of this specification provide a near-field communication processing method, apparatus, device, computer-readable medium, and computer program product to improve near-field communication performance.
[0005] According to a first aspect of one or more embodiments of this specification, a near-field communication processing method is provided, applied to a first device, comprising: Obtain the activation response information from the second device; Based on the activation response information, it is determined whether the second device is the target application device; the target application device is a device that has a target application that performs business processing with the first device. If the second device is the target application device, then maintain the card reader mode and obtain the tag data provided by the second device through NFC near field communication; If the second device is not the target application device, then identify the device type of the second device; If the second device is determined to be a physical card, the first device is initialized to card reader mode to re-trigger the acquisition of activation response information; If it is determined that the second device is a terminal device in card emulation mode, then switch to card emulation mode and wait to communicate with an external card reader device.
[0006] According to a second aspect of one or more embodiments of this specification, a near-field communication processing apparatus is provided, comprising: The information acquisition module is used to acquire the activation response information fed back by the second device; The application judgment module is used to determine whether the second device is a target application device based on the activation response information; the target application device is a device that has a target application that performs business processing with the processing device. The first mode module is used to maintain the card reader mode and obtain the tag data provided by the second device through NFC near field communication if the second device is the target application device. A type recognition module is used to identify the device type of the second device if the second device is not the target application device; The second mode module is used to initialize the first device to card reader mode if it is determined that the second device is a physical card, so as to re-trigger the acquisition of activation response information; The third mode module is used to switch to card emulation mode and wait to communicate with an external card reader device if it is determined that the second device is a terminal device in card emulation mode.
[0007] According to a third aspect of one or more embodiments of this specification, a computing device is provided, including a memory and a processor; the memory is used to store a computer program or instructions, and the processor is used to execute the computer program or instructions, wherein the computer program or instructions, when executed by the processor, implement the steps of the near-field communication processing method described above.
[0008] According to a fourth aspect of one or more embodiments of this specification, a computer-readable storage medium is provided that stores computer instructions, which, when executed by a processor, implement the steps of the near-field communication processing method described above.
[0009] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instructions that, when executed by a processor, implement the steps of the near-field communication processing method described above.
[0010] One or more embodiments of this specification can achieve at least the following beneficial effects: Based on the activation response information, the target attribute is determined, and the control logic of dynamically maintaining the card reader mode, resetting the polling state, or switching to the card emulation mode is combined with the device type identification result. Thus, multiple types of near-field targets can be diverted and their working states can be adaptively matched within a single near-field communication device. This solves the problems of fixed working modes or the need for manual intervention in traditional near-field terminals. It can improve the efficiency of establishing near-field communication links, device environment compatibility, and RF power consumption management reliability, and achieve a faster and more reliable near-field data interaction experience. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This specification provides a schematic diagram of the hardware architecture of a first device according to one embodiment. Figure 2 A flowchart illustrating a near-field communication processing method provided in one embodiment of this specification; Figure 3 A flowchart illustrating a near-field communication processing method provided in one embodiment of this specification; Figure 4 This is a schematic diagram of a near-field communication processing device provided in one embodiment of this specification; Figure 5 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0013] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0014] This specification uses specific terms to describe embodiments thereof. Terms such as "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of this specification. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Furthermore, those skilled in the art can combine and integrate the different embodiments or examples described herein, as well as the features of those different embodiments or examples, without contradiction.
[0015] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “an,” “an,” “the,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification includes any or all possible combinations of one or more associated listed items.
[0016] The terms “comprising,” “including,” or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in the process, method, product, or apparatus that includes said elements is not excluded.
[0017] Although the terms "first," "second," etc., may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, "first" may also be referred to as "second," and similarly, "second" may also be referred to as "first," without departing from the scope of one or more embodiments of this specification. Ordinal numbers such as "first," "second," etc., do not necessarily indicate order; often they are used to facilitate the distinction of objects. For example, "first server" and "second server" usually refer to two servers. To distinguish these two servers, they are described as "first server" and "second server." Of course, sometimes these two servers may be the same server.
[0018] The word "if" can be interpreted as "when," "when," or "in response to a determination," depending on the context.
[0019] In this specification, unless explicitly stated otherwise, "receiving and sending data" does not necessarily mean direct receiving and sending; it can also mean indirect receiving and sending. For example, A receiving data sent by B can be understood as A directly receiving the data sent by B, or it can be understood as A indirectly receiving the data sent by B through other entities such as C. Similarly, B sending data to A can be understood as B sending the data directly to A, or it can be understood as B indirectly sending the data to A through other entities such as C. Here, C can be one entity, or it can be two or more entities.
[0020] In this specification, unless explicitly stated otherwise, the relationships between structures can be direct or indirect. For example, when describing "A is connected to B," unless it is explicitly stated that A and B are directly connected, it should be understood that A can be directly connected to B or indirectly connected to B. Similarly, when describing "A is on top of B," unless it is explicitly stated that A is directly above B (AB is adjacent and A is above B), it should be understood that A can be directly above B or indirectly above B (AB is separated by other elements, and A is above B). And so on.
[0021] If the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in one or more embodiments of this specification are obtained through open source datasets or public datasets that comply with their license agreements, or are obtained with full authorization from the relevant parties, and the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the relevant regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0022] The following explains the terms and concepts used in one or more embodiments of this specification.
[0023] NFC (Near Field Communication) is a short-range wireless communication technology that enables near-field communication between two devices, allowing for data transmission, writing, and reading. It typically operates at a high frequency of 13.56MHz. NFC is based on RFID (Radio Frequency Identification) technology and can be considered a subset of RFID, or a special form of RFID.
[0024] NFC technology mainly includes three communication modes: Reader / Writer Mode, Card Emulation Mode, and Peer-to-Peer Mode. to Peer Mode).
[0025] Reader / Writer Mode is a commonly used operating mode, similar to barcode or QR code scanning. In this mode, NFC devices can read or write information to NFC tags or devices containing NFC tags. For example, in payment scenarios, a mobile phone can be in Reader / Writer Mode to obtain payment information from the payment device for payment. This mode can be called Active Mode, and the device in this mode can be called a card reader or master device.
[0026] In Card Emulation Mode, the NFC device can emulate a smart card, allowing it to be used as a payment card, access card, or other type of card. The device can interact with existing contactless infrastructure, such as POS machines or access control systems. For example, using a mobile phone as a bank card for payments in stores; as an access card in offices or residences; or as a transit card for public transportation. This mode can be called passive mode, and the device in this mode can be called a tag device or a slave device.
[0027] Peer-to-peer mode to Peer Mode allows two NFC-enabled devices to exchange data. Both devices must be active and capable of sending and receiving data. It's primarily used for file transfer, social networking, and interactive games. For example, it enables quick pairing of Bluetooth or Wi-Fi devices via NFC. Connect via Fi and then transfer files or photos; or exchange business cards, contact information, or social media links by tapping two phones; or swap characters or share items in multiplayer games.
[0028] Application Identifier (AID): An identifier used to uniquely identify a specific application in a smart card or near-field communication tag. It consists of a Registered Application Provider Identifier (RID) registered with the International Organization for Standardization and a Proprietary Application Identifier Extension (PIX). For example, a character sequence conforming to the ISO / IEC 7816-5 standard, the application identifier for the Taxis Union e-wallet begins with A000000632.
[0029] Application Protocol Data Unit (APDU): A command and response data structure conforming to the ISO / IEC 7816-4 standard or other communication standards agreed upon by both parties. It may contain a command header, command body, and status return code, and is used for application layer data exchange between reader-mode devices and smart cards or analog terminals. For example, a command APDU may contain a command header (CLA, INS, P1, P2) and an optional command body (Lc, data field, Le), while a response APDU contains optional data fields and status codes (SW1, SW2).
[0030] Select Acknowledge (SAK): During the near-field communication (NFC) card selection phase, this status identifier returned by the target card indicates the card's protocol compatibility, hierarchical structure, and whether it supports higher-level data exchange protocols. For example, in the ISO 14443 Type A protocol, the one-byte acknowledgment code returned by the NFC card after completing the anti-collision and selection process indicates the protocol types and functionalities supported by the card. For instance, an SAK value of 0x20 indicates that the card is a Category 4 tag device and supports the ISO 14443-4 protocol.
[0031] Type A Request-to-Response (ATQA) code: Hardware characteristic information returned by a card or tag conforming to the ISO 14443 Type A specification during the initial stage of completing the anti-collision sequence in a near-field communication (NFC) device. This information indicates the type of technology supported by the device, its anti-collision capacity, and underlying communication capabilities. For example, in the ISO 14443 Type A protocol, the response code returned by the NFC card after receiving a Request-to-Request (REQA) or Wake-up-Alert (WUPA) command from the reader indicates the card type, UID length, and anti-collision capability, among other things.
[0032] Unique Identifier (UID): A unique serial number assigned to a near-field communication card or tag, used for device identification, session tracking, fast feature verification, and anti-replay mechanisms. It can be used to distinguish different cards. For example, the length of the unique identifier can be a string of 4 bytes, 7 bytes, or 10 bytes.
[0033] Request for Answer To Select (RATS): An activation request command defined by the ISO 14443-4 protocol, sent by the reader after card selection to determine whether the card supports the ISO 14443-4 transport protocol layer. If the card supports this protocol layer, an Answer To Select (ATS) message is returned; otherwise, a communication error or timeout occurs.
[0034] Host-based Card Emulation (HCE) is a near-field communication (NFC) card emulation technology that directly handles the NFC protocol stack and data responses through the application layer of the device's operating system, while delegating the card emulation logic to the main processor to adapt to the needs of multi-service concurrency and dynamic application loading. It allows terminal devices without security chips (such as mobile phones) to directly emulate NFC cards through the host processor, achieving card emulation functionality without relying on a security chip.
[0035] A security element (SE) is a hardware security module used to store and process sensitive data (such as payment keys and authentication certificates), possessing tamper-proof and attack-proof capabilities. Security elements can be embedded, integrated into a SIM card, or in the form of an external storage card.
[0036] Type 4 Tag (T4T): A near-field tag specification based on the ISO / IEC 14443-4 architecture, supporting the complete ISO-DEP protocol stack and APDU instruction interaction, and is the mainstream implementation path for card emulation applications.
[0037] Type 2 Tag (T2T): This type of near-field communication tag protocol is based on NXP MIFARE Ultralight or NTAG series chips. It typically uses a lightweight storage structure, supports basic data read and write operations, and does not have full high-level protocol interaction capabilities.
[0038] Therefore, one or more embodiments of this specification provide a near-field communication processing scheme that can automatically switch the working mode of the near-field communication device.
[0039] The technical solutions provided in the various embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0040] Figure 1 This is a schematic diagram of the hardware architecture of a first device provided in one embodiment of this specification.
[0041] like Figure 1As shown, the hardware architecture of the first device may include a near-field communication (NFC) RF front-end module 120, a NFC controller 140, a main processor 160, and a communication interface 180. The NFC RF front-end module 120 can operate in the 13.56MHz frequency band and may include an antenna coil and an RF matching circuit for transmitting and receiving RF signals. For example, it may support ISO 14443 Type A / B communication, or it may support other protocol communication, and has the ability to actively transmit RF fields (reader / writer mode) and passively respond to RF fields (card emulation mode).
[0042] The near-field communication controller 140 is electrically connected to the near-field communication RF front-end module 120, supporting two operating modes: reader / writer mode and card emulation mode. In reader / writer mode, the near-field communication controller 140 controls the near-field communication RF front-end module 120 to actively transmit RF fields and poll for passive near-field communication devices; for example, in reader / writer mode, it emits a polling signal to detect cards. In card emulation mode, the near-field communication controller 140 configures the near-field communication RF front-end module 120 to passively respond to external RF fields; for example, in card emulation mode, it simulates a T4T tag and waits for activation by an external card reader.
[0043] In some embodiments, its RFAL (Radio-Frequency Abstraction Layer) protocol stack can support both ISO-DEP (T4T card emulation) and NFC-DEP (P2P) NFC-A listener protocols.
[0044] In some embodiments, the near-field communication controller 140 may include a comprehensive chip that can operate in both reader mode and card emulation mode. In some embodiments, the near-field communication controller 140 may also be implemented using a chipset, such as a reader chip + TAG chip. The reader chip is responsible for reading, and the TAG chip is responsible for being read. The reader chip and the tag chip can work together to perform detection, such as jointly detecting whether an external field is approaching to determine whether the external field is a reader or a card.
[0045] The main processor 160 can run the near-field communication protocol stack and the control logic in one or more embodiments of this specification, such as parsing activation response information, judging the target application device, determining the device type, and making mode switching decisions, to control the near-field communication controller 140 to perform processes such as mode switching, data processing, and communication interaction.
[0046] The main processor 160 also communicates with a host computer or server via a communication interface 180 to report read tag data or receive service commands. The communication interface 180 can be a UART, SPI, I2C, USB, Ethernet, or wireless communication interface, etc.
[0047] In some embodiments, the first device can dynamically operate in reader mode or card emulation mode based on information such as the physical attributes and protocol characteristics of the second device it interacts with. When the first device is in reader mode, it can act as an active poller, transmitting an interrogation carrier through the RF front-end module to capture the activation response information returned by the second device in the RF field. It can also complete target identification or tag data acquisition based on a multi-level identification mechanism. When the first device switches to card emulation mode, it can act as a passive responder, controlling the RF front-end module to stop active transmission, switching to near-field listening mode, loading a preset tag file, and responding to activation commands and data requests issued by external card reader devices. This enables seamless connection and routing optimization for multi-terminal near-field interaction, resulting in a faster and more reliable near-field data interaction experience.
[0048] In one or more embodiments of this specification, a near-field communication processing method is provided. This application also relates to a near-field communication processing apparatus, a computing device, a computer-readable storage medium, and a computer program product, which will be described in detail in the following embodiments.
[0049] Figure 2 This is a flowchart illustrating a near-field communication processing method provided in one embodiment of this specification.
[0050] From a programming perspective, the entity executing the process can be a program mounted on the first device. From a hardware perspective, the entity executing the process can be the first device. It is understandable that this method can be executed by any device, equipment, platform, or cluster of devices with computing and processing capabilities.
[0051] like Figure 2 As shown, the process may include the following steps: Step 202: Obtain the activation response information from the second device.
[0052] The first device refers to a near-field communication device that performs the methods of one or more embodiments of this specification, and has multiple operating modes such as reader / writer mode and card emulation mode. The first device may be a smart terminal, a turnstile, an access control device, a payment terminal, etc., that integrates near-field communication functions.
[0053] The second device can refer to an external device that is close to the first device and interacts with it via near-field communication. The second device can be a physical card (such as a transportation card, access card, or bank card), a terminal device in card emulation mode (such as a card emulated by a mobile phone), or an external card reader device, etc. The activation response information can be the response information returned by the second device when the first device detects it in reader / writer mode. For example, in the ISO 14443 Type A protocol, the activation response information may include a Select Acknowledge (SAK) code, an Answer To Request of Type A (ATQA) terminal type, and a Unique Identifier (UID), etc. In some embodiments, the activation response information may also include other optional information returned by the second device, such as an ATS (Answer To Select).
[0054] In some embodiments, the first device may be in card reader mode in the default state, initial state, or idle state, sending out detection signals, such as sending a polling card detection signal, to detect whether there is an interactive object nearby.
[0055] In some embodiments, when there are no interactive objects near the first device, or when the first device is in an idle state, the first device can be in card emulation mode and card reader mode in a time-sharing manner. For example, the mode can be switched at a preset frequency, such as 500ms, 100ms, etc. for each mode, or 200ms for one mode and 100ms for another, etc.
[0056] In some embodiments, the first device can detect the presence of an external radio frequency field and determine whether an external card reader is nearby when it is in card emulation mode (also known as card mode) or card reader mode.
[0057] The aforementioned activation response signal is a signal fed back by the first device as a card reader device and the second device as a tag end (physical card or simulated card). In some embodiments, the second device may also be a card reader device, in which case the first device can switch to card emulation mode to interact with the second device. As one implementation, if the second device is a card reader device, the first device can switch to card emulation mode and respond to the card detection signal of the first device according to the NFC near-field communication process. It can also provide the tag information in the first device to the first device so that the first device can perform relevant business processes based on the tag information. Optionally, if the second device is a card reader device, the method in one or more embodiments of this specification may include: if a near-field detection signal sent by the second device is obtained, switching to card emulation mode to provide the tag information of the first device to the second device.
[0058] Near-field detection signals can be signals actively emitted by a second device acting as a card reader to detect and identify near-field communication tags. Examples include LPCD card detection signals or polling signals for normal card detection. For instance, in a near-field communication system, the card reader can continuously emit a radio frequency field with an operating frequency of 13.56MHz and periodically send polling commands (such as REQA and WUPA commands in the ISO 14443 Type A protocol) or detection pulses. Near-field detection signals can refer to the radio frequency energy signal at the physical layer or the polling command frame at the protocol layer, used to detect the presence of passive near-field communication devices in the environment.
[0059] The first device can sense and receive the near-field detection signal sent by the second device through a near-field communication radio frequency front-end. In some embodiments, the first device can detect the presence of an external radio frequency field through the physical layer (e.g., radio frequency energy exceeding a preset threshold), determine the presence of a card reader device, and switch to card emulation mode. In some embodiments, the first device can receive and parse the polling command frame sent by the second device through the protocol layer, determine the presence of a card reader device, and switch to card emulation mode.
[0060] When the first device switches from reader mode to card emulation mode, it can stop actively transmitting radio frequency fields and configure the near-field communication controller to card emulation mode. It can also load tag information into the near-field communication controller or activate the tag information in the near-field communication controller, waiting for the second device to read it as a reader.
[0061] The specific content of the tag information may include Near Field Communication Data Exchange Format (NDEF) messages, application links (such as Uniform Resource Locators used to launch payment applications), device identification information, and service parameters. In some embodiments, the tag information is an NDEF message containing an application link for launching a specific application, which carries the identification information and service parameters of the first device. The content contained in the tag information provided by the first device and the tag information provided by the second device may differ, and can be specifically set according to actual needs.
[0062] The second device can be a mobile phone, tablet computer, dedicated card reader terminal, or other device with near-field communication (NFC) read / write capabilities. The second device actively emits a near-field detection signal to attempt to detect and read NFC tags in the environment. When the first device detects this signal, it switches to card emulation mode, and the second device can then read the tag information provided by the first device.
[0063] By acquiring the near-field detection signal sent by the second device and switching to card emulation mode accordingly, the first device can proactively switch from being a reader to being read when it detects the presence of a card reader in the environment. This breaks the deadlock state where two card readers poll each other but cannot establish communication, achieving adaptive role switching in dual-reader scenarios. A communication link can be established without manual intervention or repeated attempts. This enhances the device's adaptability and service compatibility in complex near-field communication environments.
[0064] Step 204: Based on the activation response information, determine whether the second device is the target application device.
[0065] The target application device is a device that has a target application that performs business processing with the first device.
[0066] The target application can refer to a specific application that the first device needs to access to perform business processing, such as a transit-connected e-wallet, a specific city's smart card application, a third-party payment application, or an access control card application. The target application can be identified or distinguished in the second device using an Application Identifier (AID).
[0067] The target application device can be a second device with the target application, from which the first device can read data related to the target application. The target application device is a device capable of performing specific business processing with the first device. For example, it can trigger the execution of specific business processes through near-field communication, such as being able to read tag information containing business information by the first device, or being able to read tag information containing business information provided by the first device, etc.
[0068] By combining activation response information for application identification, it is possible to accurately determine whether the second device is the target application device, avoiding invalid data reading from non-target application devices, improving processing efficiency, and providing an accurate basis for subsequent mode switching decisions.
[0069] Step 206: If the second device is the target application device, then maintain the card reader mode and obtain the tag data provided by the second device through NFC near field communication.
[0070] Maintaining reader mode means that the first device maintains its current reader / writer operating mode and does not switch modes. The first device continues to actively transmit radio frequency fields through the near-field communication radio frequency front end to maintain the communication connection with the second device.
[0071] Tag data can represent data related to a target application stored in a second device. For example, tag data may include public application information, balance information, transaction details, card status information, etc.
[0072] For example, data can be read according to file identifiers. The first device first selects the target application using the SELECT AID command, then selects the target file (such as the public application information file corresponding to SFI 0x15) using the SELECT FILE command, and then reads the file content using the READ BINARY or READ RECORD command. By sequentially reading the public application information, balance, transaction details, and other files, complete tag data can be obtained.
[0073] For example, data can be read according to application-layer custom instructions. For instance, the first device can send a custom APDU instruction, such as a GET BALANCE instruction or a GET TRANSACTION LOG instruction, to the second device to directly obtain the balance and transaction details. This method is suitable for scenarios where the card supports custom instructions and offers higher reading efficiency.
[0074] For example, in a subway turnstile scenario, the turnstile, acting as the primary device, operates in card reader mode. After identifying the transit card as the target application device, it maintains card reader mode and selects the transit-unified e-wallet application using the SELECT AID command. It then reads information such as the card number, expiration date, balance, and transaction details. The turnstile can also report the read data to a host computer via a communication interface. The host computer then deducts the fare based on the balance information and controls the turnstile to open.
[0075] Step 208: If the second device is not the target application device, then identify the device type of the second device.
[0076] Device type can represent the classification of a second device in a near-field communication (NFC) system. In some embodiments, device type can include physical cards and terminal devices in card emulation mode. Physical cards are physical cards, such as plastic transportation cards and access control cards; terminal devices in card emulation mode are terminal devices that simulate NFC cards through software, such as transportation cards and access control cards simulated by a mobile phone using host card emulation technology. This terminal device can support the international standard 14443-4 transmission protocol layer.
[0077] Step 210: If it is determined that the second device is a physical card, then initialize the first device to card reader mode to re-trigger the acquisition of activation response information.
[0078] When the second device is identified as a physical SIM card and not the target application device, the first device does not need to read its data or switch to card emulation mode. At this point, the first device should release the current communication and re-enter polling mode, waiting for the next approaching second device. This prevents the first device from remaining in the current communication state and failing to detect subsequent approaching devices.
[0079] For example, if it is determined that the second device is not the target application device and is a physical card, the first device can stop the current communication and re-polle. The first device can first stop communication with the current second device (e.g., by sending a DESELECT command or directly shutting down the RF field), then reconfigure the near-field communication controller to reader mode, start polling, for example by sending a REQA / WUPA command, and wait for a response from the new second device.
[0080] For example, if it is determined that the second device is not the target application device and is a physical card, the first device can remain in reader mode and directly poll the next device. The first device does not stop the current radio frequency field; it can send an HLTA (Halt) command to put the current second device into a sleep state, and then directly send a REQA / WUPA command to poll the new device.
[0081] Continuing with the subway turnstile example, if a user touches the turnstile with a bank card or other access card, and the turnstile determines that the card is not the target application device and identifies the physical card in the card slot, it can stop communication with the card, reinitialize the card reader mode, and continue polling. When the next transit card approaches, the turnstile re-acquires the activation response information and enters a new round of judgment.
[0082] By releasing the current communication and re-polling, the first device can quickly return to a state where it can detect new devices, avoiding the problem of being unable to respond to subsequent devices due to being stuck in the current communication, and improving the continuous processing capability of the device.
[0083] In some embodiments, when the second device is determined to be a physical card and not the target application device, the first device can also remain in reader mode, read the tag data from the second device, and complete the NFC communication process. Alternatively, when the second device is determined to be a physical card and not the target application device, the first device can also interrupt the reader mode, briefly switch to a silent state, and not execute the subsequent card reading process.
[0084] Step 212: If it is determined that the second device is a terminal device in card emulation mode, then switch to card emulation mode and wait to communicate with the external card reader device.
[0085] When the second device is determined to be not the target application device and is a terminal device in card emulation mode, the first device can switch from card reader mode to card emulation mode to facilitate the second device switching to card reader mode as much as possible, so that the two can communicate.
[0086] In some embodiments, the first device may first stop the current communication with the second device, and then start the card emulation mode. In this way, the second device can activate the card reader mode due to the disappearance of the radio frequency field, and act as a card reader to read the first device in card emulation mode.
[0087] An external card reader device can refer to an external device that can actively read data from the first device after the first device switches to card emulation mode. The external card reader device can be a second device, for example, a second device that can switch to card reader mode to obtain data from the first device, or it can be any other device with card reader functionality.
[0088] In some embodiments, when the first device is in card emulation mode, the provided tag information may include information for triggering a specific terminal application. After obtaining this tag information, the external card reader device can launch the specific terminal application on the device and use it for subsequent business processing. It is understood that all of this is performed based on user authorization.
[0089] For example, a user uses their mobile phone to take the subway in city A, but the phone contains an electronic card for city B, which is not valid in city A. Alternatively, the user's phone might be a simulated access card, not used for subway travel. Here, the turnstile is considered the first device, and the user's mobile phone the second. When the user touches the turnstile with their phone, the turnstile, acting as a card reader, receives the phone's activation response information. Through certain checks, it determines that the phone is a terminal device in card emulation mode but not the target application device, and therefore cannot pass through the turnstile. In this case, the turnstile can switch to card emulation mode. Under the influence of this mode switch, the phone can activate card reader mode and read the tag data provided by the turnstile. If the tag data contains data to trigger a specific terminal application that can provide the travel service, such as a third-party payment application, the user's phone can launch the specific terminal application after obtaining the tag data, use that application to make payment, and pass through the turnstile. This simplifies the user operation as much as possible. Although one or more embodiments of this specification provide the method steps described in the embodiments or flowcharts, it is understood that the order of steps listed in the embodiments or flowcharts is only one possible execution order among many steps and does not represent the only execution order. The order of some steps can be adjusted according to actual needs, or some steps can be omitted. When the claims involve method steps, changes in the order of such steps, or parallelism between steps, are also within the scope of protection of the claims.
[0090] Figure 2The method described above identifies the second device and triggers the corresponding mode based on the activation response information. This enables the triage of multiple near-field objects and adaptive matching of their working states. It solves the problems of traditional near-field terminals having fixed working modes, requiring manual intervention or repeated link establishment when dealing with heterogeneous interactive objects, which leads to service interruptions. While ensuring the continuous execution of the target service, it also avoids redundant high-level interactions with non-target physical cards (physical cards that are not the target application device). Furthermore, it adapts to the passive response requirements of card emulation terminals, improving the efficiency of near-field communication link establishment, device environment compatibility, and the reliability of RF power consumption management.
[0091] based on Figure 2 In addition to the method described herein, this specification also provides some implementation methods of the method, which will be described below.
[0092] To further improve the accuracy and efficiency of mode switching, in some embodiments of this specification, a preliminary protocol type screening step can be added before determining the target application device. Optionally, after obtaining the activation response information from the second device, the first device can parse the technical feature parameters in the activation response information; based on these technical feature parameters, it can determine whether the tag protocol type of the second device is a target tag protocol type that matches the target application. If the tag protocol type of the second device is the target tag protocol type, it can be further determined whether the second device is the target application device.
[0093] Technical characteristic parameters can represent technical parameters in the activation response information that reflect the protocol type and communication capabilities of the second device. For example, in the ISO 14443 Type A protocol, technical characteristic parameters may include a Select Acknowledge (SAK) and an Answer to Request of Type A (ATQA). SAK can be a single byte returned by the second device after the anti-collision and selection process, indicating the protocol types and functionalities supported by the second device. ATQA can be two bytes returned by the second device during the request-response phase, indicating the type, UID length, and anti-collision capability of the second device. If the first and second devices communicate using other protocols, the technical characteristic parameters can also be other parameters, determined according to the actual situation.
[0094] The tag protocol type indicates the type of tag protocol followed by the second device in the near-field communication (NFC) system. For example, in the ISO 14443 standard, NFC tags can be divided into Type 1 tags (T1T), Type 2 tags (T2T), Type 3 tags (T3T), and Type 4 tags (T4T). Type 2 tags are based on the MIFARE Ultralight / NTAG protocol and do not support the ISO 14443-4 transport protocol layer, thus they cannot perform APDU exchange. Type 4 tags are based on the ISO 14443-4 protocol, support APDU exchange, and have file system and application layer interaction capabilities.
[0095] The target tag protocol type can represent the tag protocol type that matches the target application. For example, if the target application (such as the T4T e-wallet or T4T e-cash) is implemented based on the ISO 14443-4 protocol and stored in the T4T device, the target tag protocol type can be a Class 4 tag protocol type. The target tag protocol type is a reference value pre-configured in the first device, used to compare with the actual technical characteristic parameters of the second device.
[0096] A match indicates that the tag protocol type of the second device is consistent with the target tag protocol type, and that the second device has the protocol foundation to carry the target application.
[0097] As one implementation method, the determination can be based on the SAK value. Optionally, the technical feature parameter includes the selection confirmation code SAK. The determination of whether the tag protocol type of the second device is a target tag protocol type that matches the target application based on the technical feature parameter may include: if the selection confirmation code SAK is a first preset value, it means that the tag protocol type of the second device is the target tag protocol type.
[0098] The first preset value can represent a reference value pre-configured in the first device, used for comparison with the SAK value returned by the second device. The first preset value corresponds to the SAK value corresponding to the target tag protocol type. In some embodiments, when the target tag protocol type is a fourth-class tag protocol type, the first preset value is 0x20 (hexadecimal) or 0x28 (hexadecimal). The first preset value can be configured according to the protocol type on which the target application depends. For example, if the target application only exists in T4T devices that fully support the ISO 14443-4 protocol, the first preset value can be set to 0x20; if the target application is also compatible with some T4T devices with NFC tag platforms, the first preset value can be set to 0x28.
[0099] The first device can extract the SAK byte from the activation response information and compare it with a first preset value (such as 0x20, or a certain range). If the SAK value is the first preset value (such as 0x20), the tag protocol type of the second device can be determined to be the target tag protocol type (such as T4T); if the SAK value is not the first preset value, it can be determined that the tag protocol type of the second device is not the target protocol tag type. For example, if the SAK value is 0x00, 0x08, 0x09, 0x1D or other values, it is determined to be a non-target tag protocol type.
[0100] In some embodiments, by specifying the technical feature parameters as selection confirmation codes and simplifying the protocol type judgment to a numerical comparison with a first preset value, a low-cost and fast protocol type screening method is provided, which can reduce the computational burden of the main processor and ensure the accuracy of the judgment.
[0101] As another implementation, SAK and ATQA can be combined for comprehensive judgment. Specifically, the first device can extract both the SAK and ATQA fields for joint judgment. For example, when a specific byte of ATQA indicates that the second device supports ISO14443-4 and the SAK value is 0x20, it is determined to be a target label protocol type; if either ATQA or SAK condition is not met, it is determined to be a non-target label protocol type. This provides a redundant verification mechanism, which can further improve the reliability of the judgment.
[0102] Some embodiments in this specification parse the technical feature parameters in the activation response information and perform initial protocol type screening by matching the tag protocol type before application identification. This can quickly filter out devices that are clearly not the target application device (such as non-T4T devices), avoiding redundant interactions with incompatible devices. This reduces the sending of invalid commands and timeout waiting time, improving the processing efficiency of the first device in scenarios where multiple types of cards are continuously approaching. Through a two-layer progressive judgment structure of "initial protocol type screening - application identification," the accuracy of target application identification is ensured while reducing processing latency in non-target scenarios. It also maintains high processing speed while being compatible with multiple card types.
[0103] To further improve accuracy, after obtaining the stimulus response information from the second device, the first device can also send an application identifier selection command to the second device, receive an application selection response returned by the second device, and determine whether the second device is the target application device based on the application selection response. Optionally, the determination of whether the second device is the target application device may include: sending an application identifier selection command to the second device; receiving an application selection response returned by the second device; and determining whether the second device is the target application device based on the application selection response.
[0104] The Application Identifier Selection instruction represents the SELECT APDU instruction, which conforms to communication standards (such as ISO 7816-4). It is used to select the application identified by the specified Application Identifier (AID) from the smart card or near-field communication tag, and is used to initiate an activation request for a specific service application to the target device.
[0105] For example, the first device can perform a precise selection of a single AID. For instance, the first device pre-configures an AID for a target application, such as the Application Identifier (AID) for the Transit Union e-wallet. The first device assembles a SELECT AID APDU instruction containing this AID, sends the instruction to the second device via the near-field communication controller, and waits for the second device to return an application selection response.
[0106] For example, the first device selects an AID by traversing a list. For instance, the first device may support multiple applications for a specific service (e.g., a user can pass through a gate by swiping a physical transit card, or by swiping an electronic card simulated on a mobile phone). The first device can pre-configure a target application AID list, containing multiple possible AIDs, such as a transit-connected e-wallet or a specific city's smart card. The first device can sequentially send SELECT commands to each AID. If any command returns a successful response, the traversal stops, and the device is determined to be the target application. If all commands return failure responses, the device is determined to be a non-target application. This method is suitable for scenarios where the first device needs to be compatible with multiple target applications, improving compatibility. In some embodiments, the traversal order of the AID list can be arranged according to priority, which can be based on usage frequency. For example, sending AIDs with higher usage frequency can be prioritized to shorten the average response time. Alternatively, the priority can be determined according to other rules, or it can be set by the user.
[0107] The application selection response can represent the response APDU returned by the second device after receiving the application identifier selection instruction, and can be in a format conforming to the communication standard (ISO 7816-4 standard).
[0108] In some embodiments, the application selection response may include optional data fields and status codes (SW1SW2, StatusWord). The status codes, which can be two bytes, SW1 and SW2, indicate the result of instruction execution. For example, in the ISO 7816-4 standard, a status code of 9000 (hexadecimal) indicates successful instruction execution and that the target application has been selected in the second device; other status codes (such as 6A82 indicating no application found, and 6D00 indicating the instruction is not supported) indicate instruction execution failure and that the target application does not exist in the second device. In some embodiments, the application selection response may also include file control information (FCI) to describe the attributes and file structure of the selected application.
[0109] Optionally, determining whether the second device is the target application device based on the application selection response may include: extracting the status code from the application selection response; if the status code is a success response code, then determining that the second device is the target application device; if the status code is a failure response code, then determining that the second device is not the target application device.
[0110] Status codes can represent status bytes used in near-field communication protocols to indicate the result of instruction execution. They can be used to map the success, failure, or exception type of the underlying operation. In some embodiments, the status code can be a two-byte status word (SW), which can be represented by status byte one (SW1) and status byte two (SW2).
[0111] A successful response code can refer to a predefined execution completion indication value in the protocol specification, such as the hexadecimal value 9000 (0x9000), which is used to confirm that the target instruction has been executed without errors and the application instance is in a ready state.
[0112] The response code indicating failure can be a predefined exception indicator value in the protocol specification, or a response code different from the response code indicating success. For example, 0x6A82 indicates that the application was not found, 0x6982 indicates that the security status was not met, or 0x6A80 indicates that the parameters were incorrect, etc., which are used to indicate that the target instruction could not be completed or the application was inaccessible.
[0113] For example, precise matching can be performed based on status codes. For instance, the first device extracts the status code from the application selection response and compares it precisely with a success response code value (such as 9000). If the status code equals the success response code value, the second device is determined to be the target application device; if the status code does not equal the success response code value, the second device is determined not to be the target application device.
[0114] For example, the judgment can be based on a partial value of the status code or a range judgment. For instance, if the status code is two bytes SW1SW2, the first device can extract status code SW1 but not SW2, and determine whether SW1 belongs to the success status code range. Assume that a value of SW1 of 90 or 61 indicates success. If SW1 is 90 or 61, the second device is determined to be the target application device; otherwise, it is determined to be a non-target application device.
[0115] Based on some embodiments of this specification, a targeted extraction and success / failure classification mapping mechanism for status codes in response messages is employed. This leverages the explicit semantics of status codes in communication protocol standards to simplify the complex application status within the second device into two deterministic conclusions: success or failure. This reduces the complexity of the judgment logic implementation, while standardized status code encoding rules ensure the consistency and universality of the judgment results. Through status code extraction and success / failure comparison, this lightweight judgment mechanism enables some implementations to quickly separate target and non-target application devices at the application identification stage with deterministic conclusions. This provides a reliable prerequisite for subsequent differentiated processing and avoids processing delays or misjudgments caused by complex judgment logic.
[0116] In some embodiments, the determination can be made without relying on the application selection response returned by the second device. For example, the determination can be based on preset UID rules. Specifically, the first device can pre-configure a UID whitelist or UID characteristic rules corresponding to the target application device. When the UID of the second device meets the preset rules (such as the UID starting byte being a specific value or the UID belonging to a specific range), it can be determined as the target application device. Alternatively, the determination can be based on a pre-read application list from a directory file. Specifically, some smart cards maintain a directory file (such as EF.DIR) in the root directory, which stores a list of application identifiers for all applications in the card. The first device can select the directory file using the SELECT FILE command instead of sending an application identifier selection command (SELECT AID command), and then read the file content using the READ BINARY command to parse out the list of all registered AIDs in the card. If the list contains the target AID, it is determined as the target application device.
[0117] In some embodiments, the above-mentioned judgment method can be combined with the method of judging by application selection response to determine whether the second device is the target application device.
[0118] In some embodiments, the determination may not rely on status codes. For example, after the first device sends a SELECT AID command, the response returned by the second device may include File Control Information (FCI) in the response data field, in addition to the status code. This response will display the AID of the selected application. The first device can extract the AID from the response data field and compare it with the target AID. If the displayed AID matches the target AID, the device is determined to be the target application; otherwise, if they do not match or the response data field is empty, it is determined to be a non-target application. This method can also combine status codes for determination. If the status code is successful and the AID matches, it indicates that the second device is the target application device, further improving the accuracy of the determination. Furthermore, the FCI template in the response data field may contain an ApplicationLabel, a readable string describing the application name. The first device can extract the ApplicationLabel and compare it with a preset target application label. If they match, the device is determined to be the target application.
[0119] To further improve the efficiency of mode switching, in some embodiments, the application selection response from the second device to the application identifier selection command sent by the first device may include not only a status code but also File Control Information (FCI). For example, when the card reader device selects an application, directory, or file via the SELECT APDU, the card-side device, in addition to returning status codes SW1 and SW2, may also return a data segment before the status code to describe the selected object; this data segment is the File Control Information (FCI). The content of the FCI can be used to preliminarily determine the type of the second device.
[0120] For example, in the ISO 7816-4 standard, when a card receives a SELECT AID command but no matching application is found, the standard behavior is to return status code 6A82 (Application Not Found) and the response data field is empty. Physical T4T cards typically follow this standard and return empty data. However, the handling of HCE emulated cards in electronic devices such as mobile phones is different. The HCE service runs on the main processor of the mobile phone and is managed by the HCE framework provided by operating systems such as Android. When the HCE service receives a mismatched SELECT AID command, the HCE framework may return a non-empty FCI, which contains other AID information registered by the HCE service or a default response template. Therefore, by checking whether the FCI is empty, it is possible to further distinguish between physical cards and HCE terminal devices after application identification fails.
[0121] In some embodiments, if the status code in the application selection response sent by the second device in response to the application identifier selection instruction sent by the first device is a failure response code and the file control information FCI is not empty, it can be determined that the second device is not the target application device and the second device is a terminal device in card emulation mode. In this case, the first device can switch to card emulation mode and wait to communicate with the external card reader device.
[0122] If the status code in the application selection response sent by the first device in response to the application identifier selection instruction is a failure response code and the file control information (FCI) is empty, it may not be possible to accurately determine whether the second device is a physical card or an electronic device in the form of an analog card. In this case, the device type of the second device can be further identified.
[0123] By incorporating FCI file control information into the application selection response as a basis for judgment, and utilizing the status codes and hierarchical judgment logic of FCI, the behavioral differences in the FCI returned by physical cards and HCE terminal devices when SELECT AID fails can be leveraged. This allows for rapid determination of some device types during the application identification stage, eliminating the need for subsequent identification processes (such as UID verification and RATS detection), and shortening the processing path in HCE terminal device scenarios. While ensuring the accuracy of device type determination, processing efficiency is further improved, resulting in a better balance between judgment speed and judgment coverage in the overall solution.
[0124] In some embodiments, after determining that the second device is not the target application device, or when it is impossible to determine whether the second device is a physical card or an electronic device in a card emulation state, the type of the second device can be further identified, and the operating mode of the first device can be switched accordingly. The method in one or more embodiments of this specification may further include: if the tag protocol type of the second device is not the target tag protocol type, then identifying the device type of the second device; if it is determined that the second device is a physical card, then initializing the first device to card reader mode and executing a card detection process; if it is determined that the second device is a terminal device in card emulation mode, then switching to card emulation mode and waiting to communicate with an external card reader device.
[0125] The tag protocol type is not the target tag protocol type, which may indicate that the technical characteristic parameters (such as SAK) of the second device do not match the first preset value. For example, the second device does not belong to the fourth type of tag (T4T) device, does not support the ISO 14443-4 transmission protocol layer, cannot perform APDU command interaction, and does not have the protocol foundation to carry the target application (such as the transportation joint e-wallet).
[0126] For details on determining the device type and mode control, please refer to the descriptions in the foregoing or subsequent embodiments; they will not be repeated here.
[0127] If the tag protocol type of the second device is not the target tag protocol type, the step of determining whether the second device is the target application device in step 204 above can be skipped, and the step of determining the device type of the second device can be executed instead. By skipping the application identification process and entering the device type determination process when the protocol types do not match, invalid instructions can be avoided for devices that do not have the capability to carry the target application, reducing instruction interaction overhead and timeout waiting time, and improving processing efficiency in non-target device scenarios.
[0128] In some embodiments, the protocol type can be initially screened before application identification. For example, the first device first parses the technical feature parameters (such as SAK) in the activation response information to determine whether the tag protocol type of the second device is a target tag protocol type that matches the target application. If it is a target tag protocol type (such as SAK=0x20, T4T device), then it is further determined whether the second device is the target application device.
[0129] In some embodiments, protocol type screening can be skipped, and application identification can be performed directly. For example, after obtaining activation response information, the first device sends an application identifier selection instruction to the second device without determining whether the second device's tag protocol type matches the target application. If the second device supports application layer interaction and contains the target application, a success response is returned; if the second device does not support application layer interaction (such as a MIFARE Classic card), communication times out or an error is returned, indicating that it is not a target application device.
[0130] To further facilitate subsequent management, optionally, the activation response information in one or more embodiments of this specification may include the device unique identifier of the second device. If the second device is determined to be a physical card, it may also include: recording the device unique identifier of the second device.
[0131] A device unique identifier (UID) can be used to uniquely identify a physical entity.
[0132] The first device can store the second device's unique identifier in its local memory or transmit it to a host computer or server via a communication interface. It can also associate the unique identifier with information such as timestamps and device numbers.
[0133] In some embodiments of this specification, when the second device is determined to be a physical card, the unique device identifier already obtained in the activation response information can be used for recording. This provides a data foundation for system management functions such as passenger flow statistics, blacklist comparison, and abnormal card tracking without increasing additional command interaction overhead. This allows the first device to complete information collection simultaneously while completing business processing, thereby enhancing the overall value of the solution. For example, it can improve the security monitoring capabilities, log management efficiency, and multi-dimensional data fusion level of the near-field communication system.
[0134] To more accurately determine the device type of the second device, it can be determined through protocol layer command interaction. Optionally, the above-mentioned identification of the device type of the second device may include: sending a protocol layer probe command to the second device; receiving a protocol layer probe response returned by the second device; and determining, based on the protocol layer probe response, whether the second device is a physical card or a terminal device in card emulation mode.
[0135] Protocol layer probe commands can refer to specific activation messages used to request the target device to return support for higher-layer communication parameters. These can be commands sent by the card reader device after completing card selection, concerning whether the second device supports a specific transport protocol layer.
[0136] For example, the protocol layer probe command can be a Request for Answer To Select (RATS) command, such as one used to probe whether the second device supports the ISO 14443-4 transport protocol layer (ISO-DEP, ISO Data Exchange Protocol).
[0137] For example, after the first device completes the application selection (SELECT) for the second device, it sends the RATS command "E0 80" to the second device, where 80 indicates that the maximum frame length acceptable to the reader is 256 bytes. After sending, the first device starts a timeout timer and waits for a response from the second device.
[0138] For example, the first device can carry different frame length parameters in the parameter bytes of the RATS command, such as "E0 50" (maximum frame length 128 bytes) or "E0 20" (maximum frame length 64 bytes), to detect the second device's ability to support different frame lengths. Besides determining whether a protocol layer is supported, this method can also assess the second device's communication capabilities and optimize parameter configurations for subsequent data transmission.
[0139] A protocol layer probe response (RATS) refers to a feedback message returned by a second device after parsing a protocol layer probe command, containing parameter negotiation results or error indications. For example, in the ISO 14443-4 protocol, a protocol layer probe response can be called an Answer To Select (ATS). An ATS can be a response frame containing multiple bytes, which may include a length indicator, format bytes, interface bytes, and history bytes. The format and interface bytes of the ATS describe the protocol parameters supported by the second device, such as frame length, bit rate, and latency. When the second device does not support the RATS command, the protocol layer probe response is empty or contains other bytes, which may indicate a communication error or timeout.
[0140] For example, after sending a protocol layer probe command (such as a RATS command), the first device can start a timeout timer (such as 5 milliseconds). If a protocol layer probe response (such as an ATS) is received within the timeout period, it indicates a successful response, and the second device can be identified as a terminal device in card emulation mode; if no response is received within the timeout period, it is determined to be a communication abnormality, and the second device can be identified as a physical card.
[0141] For example, after sending a RATS command, the first device can listen for the response from the second device. If a valid ATS frame is received, it indicates a successful response, and the second device can be identified as a terminal device in card emulation mode. If an error frame or invalid frame is received, it is considered a communication error, indicating no successful response, and the second device can be identified as a physical card. Optionally, determining whether the second device is a physical card or a terminal device in card emulation mode based on the protocol layer probe response can include: if the status identifier of the protocol layer probe response is a successful response identifier, then the second device is identified as a terminal device in card emulation mode; if the status identifier of the protocol layer probe response is a communication error identifier, then the second device is identified as a physical card.
[0142] Status identifiers can refer to characteristic fields or signal flags in protocol layer probe response messages used to indicate the result of command execution. Specifically, a successful response identifier can be a status flag indicating that higher-layer protocol interaction was completed normally and parameter negotiation was successful. Communication error identifiers can be status flags indicating that a command was not responded to, the protocol rejected the request, timed out, or verification failed.
[0143] For example, the status can be determined based on the ACK response. After sending the RATS command, the first device listens for the frames returned by the second device. If an I-block (information block) frame with ATS content is received, the status flag can indicate a successful response, determining that the second device is a terminal device in card emulation mode; if the reception times out, the status flag can indicate a communication error, determining that the second device is a physical card.
[0144] For example, the frame status can be determined based on the protocol layer. After sending the RATS command, the first device detects the frame synchronization status of the physical layer through the near-field communication controller. If the near-field communication controller reports successful frame reception, the status flag can indicate a successful response; if the near-field communication controller reports frame timeout or frame error, the status flag can indicate a communication error.
[0145] In some embodiments, the above-mentioned timeout judgment and response judgment processes can also be executed in parallel. For example, if a correct response is received from the second device within a preset time, it can be indicated that the second device is a terminal device in card emulation mode; if no feedback is received from the second device within the preset time, or if the received feedback is an error response, it can be indicated that the second device is a physical card.
[0146] In some embodiments of this specification, the type of the second device is determined by protocol layer detection. This method can utilize the essential differences between physical cards and device emulation cards supported by preset communication (such as ISO 14443-4) protocol layers and make judgments based on the actual response of the protocol stack. This can improve the accuracy and reliability of device type differentiation and also ensure the correctness of subsequent mode switching decisions.
[0147] To further improve efficiency, considering that when smartphones and other smart terminals emulate cards using HCE technology, they typically use randomly generated device unique identifiers (UIDs), these differ from the fixed device unique identifiers of physical cards (usually 7 or 10 bytes) in aspects such as byte length and string composition. This allows for device type identification through the device unique identifier. Optionally, the activation response information may include the device unique identifier (UID) of the second device. The method in one or more embodiments of this specification may further include: verifying whether the device unique identifier (UID) of the second device satisfies a preset rule; if the device unique identifier (UID) of the second device satisfies the preset rule, then determining that the second device is a terminal device in card emulation mode. Sending a protocol layer probe command to the second device may include: if the device unique identifier (UID) of the second device does not satisfy the preset rule, then sending a protocol layer probe command to the second device.
[0148] Preset rules can refer to rules pre-configured in the first device to describe the device unique identifier characteristics used by terminal devices in card emulation mode or as electronic cards. Preset rules can be set based on the usage patterns of device unique identifiers when smart devices such as mobile phones emulate cards using card emulation technologies (e.g., HCE or CE). Preset rules can include rules in one or more dimensions, such as character length, string structure, and string numerical values.
[0149] If the device unique identifier of the second device does not meet the preset rules, it may be because the device unique identifier of the second device is not in the existing statistics of the first device, or it may be that the second device is a physical card. In order to perform mode switching more accurately, the first device can make further judgments through Protocol Layer Probe (RATS).
[0150] If the device's unique identifier meets the preset rules, then the second device can be determined to be a terminal device in card emulation mode, and there is no need to further judge the second device by performing a protocol layer probe command.
[0151] This two-tiered judgment mechanism, combining device unique identifier verification and protocol layer probing, enables rapid filtering and assessment. First, device unique identifier verification quickly identifies obviously emulated cards. Then, protocol layer probing provides a more precise assessment of the remaining devices. When preset rules are met, the second device can be identified as a terminal device in emulation mode, eliminating the need for protocol layer probing command interactions and timeouts. If the preset rules are not met, protocol layer probing commands are used for precise assessment, resolving the issues of low processing efficiency due to relying solely on protocol layer probing and incomplete coverage due to relying solely on device unique identifier verification. While ensuring accurate device type identification, it also shortens the average processing latency in emulated card scenarios, achieving a balance between efficiency and accuracy.
[0152] As one implementation, the preset rules can be rules for byte length and starting byte. The above verification of whether the device unique identifier of the second device meets the preset rules can include: verifying whether the byte length and starting byte identifier of the device unique identifier of the second device meet the preset rules.
[0153] Byte length refers to the number of bytes contained in a device unique identifier. For example, in the ISO 14443 Type A protocol, the byte length of a device unique identifier can be 4 bytes, 7 bytes, or 10 bytes. A 4-byte device unique identifier is usually a randomly generated short-term identifier used for a single session; a 7-byte or 10-byte device unique identifier is usually a fixed identifier used to uniquely identify a physical card.
[0154] The start byte identifier can refer to the value of the first byte or the values of the first few bytes in the device unique identifier byte sequence. The start byte identifier can be used to indicate the generation method or source of the device unique identifier. For example, in the NFC protocol specification, when the device unique identifier is a randomly generated short-lived identifier, the start byte is usually 0x08 (hexadecimal) to distinguish it from the fixed device unique identifier assigned by the manufacturer (whose start byte is determined by the manufacturer code, such as 0x04 for NXP).
[0155] Verification can be performed on two dimensions: byte length and start byte identifier. Preset rules can define the conditions that the byte length and start byte identifier must meet.
[0156] In some embodiments, the verification steps for byte length and the verification results for the two dimensions of the starting byte can be executed in parallel. The conclusion can be determined by logical AND operation. When both dimensions meet the preset rules, the device unique identifier is determined to meet the preset rules.
[0157] In some embodiments, the checks on byte length and start byte can be performed sequentially. For example, the byte length is checked first to determine if the byte length of the device unique identifier of the second device is a preset length, which is the byte length of the device unique identifier of the NFC card emulator, such as 4 bytes. If the byte length of the device unique identifier of the second device is the preset length, the start byte is checked to determine if the value of the start byte of the device unique identifier of the second device is a preset value, which is the value of the start byte of the device unique identifier of the NFC card emulator, such as 0x08. If the byte length of the device unique identifier of the second device is not the preset length, the start byte check can be skipped, and it can be determined that the second device is not a card emulator but a physical card.
[0158] For example, the starting byte can be checked first, followed by the byte length. Similar to the above embodiment, if the starting byte check passes, the byte length is checked, and the type of the second device is determined based on the byte length check result. If the starting byte check fails, it can be determined that the second device is not a card simulation device, but a physical card, and the byte length check is no longer required.
[0159] The preset length and preset value can be determined based on the communication protocol or statistical data. In different business scenarios, the preset length and / or preset value can be set to different values, or they can be set to the same value in different business scenarios. They can be set according to actual needs and are not limited here.
[0160] In some embodiments, the preset rules are configured as a configurable rule base, allowing one or more sets of verification conditions to be defined according to different application scenarios. For example, the rule base may contain the following rules: Rule 1, byte length = 4 bytes and starting byte = 0x08; Rule 2, byte length = 4 bytes and starting byte = 0x1A (corresponding to a certain vendor's HCE implementation); Rule 3, byte length = 7 bytes and starting byte = 0x04 (corresponding to a certain type of physical card known to only contain the target application). When the byte length and starting byte of the device unique identifier satisfy any rule in the rule base, it is determined that the preset rule is satisfied. This can be applied to situations where the characteristics of the device unique identifier differ in different application scenarios, improving the flexibility and compatibility of the solution. In some embodiments, the rule base can be updated through a host computer or remote configuration interface without modifying the firmware of the first device.
[0161] Taking public transportation turnstiles as an example. Example 1: Assume the preset rule is "byte length = 4 and starting byte = 0x08". When a passenger uses their mobile phone to simulate a transportation card via HCE technology and approaches the turnstile, assuming the turnstile obtains a device unique identifier with a byte length of 4 bytes and a starting byte of 0x08, it can be determined that the mobile phone is a terminal device in card emulation mode. Example 2: When a passenger approaches the turnstile with a physical transportation card, the turnstile obtains a device unique identifier with a byte length of 8 bytes, which is not equal to 4. The turnstile can terminate the verification, determining that the preset rule is not met, and then send a RATS command for protocol layer probing. Example 3: Assume a certain brand of mobile phone generates a device unique identifier with a byte length of 4 bytes during HCE emulation; however, the starting byte is not equal to 0x08. Assuming the preset rule only allows passage when the starting byte is equal to 0x08, in this case, it can be determined that the preset rule is not met, and then a RATS command can be sent for protocol layer probing. Suppose that the preset rules include multiple rules, one of which is "byte length = 4 and start byte = 0x08", and another rule is "byte length = 4 and start byte = 0x1A". In this case, the gate can pass the verification and be identified as a terminal device without sending a RATS command.
[0162] The various technical features in the above embodiments can be combined arbitrarily, as long as there is no conflict or contradiction between the combinations of features. However, due to space limitations, they have not been described one by one. Therefore, the arbitrary combination of various technical features in the above embodiments is also within the scope of this specification.
[0163] Based on the above description, in order to more clearly illustrate the methods provided in one or more embodiments of this specification, Figure 3 This is a flowchart illustrating a near-field communication processing method provided in one embodiment of this specification. Taking a public transportation turnstile scenario as an example, the near-field communication processing method provided in one or more embodiments of this specification will be described in detail.
[0164] The turnstile, as the primary device, integrates components such as a near-field communication (NFC) radio frequency front-end, a NFC controller, a main processor, and communication interfaces. Here, it is assumed that the turnstile is pre-configured with the following parameters: a first preset value corresponding to the target tag protocol type, such as configuring SAK=0x20 (corresponding to the fourth type of tag protocol); the target application's Application Identifier (AID) is the AID of the Transportation Union e-wallet; the preset rule for verifying the device's unique identifier (UID) is a 4-byte length with a starting byte of 0x08; and the turnstile is also configured with tag information, such as an NDEF message containing a payment application link. The following explanation describes the process of the turnstile handling different approaching devices. Figure 3 As shown: Step 302: The first device is in card reader mode and polls to detect the second device.
[0165] For example, the gate can default to reader mode. The gate continuously transmits a 13.56MHz radio frequency field via a near-field communication (NFC) front-end, and periodically sends REQA (RequestCommand Type A) or WUPA (Wake-Up Type A) polling commands according to the ISO 14443 Type A protocol to detect whether any passive NFC devices have entered the NFC field range. The following situations may occur: Scenario A: A passive near-field communication device enters the radio frequency field range, the gate receives the activation response information, and proceeds to step 304; Scenario B: No passive device responds, but the gate detects an external radio frequency field (i.e., another card reader device is nearby), proceeding to step 316.
[0166] Step 304: Obtain the activation response information from the second device.
[0167] For example, when a second device (a passive near-field communication device) enters the radio frequency field range of the gate, the second device can respond to the gate's polling command, and both parties execute the anti-collision and selection process of the ISO 14443 Type A protocol. The gate obtains the activation response information fed back by the second device, which includes a selection acknowledgment code (SAK), a Type A terminal response (ATQA), and a unique device identifier (UID), etc. The specific information content is not limited here.
[0168] This section uses six typical secondary devices as examples for illustration, assuming the following characteristics for each type of secondary device: Device A is a transit union physical card, SAK=0x20, the UID has a byte length of 8 bytes, and the starting byte is 0x04.
[0169] Device B is a non-transportation joint T4T access control physical card, SAK=0x20, the UID has a byte length of 8 bytes, and the starting byte is 0x04.
[0170] Device C is a non-transportation union T4T card simulated by a mobile phone through HCE technology. Its HCE implementation returns a non-empty FCI when it receives a mismatched SELECT AID instruction, SAK=0x20, the UID has a byte length of 4 bytes, and the starting byte is 0x08.
[0171] Device D is a MIFARE Classic physical access card, SAK=0x08, the UID has a byte length of 8 bytes, and the starting byte is 0x04.
[0172] Device E is a non-transportation union T4T card simulated by a mobile phone through HCE technology. Its HCE implementation returns an empty FCI when it receives a mismatched SELECT AID instruction. SAK=0x20, the UID has a byte length of 4 bytes, and the starting byte is 0x08.
[0173] The device is a MIFARE Classic card simulated by a mobile phone using HCE technology. SAK=0x08, UID has a byte length of 4 bytes, and the starting byte is 0x1A.
[0174] Step 306: Parse the selection confirmation code SAK in the activation response information and determine whether the tag protocol type is the target tag protocol type.
[0175] This step can represent an initial screening of the technology type. For example, the gate parses the SAK value from the activation response information, compares it with the first preset value 0x20, and determines whether the tag protocol type of the second device is the target tag protocol type (T4T).
[0176] For the aforementioned devices A, B, C, and E, since their SAK values are equal to the first preset value, it can be determined that the tag protocol type of these devices is the target tag protocol type (Type 4 tag protocol type, T4T), indicating that the device is a T4T device, and proceed to step 308 for application identification.
[0177] For the aforementioned devices D and E, since their SAK values are not equal to the first preset value, the gate can determine that their tag protocol type is not the target tag protocol type (non-T4T device), and can skip step 308 and proceed to step 312 to determine the device type.
[0178] Step 308: Send an application identifier selection command to the second device to determine whether it is the target application device.
[0179] The turnstile performs application identification on the T4T devices (Device A, Device B, Device C, and Device E). For example, the turnstile sends a SELECT AID APDU command to the second device, where AID is the AID of the Transport Union e-wallet. The turnstile receives an application selection response from the second device, which may include a status code (SW1, SW2) and FCI (File Control Information). The FCI describes the file structure and attributes of the selected application. When the SELECT AID command succeeds, the FCI may contain application description information; when the command fails, physical cards typically return an empty FCI, while mobile HCE emulation cards, due to the HCE framework's response mechanism, may still return a non-empty FCI even in the event of failure.
[0180] The turnstile makes a judgment based on the status code and FCI: For device A (the transit card), the transit card contains the transit card e-wallet application, returns status code 9000 (success), and the FCI contains the application's description information. The gate determines that the transit card is the target application device and proceeds to step 310.
[0181] For device B (T4T access control physical card), the access control card does not contain the Taxis Union e-wallet application. Assuming it returns status code 6A82 (application not found) and the FCI is empty (response data field length is 0), the gate determines that the access control card is not the target application device and cannot directly determine the device type through FCI, proceeding to step 312.
[0182] For device C (mobile HCE emulating a T4T card, FCI not empty), the card emulated by the mobile HCE does not contain the Taxis e-wallet application, assuming a status code of 6A82 is returned. However, due to the HCE framework's response mechanism, the HCE service still returns a non-empty FCI when it receives a mismatched SELECT AID instruction, for example, containing other AID information registered by the HCE service. The gate detects a failure status code and a non-empty FCI, a combination that closely matches the behavior of a mobile HCE emulating a card (physical cards typically return an empty FCI upon failure). Based on this, the gate determines that device C is not the target application device and is a terminal device in card emulation mode, skipping steps 310 and 312, and proceeding directly to step 316.
[0183] For device E (mobile HCE simulating a T4T card, FCI empty), when the mobile HCE receives a mismatched SELECT AID command, assuming it returns status code 6A82 and the FCI is empty, the gate determines that this device is not the target application device and that the device type cannot be directly determined through the FCI, proceeding to step 316.
[0184] Step 310: Maintain reader mode and read tag data.
[0185] After the turnstile identifies device A as the target application device, it can maintain card reader mode and continue sending read commands (READ RECORD APDU) to the transportation card to read the tag data, which may include the card number, balance, transaction records, etc. The turnstile or host computer can determine whether to allow passage based on the balance information. For example, if the balance is sufficient, it will perform a deduction operation, open the gate, and allow the passenger to pass; if the balance is insufficient, it will prompt the passenger that the balance is insufficient, and the gate will remain closed. The turnstile can also report transaction records to the backend server via a communication interface. In some embodiments, credit payment can also be used to pass through the turnstile. For example, the tag data may contain information identifying the user or information identifying the user's credit rating. If the user is a monthly billing user or has good credit, the turnstile may allow passage; otherwise, the user needs to actually pay before passing through. The specific business processing flow can be set according to actual needs; the above are only some illustrations and are not specific limitations.
[0186] After the gate allows passage or determines not to allow passage, or after the transaction is completed, the gate can remain in or initialize to card reader mode, return to step 302, and continue to poll and detect the next passenger's device.
[0187] Step 312: Determine the device type of the non-target application device.
[0188] For non-target application devices (devices B and E) with a failed status code and an empty FCI in step 308, and non-T4T devices (devices D and F) whose tag protocol type is not the target tag protocol type in step 306, the gate enters the device type determination process to determine whether the second device is a physical card or a terminal device in card emulation mode. Device type determination can employ a two-level judgment mechanism combining UID verification pre-judgment and RATS protocol layer probing. In some embodiments, either UID verification or RATS protocol layer probing can also be used to determine the device type. Here, a two-level judgment is used as an example for explanation.
[0189] Sub-step 3122: UID verification and prediction.
[0190] The gate extracts the UID from the activation response information and verifies whether the byte length and starting byte identifier of the UID meet the preset rules (e.g., byte length of 4 bytes and starting byte of 0x08).
[0191] For device B, its UID has a byte length of 8 bytes, which is not equal to 4 bytes, thus not meeting the preset rule, so proceed to sub-step 3124. For device E, its UID has a byte length of 4 bytes, which is equal to 4 bytes; the starting byte is 0x08, which is equal to 0x08. Meeting the preset rule, the gate can determine that device E is a terminal device in card emulation mode, skipping sub-step 3124 and proceeding to step 316. For device D, its UID has a byte length of 8 bytes, which is not equal to 4 bytes, thus not meeting the preset rule, so proceed to sub-step 3124. For device F, its UID has a byte length of 4 bytes, which is equal to 4 bytes; however, the starting byte is 0x1A, which is not equal to 0x08, thus not meeting the preset rule, so proceed to sub-step 3124.
[0192] Sub-step 3124: RATS protocol layer probing.
[0193] The turnstile sends a RATS command to the devices (device B, device D, and device F) whose UID verification failed, and waits for a protocol layer probe response. The three types of devices exhibit different response behaviors during the RATS probe: Device B, which supports the ISO 14443-4 protocol, returns an ATS (Automatic Response Schedule) with a successful response status. It should be noted that since Device B is a T4T device, both physical T4T cards and mobile HCE-simulated T4T cards can respond to RATS (Automatic Response Schedule). Relying solely on the RATS response may not reliably distinguish between the two. The gate, combining Device B's UID characteristics (an 8-byte fixed identifier, not conforming to HCE characteristics), an empty FCI, and the RATS response, comprehensively determines that Device B is a physical card and proceeds to step 314.
[0194] Device D does not support the ISO 14443-4 protocol and cannot recognize RATS commands. Assuming no response is returned within a preset time (e.g., 5 milliseconds), the status is marked as a communication error. The gate determines that Device D is a physical card and proceeds to step 314.
[0195] Device 4, the mobile phone HCE is simulating a non-T4T card, but the underlying near-field communication protocol stack of the phone fully supports the ISO14443-4 protocol. After receiving the RATS command, it returned ATS, with the status indicating a successful response. In non-T4T device scenarios, the physical card chip does not support the ISO 14443-4 protocol and will not respond to RATS; however, the mobile phone HCE simulating the card will respond to RATS because the underlying protocol stack supports it. Therefore, RATS detection has reliable distinguishing effectiveness in non-T4T scenarios. The gate determines that the device is a terminal device in card emulation mode based on the device's response to RATS and proceeds to step 316.
[0196] Step 314: If it is determined that the second device is a physical card and not the target application device, then record the UID of the second device and restore the card reader mode.
[0197] After the turnstile identifies devices B and D as physical cards, it can extract and record their UIDs and timestamps from the activation response information for passenger flow statistics or blacklist comparisons. Subsequently, the turnstile can stop communication with the physical cards, maintain card reader mode, return to step 302, and continue polling for the next passenger's device. The turnstile does not perform a fare deduction, and the gate remains closed.
[0198] Step 316: Switch to card emulation mode.
[0199] In this scenario, the first device can stop its current polling and reconfigure itself into listening mode. For example, the gate calls the deactivation interface of the Near Field Communication Radio Frequency Abstraction Layer (RFAL) to stop the polling operation in the current reader mode and disable radio frequency transmission. Subsequently, the gate reconfigures the Discovery Loop parameters, disabling all polling techniques in reader mode and enabling Type A listening technology (LISTEN_TECH_A) and Type F listening technology (LISTEN_TECH_F). It can also set the device quantity limit to 1, thus switching the near field communication controller from an active poller to a passive listener.
[0200] The first device can also initialize card emulation data. For example, the gate calls the card emulation initialization interface to configure the NDEF file and Type 3 Tag information block. For example, the NDEF message content can include a payment application URL (which can be associated with the gate number, site information, and transaction serial number), an Android application record (for example, containing the Android package name of the payment application, used to directly launch the payment application on the Android system), and a general link (for example, containing the HTTPS link of the payment application, used to launch the payment application on the iOS system), etc.
[0201] After the first device switches to card emulation mode, it enters a waiting-to-be-read state to perform data interaction. For example, after initialization, the gate initiates the discovery process and enters the waiting-to-be-read state, and a timeout timer (e.g., 5 seconds) can be set. When an external card reader device (mobile phone) approaches, the gate is activated and exchanges APDUs with the mobile phone according to the NFC communication protocol. The mobile phone selects the NDEF file using the SELECT command and reads the NDEF content using the READ BINARY command. After receiving the NDEF message, the mobile phone launches the payment application, performs the payment, and then the gate sends an opening command, opening the gate and allowing the passenger to pass through.
[0202] In some embodiments, if the first device does not receive activation from the external card reader device within the timeout period, or if the data interaction is completed, the first device can also resume card reader mode and return to step 302 to continue polling and detecting the next passenger's device.
[0203] Based on the same idea, embodiments of this specification also provide apparatus corresponding to the above methods.
[0204] Figure 4 This is a schematic diagram of a near-field communication processing device provided in one embodiment of this specification. This device can be used as a first device.
[0205] like Figure 4 As shown, the device may include: The information acquisition module 402 is used to acquire the activation response information fed back by the second device; The application judgment module 404 is used to determine whether the second device is a target application device based on the activation response information; the target application device is a device that has a target application that performs business processing with the processing device. The first mode module 406 is used to maintain the card reader mode and obtain the tag data provided by the second device through NFC near field communication if the second device is the target application device. The type recognition module 408 is used to identify the device type of the second device if the second device is not the target application device; The second mode module 410 is used to initialize the processing device to card reader mode if it is determined that the second device is a physical card, so as to re-trigger the acquisition of activation response information. The third mode module 412 is used to switch to card emulation mode and wait to communicate with an external card reader device if it is determined that the second device is a terminal device in card emulation mode.
[0206] based on Figure 4 The embodiments of this specification also provide some specific implementation schemes of the method, which are described below.
[0207] Optionally, the device may further include a technical feature determination module, which can be used to: parse the technical feature parameters in the activation response information; determine whether the tag protocol type of the second device is a target tag protocol type that matches the target application based on the technical feature parameters; the determination of whether the second device is a target application device may include: if the tag protocol type of the second device is the target tag protocol type, then determine whether the second device is a target application device.
[0208] Optionally, the technical feature parameters may include a selection confirmation code; determining whether the tag protocol type of the second device is a target tag protocol type that matches the target application based on the technical feature parameters may include: if the selection confirmation code is a first preset value, then it indicates that the tag protocol type of the second device is the target tag protocol type.
[0209] Optionally, the device can also be used to: identify the device type of the second device if the tag protocol type of the second device is not the target tag protocol type; initialize the first device to card reader mode and execute the card detection process if the second device is determined to be a physical card; and switch to card emulation mode and wait to communicate with an external card reader device if the second device is determined to be a terminal device in card emulation mode.
[0210] Optionally, determining whether the second device is the target application device may include: sending an application identifier selection instruction to the second device; receiving an application selection response returned by the second device; and determining whether the second device is the target application device based on the application selection response.
[0211] Optionally, determining whether the second device is the target application device based on the application selection response may include: extracting the status code from the application selection response; if the status code is a success response code, then determining that the second device is the target application device; if the status code is a failure response code, then determining that the second device is not the target application device.
[0212] Optionally, the application selection response may further include FCI file control information; the step of determining that the second device is not the target application device if the status code is a failure response code may include: if the status code is a failure response code and the file control information is not empty, then the second device is determined to be not the target application device and is a terminal device in card emulation mode, and the first device switches to card emulation mode and waits to communicate with an external card reader device; the step of identifying the device type of the second device if the second device is not the target application device may include: if the status code is a failure response code and the file control information is empty, then the device type of the second device is identified.
[0213] Optionally, the activation response information includes the device unique identifier (UID) of the second device. If the second device is determined to be a physical card, it may also include: recording the device unique identifier of the second device.
[0214] Optionally, identifying the device type of the second device may include: sending a protocol layer probe command to the second device; receiving a protocol layer probe response returned by the second device; and determining, based on the protocol layer probe response, that the second device is a physical card or a terminal device in card emulation mode.
[0215] Optionally, determining whether the second device is a physical card or a terminal device in card emulation mode based on the protocol layer probe response may include: if the status identifier of the protocol layer probe response is a successful response identifier, then determining that the second device is a terminal device in card emulation mode; if the status identifier of the protocol layer probe response is a communication error identifier, then determining that the second device is a physical card.
[0216] Optionally, the activation response information includes the device unique identifier (UID) of the second device. The device can also be used to: verify whether the device unique identifier (UID) of the second device meets a preset rule; if the device unique identifier (UID) of the second device meets the preset rule, then determine that the second device is a terminal device in card emulation mode; the step of sending a protocol layer probe command to the second device can include: if the device unique identifier (UID) of the second device does not meet the preset rule, then send a protocol layer probe command to the second device.
[0217] Optionally, verifying whether the device unique identifier (UID) of the second device meets the preset rules may include: verifying whether the byte length and the starting byte identifier of the device unique identifier (UID) of the second device meet the preset rules.
[0218] Optionally, if the second device is a card reader, the apparatus can also be used to: if a near-field detection signal sent by the second device is received, switch to card emulation mode to provide the tag information of the first device to the second device. It is understood that the above modules refer to computer programs or program segments used to perform one or more specific functions. Furthermore, the distinction between the above modules does not mean that the actual program code must also be separate.
[0219] For ease of description, the above devices are described by dividing them into various modules or units based on their functions. Of course, when implementing one or more of these specifications, the functions of each module or unit can be implemented in the same or different software and / or hardware, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0220] The above is a schematic scheme of a near-field communication processing device according to this embodiment. It should be noted that the technical solution of this near-field communication processing device and the technical solution of the near-field communication processing method described above belong to the same concept. For details not described in detail in the technical solution of the near-field communication processing device, please refer to the description of the technical solution of the near-field communication processing method described above.
[0221] Based on the same idea, this specification also provides devices corresponding to the above methods in its embodiments.
[0222] Figure 5 A structural block diagram of a computing device 500 provided according to an embodiment of this specification is shown.
[0223] The computing device 500 includes: Memory 510 and processor 520; The memory 510 is used to store computer programs / instructions, and the processor 520 is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor 520, they implement the steps of the above-described near-field communication processing method.
[0224] Specifically, the components of the computing device 500 include, but are not limited to, a memory 510 and a processor 520. The processor 520 is connected to the memory 510 via a bus 530, and the database 550 is used to store data.
[0225] The computing device 500 also includes an access device 540, which enables the computing device 500 to communicate via one or more networks 560. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 540 may include one or more of any type of wired or wireless network interface (e.g., a network interface card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0226] In one embodiment of this specification, the aforementioned components of the computing device 500 and Figure 5 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 5 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.
[0227] The computing device 500 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 500 can also be a mobile or stationary server.
[0228] The processor 520 executes the computer instructions to implement the steps of the above-described near-field communication processing method.
[0229] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the near-field communication processing method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the near-field communication processing method described above.
[0230] An embodiment of this specification also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the near-field communication processing method as described above.
[0231] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the near-field communication processing method described above belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the near-field communication processing method described above.
[0232] An embodiment of this specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the near-field communication processing method described above.
[0233] The above is an illustrative scheme of a computer program product according to this embodiment. It should be noted that the technical solution of this computer program product and the technical solution of the near-field communication processing method described above belong to the same concept. For details not described in detail in the technical solution of the computer program product, please refer to the description of the technical solution of the near-field communication processing method described above.
[0234] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for the embodiments of apparatus, devices, media, and products, since they are basically similar to the method embodiments, the descriptions are relatively simple, and relevant parts can be referred to the descriptions of the method embodiments. The apparatus, devices, media, and products provided in the embodiments of this specification correspond to the methods; therefore, the apparatus, devices, media, and products also have similar beneficial technical effects to the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the corresponding apparatus, devices, media, and products will not be repeated here.
[0235] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0236] With technological advancements, many improvements to current methodologies can now be seen as direct improvements to hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodologies into the hardware circuit. Therefore, it cannot be said that an improvement to a methodology cannot be implemented using a hardware entity module. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program a digital system themselves to "integrate" it onto a PLD, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must also be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0237] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0238] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0239] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.
[0240] Those skilled in the art will understand that one or more embodiments of this specification can be provided as a method, system, or computer program product. Therefore, the invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0241] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0242] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0243] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0244] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0245] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0246] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital character versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0247] This application can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0248] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A near-field communication processing method, applied to a first device, comprising: Obtain the activation response information from the second device; Based on the activation response information, it is determined whether the second device is the target application device; The target application device is a device that has a target application that performs business processing with the first device. If the second device is the target application device, then maintain the card reader mode and obtain the tag data provided by the second device through NFC near field communication; If the second device is not the target application device, then identify the device type of the second device; If the second device is determined to be a physical card, the first device is initialized to card reader mode to re-trigger the acquisition of activation response information; If it is determined that the second device is a terminal device in card emulation mode, then switch to card emulation mode and wait to communicate with an external card reader device.
2. The method according to claim 1, further comprising: Analyze the technical feature parameters in the activation response information; Based on the technical feature parameters, determine whether the tag protocol type of the second device is a target tag protocol type that matches the target application; The step of determining whether the second device is the target application device includes: If the tag protocol type of the second device is the target tag protocol type, then determine whether the second device is the target application device.
3. The method according to claim 2, wherein the technical feature parameters include a selection confirmation code; The step of determining whether the tag protocol type of the second device is a target tag protocol type that matches the target application based on the technical feature parameters includes: If the selection confirmation code is the first preset value, it indicates that the tag protocol type of the second device is the target tag protocol type.
4. The method according to claim 2, further comprising: If the tag protocol type of the second device is not the target tag protocol type, then the device type of the second device is identified; If the second device is determined to be a physical card, the first device is initialized to card reader mode and the card detection process is executed. If it is determined that the second device is a terminal device in card emulation mode, then switch to card emulation mode and wait to communicate with an external card reader device.
5. The method according to claim 1, wherein determining whether the second device is a target application device includes: Send an application identifier selection command to the second device; Receive the application selection response returned by the second device; Based on the application selection response, determine whether the second device is the target application device.
6. The method according to claim 5, wherein determining whether the second device is the target application device based on the application selection response includes: Extract the status code from the application selection response; If the status code is a response code indicating success, then the second device is determined to be the target application device; If the status code is a response code indicating failure, then it is determined that the second device is not the target application device.
7. The method according to claim 6, wherein the application selection response further includes FCI file control information; The step of determining that the second device is not the target application device if the status code is a response code indicating failure includes: If the status code is a response code indicating failure and the file control information is not empty, then it is determined that the second device is not the target application device and is a terminal device in card emulation mode. The first device switches to card emulation mode and waits to communicate with an external card reader device. If the second device is not the target application device, then identifying the device type of the second device includes: If the status code is a response code indicating failure and the file control information is empty, then the device type of the second device is identified.
8. The method according to claim 1 or 4, wherein the activation response information includes the device unique identifier (UID) of the second device, and if it is determined that the second device is a physical card, it further includes: Record the unique identifier of the second device.
9. The method according to claim 1 or 4, wherein identifying the device type of the second device includes: Send a protocol layer probe command to the second device; Receive the protocol layer probe response returned by the second device; Based on the protocol layer detection response, it is determined that the second device is a physical card or a terminal device in card emulation mode.
10. The method according to claim 9, wherein determining that the second device is a physical card or a terminal device in card emulation mode based on the protocol layer probe response comprises: If the status identifier of the protocol layer probe response is a success response identifier, then the second device is determined to be a terminal device in card emulation mode; If the status identifier of the protocol layer probe response is a communication anomaly identifier, then the second device is determined to be a physical card.
11. The method according to claim 9, wherein the activation response information includes the device unique identifier (UID) of the second device, and the method further includes: Verify whether the device unique identifier (UID) of the second device meets the preset rules; If the device unique identifier (UID) of the second device satisfies the preset rule, then the second device is determined to be a terminal device in card emulation mode; Sending the protocol layer probe command to the second device includes: If the device unique identifier (UID) of the second device does not meet the preset rule, a protocol layer probe command is sent to the second device.
12. The method according to claim 11, wherein verifying whether the device unique identifier (UID) of the second device satisfies a preset rule includes: Verify whether the byte length of the device unique identifier (UID) of the second device and the starting byte identifier meet the preset rules.
13. The method according to any one of claims 1 to 7 or 10 to 12, wherein if the second device is a card reader device, the method further comprises: If a near-field detection signal sent by the second device is received, the system switches to card emulation mode to provide the tag information of the first device to the second device.
14. A near-field communication processing device, comprising: The information acquisition module is used to acquire the activation response information fed back by the second device; The application judgment module is used to determine whether the second device is a target application device based on the activation response information; the target application device is a device that has a target application that performs business processing with the processing device. The first mode module is used to maintain the card reader mode and obtain the tag data provided by the second device through NFC near field communication if the second device is the target application device. A type recognition module is used to identify the device type of the second device if the second device is not the target application device; The second mode module is used to initialize the processing device to card reader mode if it is determined that the second device is a physical card, so as to re-trigger the acquisition of activation response information; The third mode module is used to switch to card emulation mode and wait to communicate with an external card reader device if it is determined that the second device is a terminal device in card emulation mode.
15. A computing device, comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1 to 13.
16. A computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 13.
17. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 13.
