19static const char *
TAG =
"pn532_adapter";
34 esp_err_t ret = ESP_FAIL;
39 ESP_LOGE(
TAG,
"pn532_init failed: %s", esp_err_to_name(ret));
62 uint8_t *response, uint8_t &responseLen)
67 uint16_t len =
static_cast<uint16_t
>(responseLen);
69 responseLen =
static_cast<uint8_t
>((len >
static_cast<uint16_t
>(UINT8_MAX))
70 ?
static_cast<uint16_t
>(UINT8_MAX) : len);
77 uint8_t *response, uint16_t &responseLen)
97 uint32_t version = 0U;
103 _logger.println(
"PN532 firmware query failed");
void resetReader() override
Release the currently selected NFC target.
pn532_t _dev
PN532 device state (owned by this adapter).
bool printFirmwareVersion() override
Query and log the PN532 firmware version.
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).
PN532Adapter(const pn532_config_t &config, CW_Logger &logger)
Construct the adapter with the given PN532 configuration.
pn532_config_t _config
Stored configuration forwarded to pn532_init.
bool inListPassiveTarget() override
Scan for a passive ISO 14443-A card.
bool begin() override
Initialise the PN532 driver and configure the SAM.
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).
CW_Logger & _logger
Logger reference for printFirmwareVersion.
bool _initialized
true after a successful pn532_init call.
static const char *const TAG
esp_err_t pn532_init(pn532_t *dev, const pn532_config_t *config)
Initialise the PN532 and bring it to a ready state.
uint32_t pn532_read_passive_target_id(pn532_t *dev, uint8_t cardbaudrate)
Scan for a passive ISO 14443-A card and return its UID.
bool pn532_send_apdu(pn532_t *dev, const uint8_t *apdu, uint8_t apdu_len, uint8_t *response, uint16_t *response_len)
Exchange a single ISO-DEP APDU with the currently selected card.
uint32_t pn532_get_firmware_version(pn532_t *dev)
Query the PN532 firmware version.
#define PN532_MIFARE_ISO14443A
Baud-rate selector for ISO 14443-A (Mifare) cards passed to pn532_read_passive_target_id.
bool pn532_release_target(pn532_t *dev)
Release the currently selected NFC target.
static const uint32_t FW_BYTE_MASK
static const uint32_t FW_IC_SHIFT
static const uint32_t FW_REV_SHIFT
static const uint32_t FW_VER_SHIFT
Self-contained CW_NfcTransport adapter that owns its pn532_t handle.
Compile-time configuration passed to pn532_init.