From c9370e6facea3484f5abf2c137f822f0a404baaf Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Fri, 9 Apr 2010 23:11:20 +0000 Subject: [PATCH] Prevent from running polling on hardware that does not support it. --- examples/nfc-poll.c | 4 ++++ libnfc/nfc.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 29542b4..3dbb59b 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -111,6 +111,10 @@ int main(int argc, const char* argv[]) nfc_target_t antTargets[2]; size_t szTargetFound; + if(pnd->nc == NC_PN531) { + // PN531 doesn't support hardware polling (InAutoPoll) + continue; + } printf("PN53x will poll during %ld ms\n", btPollNr * szTargetTypes * btPeriod * 150); bool res = nfc_initiator_poll_targets(pnd, &nttMifare, 1, btPollNr, btPeriod, antTargets, &szTargetFound); if( res ) { diff --git a/libnfc/nfc.c b/libnfc/nfc.c index efa68fe..3bd7e2f 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -587,6 +587,10 @@ nfc_initiator_poll_targets(const nfc_device_t* pnd, const byte_t btPollNr, const byte_t btPeriod, nfc_target_t* pntTargets, size_t* pszTargetFound) { + if(pnd->nc == NC_PN531) { + // errno = ENOSUPP + return false; + } // byte_t abtInAutoPoll[] = { 0xd4, 0x60, 0x0f, 0x01, 0x00 }; size_t szTxInAutoPoll = 4 + szTargetTypes; byte_t *pbtTxInAutoPoll = malloc( szTxInAutoPoll );