[solved] having trouble reading simple NDEF records from NFCA Passive T4T cards
ST25R3911B, using the ST25RFAL001 and the NDEF library v1.0.4. I'm using the read example found in the ndef.chm file. It's detecting the card fine, but ndefPollerNdefDetect() is returning 0x5 (invalid request or requested function can't be executed at this time). Every very rare once in a while I'll get the same return code from ndefPollerReadRawMessage() so I know I'm close.
The software loop is very small. It is being called in an endless loop with HAL_Delay(1), so it runs every 1msec.
int nfc_loop(void)
{
uint32_t now;
static uint32_t next_tick;
rfalNfcState nfc_state;
static uint8_t buf[256];
int err, nread;
rfalNfcWorker();
now = HAL_GetTick();
nfc_state = rfalNfcGetState();
if (rfalNfcIsDevActivated(nfc_state)) {
rfalNfcDevice *nfcDevice;
rfalNfcGetActiveDevice(&nfcDevice);
if ((err = ndefPollerContextInitialization(&ndefCtx, nfcDevice)) != ERR_NONE) {
platformLog("ndefPollerContextInitialization returned (%d)\n", err);
return;
}
if ((err = ndefPollerNdefDetect(&ndefCtx, NULL)) != ERR_NONE) {
platformLog("ndefPollerNdefDetect returned (%d)\n", err);
return;
}
memset(buf, 0, sizeof(buf));
if ((err = ndefPollerReadRawMessage(&ndefCtx, buf, sizeof(buf), &nread)) != ERR_NONE) {
platformLog("ndefPollerReadRawMessage returned (%d)\n", err);
return;
}
platformLog("success, read %d bytes\n", nread);
}
}Digging a little deeper, it looks like ndefT4TReadAndParseCCFile() is able to successfully select the file to read, but ndefT4TPollerReadBinary() does not get a isoDepAPDU status that it likes. It receives 17 bytes from the card (00 00 00 00 0F 0F 0F 20 00 FF 00 36 04 04 06 00 01) but the status word encoded in those 17 bytes is 0x0000, not 0x9000 so the call fails.
I'm lost as to how to go about debugging this; the card is returning data, and other calls seem to work (the expected return value of 0x9000 is seen). If I use this exact same card with an iPhone reader, it correctly shows the NDEF TXT record (NFC well known type 0x01, record type T (0x54) , 19 bytes total with raw values 0x02 0x65 0x6e 0x63 0x65 0x61 0x30 0x30 0x30 0x30 0x30 0x30 0x31 0x65 0x38).
How do I go about debugging this? I should add the relevant bits of the platform header file which configures the RFAL and NDEF libraries:
#define RFAL_FEATURE_LISTEN_MODE true /*!< Enable/Disable RFAL support for Listen Mode */
#define RFAL_FEATURE_WAKEUP_MODE false /*!< Enable/Disable RFAL support for the Wake-Up mode */
#define RFAL_FEATURE_NFCA true /*!< Enable/Disable RFAL support for NFC-A (ISO14443A) */
#define RFAL_FEATURE_NFCB false /*!< Enable/Disable RFAL support for NFC-B (ISO14443B) */
#define RFAL_FEATURE_NFCF false /*!< Enable/Disable RFAL support for NFC-F (FeliCa) */
#define RFAL_FEATURE_NFCV false /*!< Enable/Disable RFAL support for NFC-V (ISO15693) */
#define RFAL_FEATURE_*** false /*!< Enable/Disable RFAL support for *** (Topaz) */
#define RFAL_FEATURE_T2T false /*!< Enable/Disable RFAL support for T2Tn */
#define RFAL_FEATURE_T3T false /*!< Enable/Disable RFAL support for T3Tn */
#define RFAL_FEATURE_T4T true /*!< Enable/Disable RFAL support for T4Tn */
#define RFAL_FEATURE_T5T false /*!< Enable/Disable RFAL support for T5Tn */
#define RFAL_FEATURE_ST25TB false /*!< Enable/Disable RFAL support for ST25TB */
#define RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG false /*!< Enable/Disable Analog Configs to be dynamically updated (RAM) */
#define RFAL_FEATURE_DYNAMIC_POWER false /*!< Enable/Disable RFAL dynamic power support */
#define RFAL_FEATURE_ISO_DEP true /*!< Enable/Disable RFAL support for ISO-DEP (ISO14443-4) */
#define RFAL_FEATURE_ISO_DEP_POLL true /*!< Enable/Disable RFAL support for Poller mode (PCD) ISO-DEP (ISO14443-4) */
#define RFAL_FEATURE_ISO_DEP_LISTEN false /*!< Enable/Disable RFAL support for Listen mode (PICC) ISO-DEP (ISO14443-4) */
#define RFAL_FEATURE_NFC_DEP false /*!< Enable/Disable RFAL support for NFC-DEP (NFCIP1/P2P) */
#define RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN 512 /*!< ISO-DEP I-Block max length. Please use values as defined by rfalIsoDepFSx */
#define RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN 512 /*!< ISO-DEP APDU max length. Please use multiples of I-Block max length */
#define RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN 128
#define RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN 128
#define RFAL_FEATURE_NFC_RF_BUF_LEN 512Eventually I need to shrink this down to the absolute bare minimum, but for now I just need to be able to read these simple text records.
