C API for BALTECH SDK

§ brp_I4CE_StartEmu()

brp_errcode brp_I4CE_StartEmu ( brp_protocol  protocol,
brp_buf  Snr,
unsigned  FWT,
unsigned  TimeoutPCD,
unsigned  TimeoutAPDU,
brp_buf  ATS,
size_t  ATS_len,
unsigned  AutoWTX,
brp_buf FirstCmd,
size_t *  FirstCmd_len,
brp_mempool mempool 
)

**This command is marked as deprecated as it is not supported by Baltech's SDK.

There is currently no alternative for this command.**

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_I4CE_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.

Two timeout parameters triggering two timers have to be specified for this command. The first timer, associated to the TimeoutPCD parameter, stops as soon as the first PCD command frame after the card selection as defined in ISO14443-3 is received. If the emulated PICC does not receive anything within TimeoutPCD , this command will return an BRP_I4CE_ErrIso144State status code, which indicates that the PICC did not receive the required protocol activation sequence to exchange ISO14443-4 APDUs. If a PCD frame is received before TimeoutPCD elapses, the second timer, associated to the TimeoutAPDU variable, is started. If this timer elapses before the reader receives the first protocol activation sequence and the first APDU, the BRP_I4CE_ErrTimeout status code is returned. Otherwise, the first APDU request is returned in the command's response.

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_I4CE_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 I4CE.StartEmu command and of all subsequent brp_I4CE_ExchangeInverseAPDU() commands. In practice, this allows to ignore the FWT limits, since the card emulation itself keeps the communication with the PCD alive.

Parameters
[in]protocolused to execute the command
[in]SnrCard serial number of the emulated PICC according to the ISO14443-3 specification (uid0, uid1, uid2, uid3).
[in]FWTFrame waiting time in ms. This is the maximum time the PCD waits for the next PICC response. If FWT is set to 0 the default frame waiting time of 77.328 ms will be applied.
[in]TimeoutPCDMaximum time (in ms) to wait for the first frame sent from the PCD. A value of 0xFFFF corresponds to an infinite time.
[in]TimeoutAPDUMaximum time (in ms) to wait for the first ISO14443-4 APDU after the first received PCD frame. A value of 0xFFFF corresponds to an infinite timeout.
[in]ATSATS (Historical Bytes) to use for card emulation.
[in]ATS_len
[in]AutoWTXEnable/disable automatic Waiting Time Extension (WTX).
[out]FirstCmdFirst ISO14443-4 APDU request received from the PCD.
[out]FirstCmd_len
[in]mempoolis 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
Deprecated:
This command may be removed in future!