libnfc
1.7.1
|
Functions | |
int | nfc_initiator_init (nfc_device *pnd) |
Initialize NFC device as initiator (reader) | |
int | nfc_initiator_init_secure_element (nfc_device *pnd) |
Initialize NFC device as initiator with its secure element initiator (reader) | |
int | nfc_initiator_select_passive_target (nfc_device *pnd, const nfc_modulation nm, const uint8_t *pbtInitData, const size_t szInitData, nfc_target *pnt) |
Select a passive or emulated tag. | |
int | nfc_initiator_list_passive_targets (nfc_device *pnd, const nfc_modulation nm, nfc_target ant[], const size_t szTargets) |
List passive or emulated tags. | |
int | nfc_initiator_poll_target (nfc_device *pnd, const nfc_modulation *pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target *pnt) |
Polling for NFC targets. | |
int | nfc_initiator_select_dep_target (nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout) |
Select a target and request active or passive mode for D.E.P. (Data Exchange Protocol) | |
int | nfc_initiator_poll_dep_target (struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout) |
Poll a target and request active or passive mode for D.E.P. (Data Exchange Protocol) | |
int | nfc_initiator_transceive_bytes (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, int timeout) |
Send data to target then retrieve data from target. | |
int | nfc_initiator_transceive_bits (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar) |
Transceive raw bit-frames to a target. | |
int | nfc_initiator_transceive_bytes_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, uint32_t *cycles) |
Send data to target then retrieve data from target. | |
int | nfc_initiator_target_is_present (nfc_device *pnd, const nfc_target *pnt) |
Check target presence. | |
int | nfc_initiator_transceive_bits_timed (nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar, uint32_t *cycles) |
Transceive raw bit-frames to a target. |
This page details how to act as "reader".
int nfc_initiator_init | ( | nfc_device * | pnd | ) |
Initialize NFC device as initiator (reader)
pnd | nfc_device struct pointer that represent currently used device |
The NFC device is configured to function as RFID reader. After initialization it can be used to communicate to passive RFID tags and active NFC devices. The reader will act as initiator to communicate peer 2 peer (NFCIP) to other active NFC devices.
int nfc_initiator_init_secure_element | ( | nfc_device * | pnd | ) |
Initialize NFC device as initiator with its secure element initiator (reader)
pnd | nfc_device struct pointer that represent currently used device |
The NFC device is configured to function as secure element reader. After initialization it can be used to communicate with the secure element.
int nfc_initiator_list_passive_targets | ( | nfc_device * | pnd, |
const nfc_modulation | nm, | ||
nfc_target | ant[], | ||
const size_t | szTargets | ||
) |
List passive or emulated tags.
pnd | nfc_device struct pointer that represent currently used device | |
nm | desired modulation | |
[out] | ant | array of nfc_target that will be filled with targets info |
szTargets | size of ant (will be the max targets listed) |
The NFC device will try to find the available passive tags. Some NFC devices are capable to emulate passive tags. The standards (ISO18092 and ECMA-340) describe the modulation that can be used for reader to passive communications. The chip needs to know with what kind of tag it is dealing with, therefore the initial modulation and speed (106, 212 or 424 kbps) should be supplied.
int nfc_initiator_poll_dep_target | ( | struct nfc_device * | pnd, |
const nfc_dep_mode | ndm, | ||
const nfc_baud_rate | nbr, | ||
const nfc_dep_info * | pndiInitiator, | ||
nfc_target * | pnt, | ||
const int | timeout | ||
) |
Poll a target and request active or passive mode for D.E.P. (Data Exchange Protocol)
pnd | nfc_device struct pointer that represent currently used device | |
ndm | desired D.E.P. mode (NDM_ACTIVE or NDM_PASSIVE for active, respectively passive mode) | |
nbr | desired baud rate | |
ndiInitiator | pointer nfc_dep_info struct that contains NFCID3 and General Bytes to set to the initiator device (optionnal, can be NULL) | |
[out] | pnt | is a nfc_target struct pointer where target information will be put. |
timeout | in milliseconds |
The NFC device will try to find an available D.E.P. target. The standards (ISO18092 and ECMA-340) describe the modulation that can be used for reader to passive communications.
int nfc_initiator_poll_target | ( | nfc_device * | pnd, |
const nfc_modulation * | pnmModulations, | ||
const size_t | szModulations, | ||
const uint8_t | uiPollNr, | ||
const uint8_t | uiPeriod, | ||
nfc_target * | pnt | ||
) |
Polling for NFC targets.
pnd | nfc_device struct pointer that represent currently used device |
pnmModulations | desired modulations |
szModulations | size of pnmModulations |
uiPollNr | specifies the number of polling (0x01 – 0xFE: 1 up to 254 polling, 0xFF: Endless polling) |
uiPeriod | indicates the polling period in units of 150 ms (0x01 – 0x0F: 150ms – 2.25s) |
[out] | pnt | pointer on nfc_target (over)writable struct |
int nfc_initiator_select_dep_target | ( | nfc_device * | pnd, |
const nfc_dep_mode | ndm, | ||
const nfc_baud_rate | nbr, | ||
const nfc_dep_info * | pndiInitiator, | ||
nfc_target * | pnt, | ||
const int | timeout | ||
) |
Select a target and request active or passive mode for D.E.P. (Data Exchange Protocol)
pnd | nfc_device struct pointer that represent currently used device | |
ndm | desired D.E.P. mode (NDM_ACTIVE or NDM_PASSIVE for active, respectively passive mode) | |
nbr | desired baud rate | |
ndiInitiator | pointer nfc_dep_info struct that contains NFCID3 and General Bytes to set to the initiator device (optionnal, can be NULL) | |
[out] | pnt | is a nfc_target struct pointer where target information will be put. |
timeout | in milliseconds |
The NFC device will try to find an available D.E.P. target. The standards (ISO18092 and ECMA-340) describe the modulation that can be used for reader to passive communications.
If timeout equals to 0, the function blocks indefinitely (until an error is raised or function is completed) If timeout equals to -1, the default timeout will be used
int nfc_initiator_select_passive_target | ( | nfc_device * | pnd, |
const nfc_modulation | nm, | ||
const uint8_t * | pbtInitData, | ||
const size_t | szInitData, | ||
nfc_target * | pnt | ||
) |
Select a passive or emulated tag.
pnd | nfc_device struct pointer that represent currently used device |
nm | desired modulation |
pbtInitData | optional initiator data, NULL for using the default values. |
szInitData | length of initiator data pbtInitData. |
[out] | pnt | nfc_target struct pointer which will filled if available |
The NFC device will try to find one available passive tag or emulated tag.
The chip needs to know with what kind of tag it is dealing with, therefore the initial modulation and speed (106, 212 or 424 kbps) should be supplied.
int nfc_initiator_target_is_present | ( | nfc_device * | pnd, |
const nfc_target * | pnt | ||
) |
Check target presence.
pnd | nfc_device struct pointer that represent currently used device |
pnt | a nfc_target struct pointer where desired target information was stored (optionnal, can be NULL). This function tests if nfc_target (or last selected tag if NULL) is currently present on NFC device. |
int nfc_initiator_transceive_bits | ( | nfc_device * | pnd, |
const uint8_t * | pbtTx, | ||
const size_t | szTxBits, | ||
const uint8_t * | pbtTxPar, | ||
uint8_t * | pbtRx, | ||
const size_t | szRx, | ||
uint8_t * | pbtRxPar | ||
) |
Transceive raw bit-frames to a target.
pnd | nfc_device struct pointer that represents currently used device |
pbtTx | contains a byte array of the frame that needs to be transmitted. |
szTxBits | contains the length in bits. |
pbtTxPar | parameter contains a byte array of the corresponding parity bits needed to send per byte. |
[out] | pbtRx | response from the target |
szRx | size of pbtRx (Will return NFC_EOVFLOW if RX exceeds this size) | |
[out] | pbtRxPar | parameter contains a byte array of the corresponding parity bits |
The NFC device (configured as initiator) will transmit low-level messages where only the modulation is handled by the PN53x chip. Construction of the frame (data, CRC and parity) is completely done by libnfc. This can be very useful for testing purposes. Some protocols (e.g. MIFARE Classic) require to violate the ISO14443-A standard by sending incorrect parity and CRC bytes. Using this feature you are able to simulate these frames.
int nfc_initiator_transceive_bits_timed | ( | nfc_device * | pnd, |
const uint8_t * | pbtTx, | ||
const size_t | szTxBits, | ||
const uint8_t * | pbtTxPar, | ||
uint8_t * | pbtRx, | ||
const size_t | szRx, | ||
uint8_t * | pbtRxPar, | ||
uint32_t * | cycles | ||
) |
Transceive raw bit-frames to a target.
This function is similar to nfc_initiator_transceive_bits() with the following differences:
Timer control: By default timer configuration tries to maximize the precision, which also limits the maximum cycles count before saturation/timeout. E.g. with PN53x it can count up to 65535 cycles, so about 4.8ms, with a precision of about 73ns.
false
. false
. true
(the default value). int nfc_initiator_transceive_bytes | ( | nfc_device * | pnd, |
const uint8_t * | pbtTx, | ||
const size_t | szTx, | ||
uint8_t * | pbtRx, | ||
const size_t | szRx, | ||
int | timeout | ||
) |
Send data to target then retrieve data from target.
pnd | nfc_device struct pointer that represents currently used device | |
pbtTx | contains a byte array of the frame that needs to be transmitted. | |
szTx | contains the length in bytes. | |
[out] | pbtRx | response from the target |
szRx | size of pbtRx (Will return NFC_EOVFLOW if RX exceeds this size) | |
timeout | in milliseconds |
The NFC device (configured as initiator) will transmit the supplied bytes (pbtTx) to the target. It waits for the response and stores the received bytes in the pbtRx byte array.
If NP_EASY_FRAMING option is disabled the frames will sent and received in raw mode: PN53x will not handle input neither output data.
The parity bits are handled by the PN53x chip. The CRC can be generated automatically or handled manually. Using this function, frames can be communicated very fast via the NFC initiator to the tag.
Tests show that on average this way of communicating is much faster than using the regular driver/middle-ware (often supplied by manufacturers).
true
(the default value).If timeout equals to 0, the function blocks indefinitely (until an error is raised or function is completed) If timeout equals to -1, the default timeout will be used
int nfc_initiator_transceive_bytes_timed | ( | nfc_device * | pnd, |
const uint8_t * | pbtTx, | ||
const size_t | szTx, | ||
uint8_t * | pbtRx, | ||
const size_t | szRx, | ||
uint32_t * | cycles | ||
) |
Send data to target then retrieve data from target.
pnd | nfc_device struct pointer that represents currently used device | |
pbtTx | contains a byte array of the frame that needs to be transmitted. | |
szTx | contains the length in bytes. | |
[out] | pbtRx | response from the target |
szRx | size of pbtRx (Will return NFC_EOVFLOW if RX exceeds this size) |
This function is similar to nfc_initiator_transceive_bytes() with the following differences:
Timer control: By default timer configuration tries to maximize the precision, which also limits the maximum cycles count before saturation/timeout. E.g. with PN53x it can count up to 65535 cycles, so about 4.8ms, with a precision of about 73ns.
false
. true
(the default value).