[libnfc] push by yob...@gmail.com - nfc_initiator_target_is_present(): Support B2 ST SRx on 2014-02-07 00:11 GMT

2 views
Skip to first unread message

lib...@googlecode.com

unread,
Feb 6, 2014, 7:12:19 PM2/6/14
to libnfc-...@googlegroups.com
Revision: 1e4fe3bd2793
Author: Philippe Teuwen <yob...@gmail.com>
Date: Fri Feb 7 00:11:19 2014 UTC
Log: nfc_initiator_target_is_present(): Support B2 ST SRx

http://code.google.com/p/libnfc/source/detail?r=1e4fe3bd2793

Modified:
/libnfc/chips/pn53x.c

=======================================
--- /libnfc/chips/pn53x.c Thu Feb 6 23:53:35 2014 UTC
+++ /libnfc/chips/pn53x.c Fri Feb 7 00:11:19 2014 UTC
@@ -1963,11 +1963,34 @@
ret = ret2;
return ret;
}
+
+static int pn53x_ISO14443B_SR_is_present(struct nfc_device *pnd)
+{
+ int ret;
+ log_put(LOG_GROUP, LOG_CATEGORY,
NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): Ping B2 ST SRx");
+ // Sending Get_UID in raw: (EASY_FRAMING is already supposed to be false)
+ uint8_t abtCmd[1] = {0x0b};
+ int failures = 0;
+ while (failures < 2) {
+ if ((ret = nfc_initiator_transceive_bytes(pnd, abtCmd, sizeof(abtCmd),
NULL, 0, 300)) < 1) {
+ if ((ret == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte ==
0x01)) { // Timeout
+ ret = NFC_ETGRELEASED;
+ break;
+ } else { // Other errors can appear when card is tired-off, let's
try again
+ failures++;
+ }
+ } else {
+ ret = NFC_SUCCESS;
+ break;
+ }
+ }
+ return ret;
+}

static int pn53x_ISO14443B_CT_is_present(struct nfc_device *pnd)
{
int ret;
- log_put(LOG_GROUP, LOG_CATEGORY,
NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): Ping B2 ASK CT");
+ log_put(LOG_GROUP, LOG_CATEGORY,
NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): Ping B2 ASK CTx");
// Sending SELECT in raw: (EASY_FRAMING is already supposed to be false)
uint8_t abtCmd[3] = {0x9f};
memcpy(abtCmd + 1, CHIP_DATA(pnd)->current_target->nti.nci.abtUID, 2);
@@ -2035,10 +2058,12 @@
case NMT_ISO14443BI:
ret = pn53x_ISO14443B_I_is_present(pnd);
break;
+ case NMT_ISO14443B2SR:
+ ret = pn53x_ISO14443B_SR_is_present(pnd);
+ break;
case NMT_ISO14443B2CT:
ret = pn53x_ISO14443B_CT_is_present(pnd);
break;
- case NMT_ISO14443B2SR:
default:
log_put(LOG_GROUP, LOG_CATEGORY,
NFC_LOG_PRIORITY_DEBUG, "%s", "target_is_present(): card type not
supported");
ret = NFC_EDEVNOTSUPP;
Reply all
Reply to author
Forward
0 new messages