summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt9
-rw-r--r--README.md12
-rw-r--r--src/CMakeLists.txt33
-rw-r--r--src/libnfc_reader.c37
4 files changed, 84 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cb875ab..1511ac0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,8 +19,17 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
option(USE_LIBNFC "Enable or disable the 'libnfc' usage." ON)
+option(LIBNFC_POLL_ALL "Enable all modulation when polling." OFF)
+option(LIBNFC_POLL_NMT_ISO14443A "Enable ISO-14443A modulation when polling." ON)
+option(LIBNFC_POLL_NMT_ISOJEWEL "Enable ISO-JEWEL modulation when polling." OFF)
+option(LIBNFC_POLL_NMT_ISO14443B "Enable ISO-14443B modulation when polling." OFF)
+option(LIBNFC_POLL_NMT_ISO14443BI "Enable ISO-14443BI modulation when polling." OFF)
+option(LIBNFC_POLL_NMT_ISO14443B2SR "Enable ISO-14443B2SR modulation when polling." OFF)
+option(LIBNFC_POLL_NMT_ISO14443B2CT "Enable ISO-14443B2CT modulation when polling." OFF)
+option(LIBNFC_POLL_NMT_FELICA "Enable Felica modulation when polling." OFF)
include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake)
install(DIRECTORY htdocs/nfc DESTINATION htdocs)
install(DIRECTORY etc DESTINATION ./)
+
diff --git a/README.md b/README.md
index 6142a93..87abcd7 100644
--- a/README.md
+++ b/README.md
@@ -36,3 +36,15 @@ Expect random error, but seem to stay stable and working.
¹ UID is randomly generated so the tag is detected as a new one on each poll.
² Polling is stopped at detection but no tag is exposed.
+
+# Compilation option
+
+* USE_LIBNFC - Enable or disable the 'libnfc' usage. Default is ON.
+ * LIBNFC_POLL_ALL Enable all modulation when polling. Default is OFF.
+ * LIBNFC_POLL_NMT_ISO14443A - Enable ISO-14443A modulation when polling. Default is ON.
+ * LIBNFC_POLL_NMT_ISOJEWEL - Enable ISO-JEWEL modulation when polling. Default is OFF.
+ * LIBNFC_POLL_NMT_ISO14443B - Enable ISO-14443B modulation when polling. Default is OFF.
+ * LIBNFC_POLL_NMT_ISO14443BI - Enable ISO-14443BI modulation when polling. Default is OFF.
+ * LIBNFC_POLL_NMT_ISO14443B2SR - Enable ISO-14443B2SR modulation when polling. Default is OFF.
+ * LIBNFC_POLL_NMT_ISO14443B2CT - Enable ISO-14443B2CT modulation when polling. Default is OFF.
+ * LIBNFC_POLL_NMT_FELICA - Enable Felica modulation when polling. Default is OFF. \ No newline at end of file
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