Abstract interface definitions for the NFC poller system. More...
Go to the source code of this file.
Data Structures | |
struct | NfcPollerBase |
Generic NFC poller interface. More... | |
Typedefs | |
typedef NfcGenericInstance *(* | NfcPollerAlloc) (NfcGenericInstance *base_poller) |
Allocate a protocol-specific poller instance. | |
typedef void(* | NfcPollerFree) (NfcGenericInstance *instance) |
Delete a protocol-specific poller instance. | |
typedef void(* | NfcPollerSetCallback) (NfcGenericInstance *poller, NfcGenericCallback callback, void *context) |
Set the callback function to handle events emitted by the poller instance. | |
typedef NfcCommand(* | NfcPollerRun) (NfcGenericEvent event, void *context) |
Activate and read a supported NFC card. | |
typedef bool(* | NfcPollerDetect) (NfcGenericEvent event, void *context) |
Determine whether there is a supported card in the vicinity. | |
typedef const NfcDeviceData *(* | NfcPollerGetData) (const NfcGenericInstance *instance) |
Get the data that was that was gathered during the reading process. | |
Abstract interface definitions for the NFC poller system.
This file is an implementation detail. It must not be included in any public API-related headers.
typedef NfcGenericInstance *(* NfcPollerAlloc) (NfcGenericInstance *base_poller) |
Allocate a protocol-specific poller instance.
For base pollers pass a pointer to an instance of type Nfc as the base_poller parameter, otherwise it must be a pointer to another poller instance (compare iso14443_3a/iso14443_3a_poller.c and iso14443_4a/iso14443_4a_poller.c).
[in] | base_poller | pointer to the parent poller instance. |
typedef bool(* NfcPollerDetect) (NfcGenericEvent event, void *context) |
Determine whether there is a supported card in the vicinity.
The behaviour is mostly the same as of NfcPollerRun, with the difference in the procedure and return value. The procedure implemented in this function must do whatever it needs to unambigiously determine whether a supported and valid NFC card is in the vicinity.
Like the previously described NfcPollerRun, it is called automatically by the NfcPoller implementation, so there is no need to call it explicitly.
[in] | event | protocol-specific event passed by the parent poller instance. |
[in,out] | context | pointer to the protocol-specific poller instance. |
typedef void(* NfcPollerFree) (NfcGenericInstance *instance) |
Delete a protocol-specific poller instance.
[in,out] | instance | pointer to the instance to be deleted. |
typedef const NfcDeviceData *(* NfcPollerGetData) (const NfcGenericInstance *instance) |
Get the data that was that was gathered during the reading process.
[in] | instance | pointer to the protocol-specific poller instance. |
typedef NfcCommand(* NfcPollerRun) (NfcGenericEvent event, void *context) |
Activate and read a supported NFC card.
Ths function is passed to the parent poller's ${POLLER_NAME}_set_callback function as the callback parameter. This is done automatically by the NfcPoller implementation based on the protocol hierarchy defined in nfc_protocol.c, so there is no need to call it explicitly.
Thus, it will be called each time the parent poller emits an event. Usually it happens only after the parent poller has successfully completed its job.
Example for an application reading a card with a compound (non-base) protocol (simplified):
The base poller receives events directly from an Nfc instance, from which they are propagated as needed to however many other pollers there are in the current hierarchy.
This function can be thought of as the poller's "main loop" function. Depending on the particular poller implementation, it may perform actions such as reading and writing to an NFC card, state changes and control of the parent poller.
[in] | event | protocol-specific event passed by the parent poller instance. |
[in,out] | context | pointer to the protocol-specific poller instance. |
typedef void( * NfcPollerSetCallback) (NfcGenericInstance *poller, NfcGenericCallback callback, void *context) |
Set the callback function to handle events emitted by the poller instance.
[in,out] | poller | pointer to the protocol-specific poller instance. |
[in] | callback | pointer to the user-defined callback function which will receive events. |
[in] | context | pointer to the user-specific context (will be passed to the callback). |