diff options
author | Loïc Collignon <loic.collignon@iot.bzh> | 2017-11-08 23:02:19 +0100 |
---|---|---|
committer | Loïc Collignon <loic.collignon@iot.bzh> | 2017-11-08 23:02:19 +0100 |
commit | 1ca9e57c1423899798103f9eb05ec53f5cd02dcf (patch) | |
tree | 7b2d09f6e72db3ca5204c67ee7142af74bb1c375 /src | |
parent | e9d9e65ca0f6a2750420473300db2081d186de94 (diff) |
added compilation option to enable or disable modulations to speed up the detection.
Change-Id: I14bd40f9fcc4ca526da8d1d15e836f7f722fc9c7
Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 33 | ||||
-rw-r--r-- | src/libnfc_reader.c | 37 |
2 files changed, 63 insertions, 7 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c9021c..ba35037 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,40 @@ set(NFC_BINDING_SOURCES api.c nfc-binding.c) if (USE_LIBNFC) set(NFC_BINDING_SOURCES ${NFC_BINDING_SOURCES} libnfc_reader.c) add_definitions(-DUSE_LIBNFC=1) + + if(LIBNFC_POLL_ALL) + add_definitions(-DLIBNFC_POLL_ALL=1) + endif() + + if(LIBNFC_POLL_NMT_ISO14443A) + add_definitions(-DLIBNFC_POLL_NMT_ISO14443A=1) + endif() + + if(LIBNFC_POLL_NMT_ISOJEWEL) + add_definitions(-DLIBNFC_POLL_NMT_ISOJEWEL=1) + endif() + + if(LIBNFC_POLL_NMT_ISO14443B) + add_definitions(-DLIBNFC_POLL_NMT_ISO14443B=1) + endif() + + if(LIBNFC_POLL_NMT_ISO14443BI) + add_definitions(-DLIBNFC_POLL_NMT_ISO14443BI=1) + endif() + + if(LIBNFC_POLL_NMT_ISO14443B2SR) + add_definitions(-DLIBNFC_POLL_NMT_ISO14443B2SR=1) + endif() + + if(LIBNFC_POLL_NMT_ISO14443B2CT) + add_definitions(-DLIBNFC_POLL_NMT_ISO14443B2CT=1) + endif() + + if(LIBNFC_POLL_NMT_FELICA) + add_definitions(-DLIBNFC_POLL_NMT_FELICA=1) + endif() endif() + message(STATUS "libnfc enabled: ${USE_LIBNFC}") add_library(${TARGET_NAME} MODULE ${NFC_BINDING_SOURCES}) diff --git a/src/libnfc_reader.c b/src/libnfc_reader.c index af51db5..147cccf 100644 --- a/src/libnfc_reader.c +++ b/src/libnfc_reader.c @@ -20,7 +20,7 @@ extern struct afb_event on_nfc_target_remove_event; #define MAX_NFC_DEVICE_COUNT 8 #define MAX_NFC_MODULATIONS 8 #define MAX_NFC_BAUDRATES 8 -#define POLL_NUMBER 0xA +#define POLL_NUMBER 0x1 #define POLL_PERIOD 0x7 typedef struct libnfc_device_tag @@ -153,16 +153,39 @@ void* libnfc_reader_main(void* arg) int polled_target_count; nfc_modulation mods[MAX_NFC_MODULATIONS]; struct json_object* result; - size_t i, j; + size_t i; device = (libnfc_device*)arg; memset(mods, 0, sizeof(nfc_modulation) * MAX_NFC_MODULATIONS); - for(i = 0, j = 0; i < device->modulations_count; ++i, ++j) + for(i = 0; i < device->modulations_count; ++i) { - if (device->modulations[i].nmt != NMT_DEP) - mods[j] = device->modulations[i]; - else --j; + switch(device->modulations[i].nmt) + { +#if defined(LIBNFC_POLL_ALL) || defined(LIBNFC_POLL_NMT_ISO14443A) + case NMT_ISO14443A: +#endif +#if defined(LIBNFC_POLL_ALL) || defined(LIBNFC_POLL_NMT_ISOJEWEL) + case NMT_JEWEL: +#endif +#if defined(LIBNFC_POLL_ALL) || defined(LIBNFC_POLL_NMT_ISO14443B) + case NMT_ISO14443B: +#endif +#if defined(LIBNFC_POLL_ALL) || defined(LIBNFC_POLL_NMT_ISO14443BI) + case NMT_ISO14443BI: +#endif +#if defined(LIBNFC_POLL_ALL) || defined(LIBNFC_POLL_NMT_ISO14443B2SR) + case NMT_ISO14443B2SR: +#endif +#if defined(LIBNFC_POLL_ALL) || defined(LIBNFC_POLL_NMT_ISO14443B2CT) + case NMT_ISO14443B2CT: +#endif +#if defined(LIBNFC_POLL_ALL) || defined(LIBNFC_POLL_NMT_FELICA) + case NMT_FELICA: +#endif + mods[i] = device->modulations[i]; + // NMT_DEP is always disabled because it can't be polled + } } while(device->device) @@ -171,7 +194,7 @@ void* libnfc_reader_main(void* arg) ( device->device, mods, - j, + i, POLL_NUMBER, POLL_PERIOD, &nt |