BALTECH Docs |
C API for BALTECH SDK
|
brp_errcode brp_Iso14CE_ActivateCardAPDU | ( | brp_protocol | protocol, |
bool | SpecifyTimeoutApdu, | ||
bool | AutoWTX, | ||
unsigned | ATQA, | ||
brp_buf | Snr, | ||
bool | DSEqualToDR, | ||
bool | DS8, | ||
bool | DS4, | ||
bool | DS2, | ||
bool | DR8, | ||
bool | DR4, | ||
bool | DR2, | ||
unsigned | FWT, | ||
unsigned | TimeoutPCD, | ||
unsigned | TimeoutApdu, | ||
brp_buf | ATS, | ||
size_t | ATS_len, | ||
brp_buf * | FirstCmd, | ||
size_t * | FirstCmd_len, | ||
brp_mempool * | mempool | ||
) |
This command starts the reader's passive mode, emulating an ISO14443-4 compatible card, and returns the first APDU request received.
The emulated PICC answers all ISO14443-3 request, anticollision and select commands. It utilizes the 4-Byte serial number specified in the Snr parameter. The Byte order corresponds to ISO14443-3: The first Byte (uid0) will be transmitted first to the reader. It has to be 0x08 as this indicates a random serial number.
To identify potential errors, the PCD starts a timer within which the PICC has to respond, after sending out each frame. This time duration is the so-called frame waiting time (FWT). FWT is determined by the PICC during protocol activation and is valid for all further communication. This parameter should be chosen as large as required, but as small as possible. The communication speed between card emulator and host and the processing speed of the host should be taken into consideration. It is possible to increase the FWT temporarily for a single frame by calling the brp_Iso14CE_ExtendWaitingTime() command. Since the ISO14443 protocol specification only allows discrete FWT values, the firmware calculates the lowest value that meets the specified waiting time according to the equation
FWI = (256 * 16 / fc) * 2 ^ FWT,
where fc is the RFID carrier frequency. The highest possible FWT value is 4949 ms.
2 timeout parameters triggering a timer have to be specified for this command:
The ATS (historical bytes) the card emulation shall use may be specified by the ATS parameter if required. This parameter may also be left out, in which case no historical bytes are sent.
As already mentioned, ISO14443-4 specifies that a card has to send a response within FWT ms. The command brp_Iso14CE_ExtendWaitingTime() can be called to extend this time temporarily if the host cannot prepare the APDU within the defined FWT time. A more convenient way to perform this action is to use the automatic WTX mode : If the parameter AutoWTX is set to 1, the card emulation will automatically transmit WTX requests periodically every 0.9 * FWT ms after the successful execution of the Iso14CE.StartEmu command and of all subsequent brp_Iso14CE_ExchangeCardAPDU() commands. In practice, this allows to ignore the FWT limits, since the card emulation itself keeps the communication with the PCD alive.
[in] | protocol | used to execute the command |
[in] | SpecifyTimeoutApdu | Has to be set if the TimeoutApdu parameter is present. |
[in] | AutoWTX | Enable/disable automatic Waiting Time Extension |
[in] | ATQA | Attention: When transferred via HF, the ATQA is sent LSB (instead of the MSB order used here). |
[in] | Snr | Card serial number of the emulated PICC according to the ISO14443-3 specification (uid0, uid1, uid2, uid3). |
[in] | DSEqualToDR | Same D for both directions |
[in] | DS8 | supports 848 kBit PICC -> PCD |
[in] | DS4 | supports 424 kBit PICC -> PCD |
[in] | DS2 | supports 212 kBit PICC -> PCD |
[in] | DR8 | supports 848 kBit PCD -> PICC |
[in] | DR4 | supports 424 kBit PCD -> PICC |
[in] | DR2 | supports 212 kBit PCD -> PICC |
[in] | FWT | Frame waiting time in ms. This is the maximum time the PCD waits for the next PICC response. If FWT is set to 0xFFFF the default frame waiting time of 77.328 ms will be applied. |
[in] | TimeoutPCD | Maximum time (in ms) to wait for card activation. Card activation is complete after the PICC has received the RATS command. A value of 0xFFFF corresponds to an infinite time. |
[in] | TimeoutApdu | Maximum time (in ms) to wait for an optional Apdu or the first ISO14443-4 APDU after the first received PCD frame. This value is optional - if not given as a parameter, it's set to 100ms. A value of 0xFFFF corresponds to an infinite time. |
[in] | ATS | ATS (Historical Bytes) to use for card emulation. |
[in] | ATS_len | |
[out] | FirstCmd | First ISO14443-4 APDU request received from the PCD. |
[out] | FirstCmd_len | |
[in] | mempool | is used to store response data. Maybe NULL to use an internal mempool, in this case the data is only available until another command uses the internal mempool |