Skip to content

Commit 1d729e3

Browse files
kenspeckle1Your Name
authored and
Your Name
committed
Apply styles for changed files
1 parent 1e4146d commit 1d729e3

File tree

8 files changed

+1622
-1558
lines changed

8 files changed

+1622
-1558
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ file per device in a nfc/devices.d directory:
102102
printf 'name = "My first device"\nconnstring = "pn532_uart:/dev/ttyACM0"\n' | sudo tee /etc/nfc/devices.d/first.conf
103103
printf 'name = "My second device"\nconnstring = "pn532_uart:/dev/ttyACM1"\n' | sudo tee /etc/nfc/devices.d/second.conf
104104

105+
Environment Variables
106+
=====================
107+
You can override certain configuration options at runtime using the following environment variables:
108+
+ `LIBNFC_DEFAULT_DEVICE=<connstring>`: `LIBNFC_DEFAULT_DEVICE=pn532_uart:/dev/ttyACM0` will use pn532 on /dev/ttyACM0 as default device
109+
+ `LIBNFC_DEVICE=<connstring>` will ignore all devices in the config files and use only the one defined in the variable
110+
+ `LIBNFC_AUTO_SCAN=<true|false>` overrides `allow_autoscan` option in the config file
111+
+ `LIBNFC_INTRUSIVE_SCAN=<true|false>` overrides `allow_intrusive_scan` option in the config file
112+
+ `LIBNFC_LOG_LEVEL=<0|1|2|3>` overrides `log_level` option in the config file
113+
114+
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.
115+
105116
How to report bugs
106117
==================
107118

examples/nfc-st25tb.c

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
*
5151
* Tested with
5252
* - ST25TB512-AC - (BE/Brussels/STIB ; AliExpress ones)
53-
* - ST25TB512-AT - (FR/Lille/Ilevia ; FR/Reims/Citura)
53+
* - ST25TB512-AT - (FR/Lille/Ilevia ; FR/Reims/Citura ; FR/Dijon/Divia ; FR/Strasbourg/CTS)
5454
* - SRT512 - legacy - (FR/Bordeaux/TBM)
5555
* - SRI512 - legacy - (anonymous vending machine)
5656
*/
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
9494
nfc_context *context = NULL;
9595
nfc_device *pnd = NULL;
9696
nfc_target nt = {0};
97-
nfc_modulation nm = {NMT_ISO14443B, NBR_106};
97+
nfc_modulation nm = {NMT_ISO14443B2SR, NBR_106};
9898
const st_data * stcurrent;
9999
int opt, res;
100100
bool bIsBlock = false, bIsRead = false, bIsWrite = false, bIsBadCli = false;
@@ -205,45 +205,35 @@ int main(int argc, char *argv[])
205205
{
206206
printf("Reader : %s - via %s\n ...wait for card...\n", nfc_device_get_name(pnd), nfc_device_get_connstring(pnd));
207207

208-
res = nfc_initiator_list_passive_targets(pnd, nm, &nt, 1);
209-
if(res == 0) // we don't really wanted a NMT_ISO14443B
208+
if (nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt) > 0)
210209
{
211-
nm.nmt = NMT_ISO14443B2SR; // we want a NMT_ISO14443B2SR, but needed to ask for NMT_ISO14443B before
212-
if (nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt) > 0)
210+
stcurrent = get_info(&nt, true);
211+
if(stcurrent)
213212
{
214-
stcurrent = get_info(&nt, true);
215-
if(stcurrent)
216-
{
217-
printf("\n");
213+
printf("\n");
218214

219-
if(bIsBlock && (bIsRead || bIsWrite))
215+
if(bIsBlock && (bIsRead || bIsWrite))
216+
{
217+
if(bIsRead)
220218
{
221-
if(bIsRead)
222-
{
223-
get_block_at(pnd, blockNumber, NULL, 0, true);
224-
}
225-
226-
if(bIsWrite)
227-
{
228-
set_block_at_confirmed(pnd, blockNumber, data, cbData, true);
229-
}
219+
get_block_at(pnd, blockNumber, NULL, 0, true);
230220
}
231-
else if(!bIsRead && !bIsWrite && !bIsBlock)
221+
222+
if(bIsWrite)
223+
{
224+
set_block_at_confirmed(pnd, blockNumber, data, cbData, true);
225+
}
226+
}
227+
else if(!bIsRead && !bIsWrite && !bIsBlock)
228+
{
229+
for(i = 0; i < stcurrent->nbNormalBlock; i++)
232230
{
233-
for(i = 0; i < stcurrent->nbNormalBlock; i++)
234-
{
235-
get_block_at(pnd, i, NULL, 0, true);
236-
}
237-
display_system_info(pnd, stcurrent);
231+
get_block_at(pnd, i, NULL, 0, true);
238232
}
233+
display_system_info(pnd, stcurrent);
239234
}
240235
}
241236
}
242-
else if(res > 0)
243-
{
244-
printf("ERROR - We got a NMT_ISO14443B ?\n");
245-
}
246-
else printf("ERROR - nfc_initiator_list_passive_targets: %i\n", res);
247237
}
248238
else printf("ERROR - nfc_initiator_init: %i\n", res);
249239

@@ -606,4 +596,5 @@ void print_hex(const uint8_t *pbtData, const size_t szBytes)
606596
{
607597
printf("%02hhx ", pbtData[szPos]);
608598
}
609-
}
599+
}
600+

0 commit comments

Comments
 (0)