iso14443_cascade_uid(byte[] abtUID, int szUID, ref byte[] pbtCascadedUID, out int pszCascadedUID) { switch (szUID) { case 7: pbtCascadedUID[0] = 0x88; MiscTool.memcpy(pbtCascadedUID, 1, abtUID, 0, 7); pszCascadedUID = 8; break; case 10: pbtCascadedUID[0] = 0x88; MiscTool.memcpy(pbtCascadedUID, 1, abtUID, 0, 3); pbtCascadedUID[4] = 0x88; MiscTool.memcpy(pbtCascadedUID, 5, abtUID, 3, 7); pszCascadedUID = 12; break; case 4: default: MiscTool.memcpy(pbtCascadedUID, 0, abtUID, 0, szUID); pszCascadedUID = szUID; break; } }
iso14443a_locate_historical_bytes(byte[] pbtAts, int szAts, out int pszTk) { if (szAts != 0) { int offset = 1; if (0 != (pbtAts[0] & 0x10)) { // TA offset++; } if (0 != (pbtAts[0] & 0x20)) { // TB offset++; } if (0 != (pbtAts[0] & 0x40)) { // TC offset++; } if (szAts > offset) { pszTk = (szAts - offset); return(MiscTool.SubBytes(pbtAts, offset)); } } pszTk = 0; return(null); }
public static int nfc_initiator_list_passive_targets(nfc_device pnd, nfc_modulation nm, ref nfc_target[] ant /*, int szTargets*/) { nfc_target nt = new nfc_target(); int szTargetFound = 0; byte[] pbtInitData = null; //int szInitDataLen = 0; int res = 0; pnd.last_error = 0; // Let the reader only try once to find a tag bool bInfiniteSelect = pnd.bInfiniteSelect; if ((res = nfc_device_set_property_bool(pnd, nfc_property.NP_INFINITE_SELECT, false)) < 0) { return(res); } pbtInitData = prepare_initiator_data(nm); //szInitDataLen = pbtInitData.Length; while (nfc_initiator_select_passive_target(pnd, nm, pbtInitData, pbtInitData.Length, /*out*/ nt) > 0) { int i; bool seen = false; // Check if we've already seen this tag for (i = 0; i < szTargetFound; i++) { if (MiscTool.CompareType <nfc_target>(ant[i], nt)) { seen = true; } } if (seen) { break; } ant[szTargetFound] = nt; szTargetFound++; if (ant.Length == szTargetFound) { break; } nfc_initiator_deselect_target(pnd); // deselect has no effect on FeliCa and Jewel cards so we'll stop after one... // ISO/IEC 14443 B' cards are polled at 100% probability so it's not possible to detect correctly two cards at the same time if ((nm.nmt == nfc_modulation_type.NMT_FELICA) || (nm.nmt == nfc_modulation_type.NMT_JEWEL) || (nm.nmt == nfc_modulation_type.NMT_ISO14443BI) || (nm.nmt == nfc_modulation_type.NMT_ISO14443B2SR) || (nm.nmt == nfc_modulation_type.NMT_ISO14443B2CT)) { break; } } if (bInfiniteSelect) { if ((res = nfc_device_set_property_bool(pnd, nfc_property.NP_INFINITE_SELECT, true)) < 0) { return(res); } } return(szTargetFound); }