Skip to content

Commit

Permalink
Apply styles for changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
kenspeckle1 authored and Your Name committed Nov 6, 2023
1 parent 1e4146d commit 1d729e3
Show file tree
Hide file tree
Showing 8 changed files with 1,622 additions and 1,558 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ file per device in a nfc/devices.d directory:
printf 'name = "My first device"\nconnstring = "pn532_uart:/dev/ttyACM0"\n' | sudo tee /etc/nfc/devices.d/first.conf
printf 'name = "My second device"\nconnstring = "pn532_uart:/dev/ttyACM1"\n' | sudo tee /etc/nfc/devices.d/second.conf

Environment Variables
=====================
You can override certain configuration options at runtime using the following environment variables:
+ `LIBNFC_DEFAULT_DEVICE=<connstring>`: `LIBNFC_DEFAULT_DEVICE=pn532_uart:/dev/ttyACM0` will use pn532 on /dev/ttyACM0 as default device
+ `LIBNFC_DEVICE=<connstring>` will ignore all devices in the config files and use only the one defined in the variable
+ `LIBNFC_AUTO_SCAN=<true|false>` overrides `allow_autoscan` option in the config file
+ `LIBNFC_INTRUSIVE_SCAN=<true|false>` overrides `allow_intrusive_scan` option in the config file
+ `LIBNFC_LOG_LEVEL=<0|1|2|3>` overrides `log_level` option in the config file

To obtain the connstring of a recognized device, you can use `nfc-scan-device`: `LIBNFC_AUTO_SCAN=true nfc-scan-device` will show the names & connstrings of all found devices.

How to report bugs
==================

Expand Down
55 changes: 23 additions & 32 deletions examples/nfc-st25tb.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*
* Tested with
* - 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)
* - SRI512 - legacy - (anonymous vending machine)
*/
Expand Down Expand Up @@ -94,7 +94,7 @@ int main(int argc, char *argv[])
nfc_context *context = NULL;
nfc_device *pnd = NULL;
nfc_target nt = {0};
nfc_modulation nm = {NMT_ISO14443B, NBR_106};
nfc_modulation nm = {NMT_ISO14443B2SR, NBR_106};
const st_data * stcurrent;
int opt, res;
bool bIsBlock = false, bIsRead = false, bIsWrite = false, bIsBadCli = false;
Expand Down Expand Up @@ -205,45 +205,35 @@ 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));

res = nfc_initiator_list_passive_targets(pnd, nm, &nt, 1);
if(res == 0) // we don't really wanted a NMT_ISO14443B
if (nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt) > 0)
{
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)
stcurrent = get_info(&nt, true);
if(stcurrent)
{
stcurrent = get_info(&nt, true);
if(stcurrent)
{
printf("\n");
printf("\n");

if(bIsBlock && (bIsRead || bIsWrite))
if(bIsBlock && (bIsRead || bIsWrite))
{
if(bIsRead)
{
if(bIsRead)
{
get_block_at(pnd, blockNumber, NULL, 0, true);
}

if(bIsWrite)
{
set_block_at_confirmed(pnd, blockNumber, data, cbData, true);
}
get_block_at(pnd, blockNumber, NULL, 0, true);
}
else if(!bIsRead && !bIsWrite && !bIsBlock)

if(bIsWrite)
{
set_block_at_confirmed(pnd, blockNumber, data, cbData, true);
}
}
else if(!bIsRead && !bIsWrite && !bIsBlock)
{
for(i = 0; i < stcurrent->nbNormalBlock; i++)
{
for(i = 0; i < stcurrent->nbNormalBlock; i++)
{
get_block_at(pnd, i, NULL, 0, true);
}
display_system_info(pnd, stcurrent);
get_block_at(pnd, i, NULL, 0, true);
}
display_system_info(pnd, stcurrent);
}
}
}
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);

Expand Down Expand Up @@ -606,4 +596,5 @@ void print_hex(const uint8_t *pbtData, const size_t szBytes)
{
printf("%02hhx ", pbtData[szPos]);
}
}
}

Loading

0 comments on commit 1d729e3

Please sign in to comment.