NFC card emulation library. More...
Go to the source code of this file.
Typedefs | |
typedef struct NfcListener | NfcListener |
NfcListener opaque type definition. | |
Functions | |
NfcListener * | nfc_listener_alloc (Nfc *nfc, NfcProtocol protocol, const NfcDeviceData *data) |
Allocate an NfcListener instance. | |
void | nfc_listener_free (NfcListener *instance) |
Delete an NfcListener instance. | |
void | nfc_listener_start (NfcListener *instance, NfcGenericCallback callback, void *context) |
Start an NfcListener instance. | |
void | nfc_listener_stop (NfcListener *instance) |
Stop an NfcListener instance. | |
NfcProtocol | nfc_listener_get_protocol (const NfcListener *instance) |
Get the protocol identifier an NfcListener instance was created with. | |
const NfcDeviceData * | nfc_listener_get_data (const NfcListener *instance, NfcProtocol protocol) |
Get the data that was that was provided for emulation. | |
NFC card emulation library.
Once started, it will respond to supported commands from an NFC reader, thus imitating (or emulating) an NFC card. The responses will depend on the data that was supplied to the listener, so various card types and different cards of the same type can be emulated.
It will also make any changes necessary to the emulated data in response to the reader commands if the protocol supports it.
When running, NfcListener will generate events that the calling code must handle by providing a callback function. The events passed to the callback are protocol-specific and may include errors, state changes, data reception, special function requests and more.
NfcListener * nfc_listener_alloc | ( | Nfc * | nfc, |
NfcProtocol | protocol, | ||
const NfcDeviceData * | data ) |
Allocate an NfcListener instance.
[in] | nfc | pointer to an Nfc instance. |
[in] | protocol | identifier of the protocol to be used. |
[in] | data | pointer to the data to use during emulation. |
void nfc_listener_free | ( | NfcListener * | instance | ) |
Delete an NfcListener instance.
[in,out] | instance | pointer to the instance to be deleted. |
const NfcDeviceData * nfc_listener_get_data | ( | const NfcListener * | instance, |
NfcProtocol | protocol ) |
Get the data that was that was provided for emulation.
The protocol identifier passed as the protocol parameter MUST match the one stored in the instance, otherwise a crash will occur. This is to improve type safety.
[in] | instance | pointer to the instance to be queried. |
[in] | protocol | assumed protocol identifier of the data to be retrieved. |
NfcProtocol nfc_listener_get_protocol | ( | const NfcListener * | instance | ) |
Get the protocol identifier an NfcListener instance was created with.
[in] | instance | pointer to the instance to be queried. |
void nfc_listener_start | ( | NfcListener * | instance, |
NfcGenericCallback | callback, | ||
void * | context ) |
Start an NfcListener instance.
The callback logic is protocol-specific, so it cannot be described here in detail. However, the callback return value ALWAYS determines what the listener should do next: to continue whatever it was doing prior to the callback run or to stop.
[in,out] | instance | pointer to the instance to be started. |
[in] | callback | pointer to a user-defined callback function which will receive events. |
[in] | context | pointer to a user-specific context (will be passed to the callback). |
void nfc_listener_stop | ( | NfcListener * | instance | ) |
Stop an NfcListener instance.
The emulation process can be stopped explicitly (the other way is via the callback return value).
[in,out] | instance | pointer to the instance to be stopped. |