NFC card reading library. More...
Go to the source code of this file.
Data Structures | |
struct | NfcGenericEventEx |
Extended generic Nfc event type. More... | |
Typedefs | |
typedef struct NfcPoller | NfcPoller |
NfcPoller opaque type definition. | |
typedef NfcCommand(* | NfcGenericCallbackEx) (NfcGenericEventEx event, void *context) |
Extended generic Nfc event callback type. | |
Functions | |
NfcPoller * | nfc_poller_alloc (Nfc *nfc, NfcProtocol protocol) |
Allocate an NfcPoller instance. | |
void | nfc_poller_free (NfcPoller *instance) |
Delete an NfcPoller instance. | |
void | nfc_poller_start (NfcPoller *instance, NfcGenericCallback callback, void *context) |
Start an NfcPoller instance. | |
void | nfc_poller_start_ex (NfcPoller *instance, NfcGenericCallbackEx callback, void *context) |
Start an NfcPoller instance in extended mode. | |
void | nfc_poller_stop (NfcPoller *instance) |
Stop an NfcPoller instance. | |
bool | nfc_poller_detect (NfcPoller *instance) |
Detect whether there is a card supporting a particular protocol in the vicinity. | |
NfcProtocol | nfc_poller_get_protocol (const NfcPoller *instance) |
Get the protocol identifier an NfcPoller instance was created with. | |
const NfcDeviceData * | nfc_poller_get_data (const NfcPoller *instance) |
Get the data that was that was gathered during the reading process. | |
NFC card reading library.
Once started, it will try to activate and read a card using the designated protocol, which is usually obtained by creating and starting an NfcScanner first.
When running, NfcPoller 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.
typedef NfcCommand(* NfcGenericCallbackEx) (NfcGenericEventEx event, void *context) |
Extended generic Nfc event callback type.
A function of this type must be passed as the callback parameter upon extended start of a poller.
[in] | event | Nfc extended generic event, passed by value, complete with protocol type and data. |
[in,out] | context | pointer to the user-specific context (set when starting a poller/listener instance). |
NfcPoller * nfc_poller_alloc | ( | Nfc * | nfc, |
NfcProtocol | protocol ) |
Allocate an NfcPoller instance.
[in] | nfc | pointer to an Nfc instance. |
[in] | protocol | identifier of the protocol to be used. |
bool nfc_poller_detect | ( | NfcPoller * | instance | ) |
Detect whether there is a card supporting a particular protocol in the vicinity.
The behaviour of this function is protocol-defined, in general, it will do whatever is necessary to determine whether a card supporting the current protocol is in the vicinity and whether it is functioning normally.
It is used automatically inside NfcScanner, so there is usually no need to call it explicitly.
[in,out] | instance | pointer to the instance to perform the detection with. |
void nfc_poller_free | ( | NfcPoller * | instance | ) |
Delete an NfcPoller instance.
[in,out] | instance | pointer to the instance to be deleted. |
const NfcDeviceData * nfc_poller_get_data | ( | const NfcPoller * | instance | ) |
Get the data that was that was gathered during the reading process.
[in] | instance | pointer to the instance to be queried. |
NfcProtocol nfc_poller_get_protocol | ( | const NfcPoller * | instance | ) |
Get the protocol identifier an NfcPoller instance was created with.
[in] | instance | pointer to the instance to be queried. |
void nfc_poller_start | ( | NfcPoller * | instance, |
NfcGenericCallback | callback, | ||
void * | context ) |
Start an NfcPoller instance.
The callback logic is protocol-specific, so it cannot be described here in detail. However, the callback return value ALWAYS determines what the poller 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_poller_start_ex | ( | NfcPoller * | instance, |
NfcGenericCallbackEx | callback, | ||
void * | context ) |
Start an NfcPoller instance in extended mode.
When nfc poller is started in extended mode, callback will be called with parent protocol events and protocol instance. This mode enables to make custom poller state machines.
[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_poller_stop | ( | NfcPoller * | instance | ) |
Stop an NfcPoller instance.
The reading process can be stopped explicitly (the other way is via the callback return value).
[in,out] | instance | pointer to the instance to be stopped. |