|
cryptnox-sdk-esp32 1.0.0
ESP32 SDK for Cryptnox Hardware Wallet
|
Self-contained CW_NfcTransport that owns its pn532_t instance. More...
#include <pn532_adapter.h>
Public Member Functions | |
| PN532Adapter (const pn532_config_t &config, CW_Logger &logger) | |
| Construct the adapter with the given PN532 configuration. | |
| bool | begin () override |
| Initialise the PN532 driver and configure the SAM. | |
| bool | inListPassiveTarget () override |
| Scan for a passive ISO 14443-A card. | |
| bool | sendAPDU (const uint8_t *apdu, uint8_t apduLen, uint8_t *response, uint8_t &responseLen) override |
| Exchange one ISO-DEP APDU with the selected card (short response). | |
| bool | sendAPDULarge (const uint8_t *apdu, uint8_t apduLen, uint8_t *response, uint16_t &responseLen) override |
| Exchange one ISO-DEP APDU with the selected card (large response). | |
| void | resetReader () override |
| Release the currently selected NFC target. | |
| bool | printFirmwareVersion () override |
| Query and log the PN532 firmware version. | |
Private Attributes | |
| pn532_config_t | _config |
| Stored configuration forwarded to pn532_init. | |
| pn532_t | _dev |
| PN532 device state (owned by this adapter). | |
| CW_Logger & | _logger |
| Logger reference for printFirmwareVersion. | |
| bool | _initialized |
true after a successful pn532_init call. | |
Self-contained CW_NfcTransport that owns its pn532_t instance.
Unlike Pn532NfcTransport (which takes a pre-initialised pn532_t pointer), PN532Adapter accepts a pn532_config_t at construction time and calls pn532_init internally on the first begin() call. This is convenient when the NFC reader is the only SPI/I²C device and the application does not need to manage the bus lifetime separately.
_dev holds raw SPI/I²C handles that cannot be duplicated.Definition at line 54 of file pn532_adapter.h.
| PN532Adapter::PN532Adapter | ( | const pn532_config_t & | config, |
| CW_Logger & | logger ) |
Construct the adapter with the given PN532 configuration.
Stores the configuration and logger for use during begin(). The PN532 driver is not initialised at this point.
| [in] | config | Transport and pin configuration forwarded to pn532_init on the first begin() call. |
| [in] | logger | Logger used by printFirmwareVersion. |
Definition at line 27 of file pn532_adapter.cpp.
References _config, _dev, _initialized, and _logger.
|
override |
Initialise the PN532 driver and configure the SAM.
Calls pn532_init (if not already done) followed by pn532_sam_config. Idempotent — repeated calls after a successful init are no-ops that return true.
true on success, false if pn532_init or pn532_sam_config fails. Definition at line 32 of file pn532_adapter.cpp.
References _config, _dev, _initialized, pn532_init(), and TAG.
|
override |
Scan for a passive ISO 14443-A card.
true if a card was detected in the RF field, false if no card is present or a communication error occurred. Definition at line 48 of file pn532_adapter.cpp.
References _dev, _initialized, PN532_MIFARE_ISO14443A, and pn532_read_passive_target_id().
|
override |
Query and log the PN532 firmware version.
Prints "PN5xx firmware vX.Y" via the injected logger.
true if the PN532 returned a valid version, false on communication failure or if the adapter has not been initialised. Definition at line 95 of file pn532_adapter.cpp.
References _dev, _initialized, _logger, FW_BYTE_MASK, FW_IC_SHIFT, FW_REV_SHIFT, FW_VER_SHIFT, and pn532_get_firmware_version().
|
override |
Release the currently selected NFC target.
Calls pn532_release_target to drop the logical link so the PN532 can list a new target on the next inListPassiveTarget call.
Definition at line 88 of file pn532_adapter.cpp.
References _dev, _initialized, and pn532_release_target().
|
override |
Exchange one ISO-DEP APDU with the selected card (short response).
| [in] | apdu | APDU command bytes (must not be NULL). |
| [in] | apduLen | Length of apdu (≤ PN532_MAX_APDU_LEN). |
| [out] | response | Caller-allocated buffer for the DataOut bytes. |
| [in,out] | responseLen | In: capacity of response. Out: number of DataOut bytes written, capped at UINT8_MAX on overflow. |
true on success, false on transport or card error.Definition at line 61 of file pn532_adapter.cpp.
References _dev, _initialized, and pn532_send_apdu().
|
override |
Exchange one ISO-DEP APDU with the selected card (large response).
Use when the card's DataOut may exceed 255 bytes (e.g. GET_MANUFACTURER_CERTIFICATE).
| [in] | apdu | APDU command bytes (must not be NULL). |
| [in] | apduLen | Length of apdu (≤ PN532_MAX_APDU_LEN). |
| [out] | response | Caller-allocated buffer for the DataOut bytes. |
| [in,out] | responseLen | In: capacity of response in bytes. Out: number of DataOut bytes actually written. |
true on success, false on transport or card error.Definition at line 76 of file pn532_adapter.cpp.
References _dev, _initialized, and pn532_send_apdu().
|
private |
Stored configuration forwarded to pn532_init.
Definition at line 141 of file pn532_adapter.h.
Referenced by begin(), and PN532Adapter().
|
private |
PN532 device state (owned by this adapter).
Definition at line 142 of file pn532_adapter.h.
Referenced by begin(), inListPassiveTarget(), PN532Adapter(), printFirmwareVersion(), resetReader(), sendAPDU(), and sendAPDULarge().
|
private |
true after a successful pn532_init call.
Definition at line 144 of file pn532_adapter.h.
Referenced by begin(), inListPassiveTarget(), PN532Adapter(), printFirmwareVersion(), resetReader(), sendAPDU(), and sendAPDULarge().
|
private |
Logger reference for printFirmwareVersion.
Definition at line 143 of file pn532_adapter.h.
Referenced by PN532Adapter(), and printFirmwareVersion().