Merge pull request #688 from gentilkiwi/master

pn53x initiator set registers for ISO14443B-2 ST SRx
This commit is contained in:
Philippe Teuwen 2023-02-13 21:00:49 +01:00 committed by GitHub
commit 42de50f2b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 33 deletions

View file

@ -50,7 +50,7 @@
* *
* Tested with * Tested with
* - ST25TB512-AC - (BE/Brussels/STIB ; AliExpress ones) * - ST25TB512-AC - (BE/Brussels/STIB ; AliExpress ones)
* - ST25TB512-AT - (FR/Lille/Ilevia ; FR/Reims/Citura) * - ST25TB512-AT - (FR/Lille/Ilevia ; FR/Reims/Citura ; FR/Dijon/Divia ; FR/Strasbourg/CTS)
* - SRT512 - legacy - (FR/Bordeaux/TBM) * - SRT512 - legacy - (FR/Bordeaux/TBM)
* - SRI512 - legacy - (anonymous vending machine) * - SRI512 - legacy - (anonymous vending machine)
*/ */
@ -94,7 +94,7 @@ int main(int argc, char *argv[])
nfc_context *context = NULL; nfc_context *context = NULL;
nfc_device *pnd = NULL; nfc_device *pnd = NULL;
nfc_target nt = {0}; nfc_target nt = {0};
nfc_modulation nm = {NMT_ISO14443B, NBR_106}; nfc_modulation nm = {NMT_ISO14443B2SR, NBR_106};
const st_data * stcurrent; const st_data * stcurrent;
int opt, res; int opt, res;
bool bIsBlock = false, bIsRead = false, bIsWrite = false, bIsBadCli = false; bool bIsBlock = false, bIsRead = false, bIsWrite = false, bIsBadCli = false;
@ -205,10 +205,6 @@ int main(int argc, char *argv[])
{ {
printf("Reader : %s - via %s\n ...wait for card...\n", nfc_device_get_name(pnd), nfc_device_get_connstring(pnd)); printf("Reader : %s - via %s\n ...wait for card...\n", nfc_device_get_name(pnd), nfc_device_get_connstring(pnd));
res = nfc_initiator_list_passive_targets(pnd, nm, &nt, 1);
if(res == 0) // we don't really wanted a NMT_ISO14443B
{
nm.nmt = NMT_ISO14443B2SR; // we want a NMT_ISO14443B2SR, but needed to ask for NMT_ISO14443B before
if (nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt) > 0) if (nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt) > 0)
{ {
stcurrent = get_info(&nt, true); stcurrent = get_info(&nt, true);
@ -239,12 +235,6 @@ int main(int argc, char *argv[])
} }
} }
} }
else if(res > 0)
{
printf("ERROR - We got a NMT_ISO14443B ?\n");
}
else printf("ERROR - nfc_initiator_list_passive_targets: %i\n", res);
}
else printf("ERROR - nfc_initiator_init: %i\n", res); else printf("ERROR - nfc_initiator_init: %i\n", res);
nfc_close(pnd); nfc_close(pnd);
@ -607,3 +597,4 @@ void print_hex(const uint8_t *pbtData, const size_t szBytes)
printf("%02hhx ", pbtData[szPos]); printf("%02hhx ", pbtData[szPos]);
} }
} }

View file

@ -1155,6 +1155,14 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd,
uint8_t abtRx[1]; uint8_t abtRx[1];
uint8_t *pbtInitData = (uint8_t *) "\x0b"; uint8_t *pbtInitData = (uint8_t *) "\x0b";
size_t szInitData = 1; size_t szInitData = 1;
if ((res = pn53x_write_register(pnd, PN53X_REG_CIU_TxAuto, 0xef, 0x07)) < 0) // Initial RFOn, Tx2 RFAutoEn, Tx1 RFAutoEn
return res;
if ((res = pn53x_write_register(pnd, PN53X_REG_CIU_CWGsP, 0x3f, 0x3f)) < 0) // Conductance of the P-Driver
return res;
if ((res = pn53x_write_register(pnd, PN53X_REG_CIU_ModGsP, 0x3f, 0x12)) < 0) // Driver P-output conductance for the time of modulation
return res;
// Getting random Chip_ID // Getting random Chip_ID
if ((res = pn53x_initiator_transceive_bytes(pnd, abtInitiate, szInitiateLen, abtRx, sizeof(abtRx), timeout)) < 0) { if ((res = pn53x_initiator_transceive_bytes(pnd, abtInitiate, szInitiateLen, abtRx, sizeof(abtRx), timeout)) < 0) {
if ((res == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Chip timeout if ((res == NFC_ERFTRANS) && (CHIP_DATA(pnd)->last_status_byte == 0x01)) { // Chip timeout

View file

@ -113,7 +113,7 @@ main(int argc, const char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
// Force TypeB for all derivatives of B // Force TypeB for all derivatives of B
if (mask & 0xf0) if (mask & 0xd0)
mask |= 0x08; mask |= 0x08;
} else { } else {
ERR("%s is not supported option.", argv[arg]); ERR("%s is not supported option.", argv[arg]);