Compare commits
No commits in common. "master" and "libnfc-1.7.0-rc5" have entirely different histories.
master
...
libnfc-1.7
86
.gitignore
vendored
86
.gitignore
vendored
@ -1,21 +1,16 @@
|
|||||||
**/.deps/
|
|
||||||
**/.libs/
|
|
||||||
**/Makefile
|
|
||||||
**/Makefile.in
|
|
||||||
*.exe
|
|
||||||
*.la
|
|
||||||
*.lo
|
|
||||||
*.o
|
|
||||||
*~
|
*~
|
||||||
.vs/
|
|
||||||
CMakeSettings.json
|
|
||||||
Doxyfile
|
Doxyfile
|
||||||
INSTALL
|
INSTALL
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
ar-lib
|
ar-lib
|
||||||
autom4te.cache/
|
autom4te.cache/
|
||||||
build
|
build
|
||||||
compile
|
cmake/Makefile
|
||||||
|
cmake/Makefile.in
|
||||||
|
cmake/modules/Makefile
|
||||||
|
cmake/modules/Makefile.in
|
||||||
config.guess
|
config.guess
|
||||||
config.h
|
config.h
|
||||||
config.h.in
|
config.h.in
|
||||||
@ -23,8 +18,22 @@ config.log
|
|||||||
config.status
|
config.status
|
||||||
config.sub
|
config.sub
|
||||||
configure
|
configure
|
||||||
debian/
|
contrib/Makefile
|
||||||
|
contrib/Makefile.in
|
||||||
|
contrib/devd/Makefile
|
||||||
|
contrib/devd/Makefile.in
|
||||||
|
contrib/udev/Makefile
|
||||||
|
contrib/udev/Makefile.in
|
||||||
|
contrib/win32/Makefile
|
||||||
|
contrib/win32/Makefile.in
|
||||||
|
contrib/win32/sys/Makefile
|
||||||
|
contrib/win32/sys/Makefile.in
|
||||||
depcomp
|
depcomp
|
||||||
|
examples/*.o
|
||||||
|
examples/.deps/
|
||||||
|
examples/.libs/
|
||||||
|
examples/Makefile
|
||||||
|
examples/Makefile.in
|
||||||
examples/nfc-anticol
|
examples/nfc-anticol
|
||||||
examples/nfc-dep-initiator
|
examples/nfc-dep-initiator
|
||||||
examples/nfc-dep-target
|
examples/nfc-dep-target
|
||||||
@ -37,10 +46,44 @@ examples/nfc-relay
|
|||||||
examples/pn53x-diagnose
|
examples/pn53x-diagnose
|
||||||
examples/pn53x-sam
|
examples/pn53x-sam
|
||||||
examples/pn53x-tamashell
|
examples/pn53x-tamashell
|
||||||
|
examples/pn53x-tamashell-scripts/Makefile
|
||||||
|
examples/pn53x-tamashell-scripts/Makefile.in
|
||||||
examples/quick_start_example1
|
examples/quick_start_example1
|
||||||
examples/quick_start_example2
|
examples/quick_start_example2
|
||||||
|
include/Makefile
|
||||||
|
include/Makefile.in
|
||||||
|
include/nfc/Makefile
|
||||||
|
include/nfc/Makefile.in
|
||||||
install-sh
|
install-sh
|
||||||
libnfc.pc
|
libnfc.pc
|
||||||
|
libnfc/*.lo
|
||||||
|
libnfc/*.o
|
||||||
|
libnfc/.deps/
|
||||||
|
libnfc/.libs/
|
||||||
|
libnfc/Makefile
|
||||||
|
libnfc/Makefile.in
|
||||||
|
libnfc/buses/*.la
|
||||||
|
libnfc/buses/*.lo
|
||||||
|
libnfc/buses/*.o
|
||||||
|
libnfc/buses/.deps/
|
||||||
|
libnfc/buses/.libs/
|
||||||
|
libnfc/buses/Makefile
|
||||||
|
libnfc/buses/Makefile.in
|
||||||
|
libnfc/chips/*.la
|
||||||
|
libnfc/chips/*.lo
|
||||||
|
libnfc/chips/*.o
|
||||||
|
libnfc/chips/.deps/
|
||||||
|
libnfc/chips/.libs/
|
||||||
|
libnfc/chips/Makefile
|
||||||
|
libnfc/chips/Makefile.in
|
||||||
|
libnfc/drivers/*.la
|
||||||
|
libnfc/drivers/*.lo
|
||||||
|
libnfc/drivers/*.o
|
||||||
|
libnfc/drivers/.deps/
|
||||||
|
libnfc/drivers/.libs/
|
||||||
|
libnfc/drivers/Makefile
|
||||||
|
libnfc/drivers/Makefile.in
|
||||||
|
libnfc/libnfc.la
|
||||||
libtool
|
libtool
|
||||||
ltmain.sh
|
ltmain.sh
|
||||||
m4/libtool.m4
|
m4/libtool.m4
|
||||||
@ -50,12 +93,21 @@ m4/ltversion.m4
|
|||||||
m4/lt~obsolete.m4
|
m4/lt~obsolete.m4
|
||||||
missing
|
missing
|
||||||
stamp-h1
|
stamp-h1
|
||||||
test-driver
|
test/*.la
|
||||||
test/run-test.sh.log
|
test/*.lo
|
||||||
test/run-test.sh.trs
|
test/*.o
|
||||||
test/test-suite.log
|
test/.deps/
|
||||||
|
test/.libs/
|
||||||
|
test/Makefile
|
||||||
|
test/Makefile.in
|
||||||
|
utils/*.la
|
||||||
|
utils/*.lo
|
||||||
|
utils/*.o
|
||||||
|
utils/.deps/
|
||||||
|
utils/.libs/
|
||||||
|
utils/Makefile
|
||||||
|
utils/Makefile.in
|
||||||
utils/nfc-emulate-forum-tag4
|
utils/nfc-emulate-forum-tag4
|
||||||
utils/nfc-jewel
|
|
||||||
utils/nfc-list
|
utils/nfc-list
|
||||||
utils/nfc-mfclassic
|
utils/nfc-mfclassic
|
||||||
utils/nfc-mfultralight
|
utils/nfc-mfultralight
|
||||||
|
|||||||
81
.travis.yml
81
.travis.yml
@ -1,81 +0,0 @@
|
|||||||
language: c
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: windows
|
|
||||||
compiler:
|
|
||||||
- clang
|
|
||||||
before_install:
|
|
||||||
- mkdir build && cd build && wget "https://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/libusb-win32-bin-1.2.6.0.zip" && 7z x libusb-win32-bin-1.2.6.0.zip -o"$PROGRAMFILES" && mv "$PROGRAMFILES/libusb-win32-bin-1.2.6.0" "$PROGRAMFILES/libusb-win32"
|
|
||||||
install:
|
|
||||||
choco install doxygen.install ninja
|
|
||||||
script:
|
|
||||||
cmake -GNinja .. && cmake --build .
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
dist: bionic
|
|
||||||
compiler:
|
|
||||||
- clang
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libusb-dev
|
|
||||||
- doxygen
|
|
||||||
- cmake
|
|
||||||
script:
|
|
||||||
- mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=~/.local .. && make -j2 && make install
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
dist: bionic
|
|
||||||
compiler:
|
|
||||||
- clang
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libusb-dev
|
|
||||||
- doxygen
|
|
||||||
script:
|
|
||||||
- autoreconf -vfi && mkdir build && cd build && ../configure --prefix=$HOME/.local/ && make -j2 && make install
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
dist: bionic
|
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libusb-dev
|
|
||||||
- doxygen
|
|
||||||
- cmake
|
|
||||||
script:
|
|
||||||
- mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=~/.local .. && make -j2 && make install
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
dist: bionic
|
|
||||||
compiler:
|
|
||||||
- gcc
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- libusb-dev
|
|
||||||
- doxygen
|
|
||||||
script:
|
|
||||||
- autoreconf -vfi && mkdir build && cd build && ../configure --prefix=$HOME/.local/ && make -j2 && make install
|
|
||||||
|
|
||||||
- os: osx
|
|
||||||
osx_image: xcode12
|
|
||||||
compiler:
|
|
||||||
- clang
|
|
||||||
before_install:
|
|
||||||
- brew install doxygen libusb-compat
|
|
||||||
script:
|
|
||||||
- mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=~/.local .. && make -j2 && make install
|
|
||||||
|
|
||||||
- os: osx
|
|
||||||
osx_image: xcode12
|
|
||||||
compiler:
|
|
||||||
- clang
|
|
||||||
before_install:
|
|
||||||
- brew install doxygen libusb-compat m4
|
|
||||||
script:
|
|
||||||
- autoreconf -vfi && mkdir build && cd build && ../configure --prefix=$HOME/.local/ && make -j2 && make install
|
|
||||||
48
AUTHORS
48
AUTHORS
@ -1,49 +1,3 @@
|
|||||||
# Alphabetical cleaned output of "git shortlog -s -e|cut -c 8-" :
|
|
||||||
Adam Laurie <adam@algroup.co.uk>
|
|
||||||
Ahti Legonkov <ahti.legonkov@gmail.com>
|
|
||||||
Alex Lian <alian@alum.mit.edu>
|
|
||||||
Alexander Inyukhin <shurick@sectorb.msk.ru>
|
|
||||||
Anugrah Redja Kusuma <anugrah.redja@gmail.com>
|
|
||||||
Audrey Diacre <adiacre@il4p.fr>
|
|
||||||
Boris Moiseev <cyberbobs@gmail.com>
|
|
||||||
Christoph Gritschenberger <christoph.gritschenberger@gmail.com>
|
|
||||||
Dario Carluccio <dario.carluccio@gmail.com>
|
|
||||||
David Kreitschmann <david@kreitschmann.de>
|
|
||||||
Emanuele Bertoldi <emanuele.bertoldi@gmail.com>
|
|
||||||
Emmanuel Dreyfus <manu@netbsd.org>
|
|
||||||
Eugeny Boger <eugenyboger@gmail.com>
|
|
||||||
Francois Kooman <fkooman@tuxed.net>
|
|
||||||
Frank Morgner <frankmorgner@gmail.com>
|
|
||||||
Frédéric Bourgeois <bourgeoislab@gmail.com>
|
|
||||||
Hidde Wieringa <hidde@hiddewieringa.nl>
|
|
||||||
Jairo Andres Suarez <andres4005@gmail.com>
|
|
||||||
Jiapeng Li <gapleehit@gmail.com>
|
|
||||||
Jim Anastassiou <jim.anastassiou@gmail.com>
|
|
||||||
John Galt <centromere@users.noreply.github.com>
|
|
||||||
Julien Ehrhart <julien.ehrhart@live.com>
|
|
||||||
Julien Schueller <julien.schueller@gmail.com>
|
|
||||||
Laurent Latil <laurent@latil.nom.fr>
|
|
||||||
Ludovic Rousseau <ludovic.rousseau@gmail.com>
|
|
||||||
Marcello Morena <marcello.morena@gmail.com>
|
|
||||||
Marcos Vives Del Sol <socram8888@gmail.com>
|
|
||||||
Mati Vait <mativait@gmail.com>
|
|
||||||
Maxim Martyanov <llorephie@gmail.com>
|
|
||||||
Mike Auty <mike.auty@gmail.com>
|
|
||||||
Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
|
|
||||||
Olliver Schinagl <oliver@schinagl.nl>
|
|
||||||
Paul Menzel <paul.menzel@giantmonkey.de>
|
|
||||||
Peter Meerwald <pmeerw@pmeerw.net>
|
|
||||||
Philippe Teuwen <yobibe@gmail.com>
|
|
||||||
Pim 't Hart <pimmeyproductions@gmail.com>
|
|
||||||
Ray Lee <rayleesky@outlook.com>
|
|
||||||
Roel Verdult <roel@libnfc.org>
|
Roel Verdult <roel@libnfc.org>
|
||||||
Romain Tartiere <romain.tartiere@gmail.com>
|
Romain Tartière <romain@libnfc.org>
|
||||||
Romuald Conty <romuald@libnfc.org>
|
Romuald Conty <romuald@libnfc.org>
|
||||||
Simon Yorkston <simon.yorkston@gmail.com>
|
|
||||||
bhack <s.fabri@email.it>
|
|
||||||
lego <lego@debian-fresh.prx>
|
|
||||||
quantum-x <simon.yorkston@gmail.com>
|
|
||||||
timzi <developers@make-gadget.ru>
|
|
||||||
xantares <xantares09@hotmail.com>
|
|
||||||
xaqq <kapp.arno@gmail.com>
|
|
||||||
yerzhanm <yerzhan.mukhamejan@gmail.com>
|
|
||||||
|
|||||||
212
CMakeLists.txt
212
CMakeLists.txt
@ -1,13 +1,7 @@
|
|||||||
cmake_minimum_required (VERSION 2.6)
|
PROJECT(libnfc C)
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||||
if (NOT DEFINED CMAKE_BUILD_TYPE)
|
|
||||||
set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
project (libnfc C)
|
|
||||||
|
|
||||||
SET(VERSION_MAJOR "1")
|
SET(VERSION_MAJOR "1")
|
||||||
SET(VERSION_MINOR "8")
|
SET(VERSION_MINOR "7")
|
||||||
SET(VERSION_PATCH "0")
|
SET(VERSION_PATCH "0")
|
||||||
|
|
||||||
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
||||||
@ -18,37 +12,28 @@ SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
|||||||
|
|
||||||
# config.h
|
# config.h
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET(LIBNFC_SYSCONFDIR "./config" CACHE PATH "libnfc configuration directory")
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_windows.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
|
||||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_windows.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
SET(LIBNFC_SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/config" CACHE PATH "libnfc configuration directory")
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32)
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32)
|
||||||
IF(NOT MINGW)
|
|
||||||
SET(CMAKE_C_FLAGS "-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE ${CMAKE_C_FLAGS}")
|
|
||||||
ENDIF(NOT MINGW)
|
|
||||||
ELSE(WIN32)
|
ELSE(WIN32)
|
||||||
SET(_XOPEN_SOURCE 600)
|
SET(_XOPEN_SOURCE 600)
|
||||||
SET(SYSCONFDIR "/etc" CACHE PATH "System configuration directory")
|
SET(SYSCONFDIR "/etc" CACHE PATH "System configuration directory")
|
||||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_posix.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_posix.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
|
|
||||||
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
|
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
# make it easy to locate CMake modules for finding libraries
|
# make it easy to locate CMake modules for finding libraries
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")
|
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
option (LIBNFC_LOG "Enable log facility (errors, warning, info and debug messages)" ON)
|
SET(LIBNFC_LOG ON CACHE BOOL "Enable log facility (errors, warning, info and debug messages)")
|
||||||
IF(LIBNFC_LOG)
|
IF(LIBNFC_LOG)
|
||||||
ADD_DEFINITIONS(-DLOG)
|
ADD_DEFINITIONS(-DLOG)
|
||||||
ENDIF(LIBNFC_LOG)
|
ENDIF(LIBNFC_LOG)
|
||||||
|
|
||||||
option (LIBNFC_ENVVARS "Enable envvars facility" ON)
|
|
||||||
IF(LIBNFC_ENVVARS)
|
|
||||||
ADD_DEFINITIONS(-DENVVARS)
|
|
||||||
ENDIF(LIBNFC_ENVVARS)
|
|
||||||
|
|
||||||
SET(LIBNFC_DEBUG_MODE OFF CACHE BOOL "Debug mode")
|
SET(LIBNFC_DEBUG_MODE OFF CACHE BOOL "Debug mode")
|
||||||
IF(LIBNFC_DEBUG_MODE)
|
IF(LIBNFC_DEBUG_MODE)
|
||||||
ADD_DEFINITIONS(-DDEBUG)
|
ADD_DEFINITIONS(-DDEBUG)
|
||||||
@ -59,17 +44,6 @@ ELSE(LIBNFC_DEBUG_MODE)
|
|||||||
SET(WIN32_MODE "release")
|
SET(WIN32_MODE "release")
|
||||||
ENDIF(LIBNFC_DEBUG_MODE)
|
ENDIF(LIBNFC_DEBUG_MODE)
|
||||||
|
|
||||||
option (LIBNFC_CONFFILES_MODE "Enable configuration files" ON)
|
|
||||||
IF(LIBNFC_CONFFILES_MODE)
|
|
||||||
ADD_DEFINITIONS(-DCONFFILES)
|
|
||||||
ENDIF(LIBNFC_CONFFILES_MODE)
|
|
||||||
|
|
||||||
option (BUILD_EXAMPLES "build examples ON/OFF" ON)
|
|
||||||
option (BUILD_UTILS "build utils ON/OFF" ON)
|
|
||||||
|
|
||||||
option (BUILD_DEBPKG "build debian package ON/OFF" OFF)
|
|
||||||
|
|
||||||
|
|
||||||
# Doxygen
|
# Doxygen
|
||||||
SET(builddir "${CMAKE_BINARY_DIR}")
|
SET(builddir "${CMAKE_BINARY_DIR}")
|
||||||
SET(top_srcdir "${CMAKE_SOURCE_DIR}")
|
SET(top_srcdir "${CMAKE_SOURCE_DIR}")
|
||||||
@ -103,34 +77,12 @@ ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
|||||||
ADD_DEFINITIONS(-Du_int8_t=uint8_t -Du_int16_t=uint16_t)
|
ADD_DEFINITIONS(-Du_int8_t=uint8_t -Du_int16_t=uint16_t)
|
||||||
|
|
||||||
IF(MINGW)
|
IF(MINGW)
|
||||||
IF (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
# force MinGW-w64 in 32bit mode
|
||||||
# force MinGW-w64 in 32bit mode
|
SET(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
|
||||||
SET(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
|
SET(CMAKE_MODULE_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||||
SET(CMAKE_MODULE_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
|
SET(CMAKE_SHARED_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||||
SET(CMAKE_SHARED_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
|
SET(CMAKE_EXE_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
|
SET(CMAKE_RC_FLAGS "--target=pe-i386 --output-format=coff ${CMAKE_RC_FLAGS}")
|
||||||
SET(CMAKE_RC_FLAGS "--target=pe-i386 --output-format=coff ${CMAKE_RC_FLAGS}")
|
|
||||||
ELSE(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
|
||||||
IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
|
|
||||||
# force MinGW-w64 in 32bit mode
|
|
||||||
MESSAGE("Building 32-bit Windows DLL")
|
|
||||||
#SET(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
|
|
||||||
#SET(CMAKE_MODULE_LINKER_FLAGS "--Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
#SET(CMAKE_SHARED_LINKER_FLAGS "--Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
|
|
||||||
#SET(CMAKE_EXE_LINKER_FLAGS "--Wl,--enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
|
|
||||||
SET(CMAKE_RC_FLAGS "--target=pe-i386 --output-format=coff ${CMAKE_RC_FLAGS}")
|
|
||||||
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
|
||||||
MESSAGE("Building 64-bit Windows DLL")
|
|
||||||
SET(CMAKE_RC_FLAGS "--target=pe-x86-64 --output-format=coff ${CMAKE_RC_FLAGS}")
|
|
||||||
ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
|
|
||||||
MESSAGE(FATAL_ERROR "Unknown Processor: ${CMAKE_SYSTEM_PROCESSOR}")
|
|
||||||
ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
|
|
||||||
ENDIF(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
|
||||||
|
|
||||||
FIND_PROGRAM(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH)
|
|
||||||
IF (NOT DLLTOOL)
|
|
||||||
MESSAGE(FATAL_ERROR "Could not find dlltool command")
|
|
||||||
ENDIF (NOT DLLTOOL)
|
|
||||||
ENDIF(MINGW)
|
ENDIF(MINGW)
|
||||||
|
|
||||||
IF(NOT WIN32)
|
IF(NOT WIN32)
|
||||||
@ -141,38 +93,23 @@ IF(NOT WIN32)
|
|||||||
IF(LIBNFC_DRIVER_PN53X_USB)
|
IF(LIBNFC_DRIVER_PN53X_USB)
|
||||||
SET(PKG_REQ ${PKG_REQ} "libusb")
|
SET(PKG_REQ ${PKG_REQ} "libusb")
|
||||||
ENDIF(LIBNFC_DRIVER_PN53X_USB)
|
ENDIF(LIBNFC_DRIVER_PN53X_USB)
|
||||||
IF(LIBNFC_DRIVER_ACR122_USB)
|
IF(LIBNFC_DRIVER_ACR122)
|
||||||
SET(PKG_REQ ${PKG_REQ} "libusb")
|
|
||||||
ENDIF(LIBNFC_DRIVER_ACR122_USB)
|
|
||||||
IF(LIBNFC_DRIVER_PCSC)
|
|
||||||
SET(PKG_REQ ${PKG_REQ} "libpcsclite")
|
SET(PKG_REQ ${PKG_REQ} "libpcsclite")
|
||||||
ENDIF(LIBNFC_DRIVER_PCSC)
|
ENDIF(LIBNFC_DRIVER_ACR122)
|
||||||
IF(LIBNFC_DRIVER_ACR122_PCSC)
|
|
||||||
SET(PKG_REQ ${PKG_REQ} "libpcsclite")
|
|
||||||
ENDIF(LIBNFC_DRIVER_ACR122_PCSC)
|
|
||||||
# CMake lists are separated by a semi colon, replace with colon
|
# CMake lists are separated by a semi colon, replace with colon
|
||||||
STRING(REPLACE ";" "," PKG_CONFIG_REQUIRES "${PKG_REQ}")
|
STRING(REPLACE ";" "," PKG_CONFIG_REQUIRES "${PKG_REQ}")
|
||||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libnfc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc @ONLY)
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libnfc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc @ONLY)
|
||||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
ENDIF(NOT WIN32)
|
ENDIF(NOT WIN32)
|
||||||
|
|
||||||
INCLUDE(LibnfcDrivers)
|
# Require PCRE for Win32
|
||||||
|
IF (WIN32)
|
||||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
FIND_PACKAGE(PCRE REQUIRED)
|
||||||
IF(I2C_REQUIRED)
|
IF(PCRE_INCLUDE_DIRS)
|
||||||
# Inspired from http://cmake.3232098.n2.nabble.com/RFC-cmake-analog-to-AC-SEARCH-LIBS-td7585423.html
|
INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIRS})
|
||||||
INCLUDE (CheckFunctionExists)
|
LINK_DIRECTORIES(${PCRE_LIBRARY_DIRS})
|
||||||
INCLUDE (CheckLibraryExists)
|
ENDIF(PCRE_INCLUDE_DIRS)
|
||||||
CHECK_FUNCTION_EXISTS (clock_gettime HAVE_CLOCK_GETTIME)
|
ENDIF(WIN32)
|
||||||
IF (NOT HAVE_CLOCK_GETTIME)
|
|
||||||
CHECK_LIBRARY_EXISTS (rt clock_gettime "" HAVE_CLOCK_GETTIME_IN_RT)
|
|
||||||
IF (HAVE_CLOCK_GETTIME_IN_RT)
|
|
||||||
SET(LIBRT_FOUND TRUE)
|
|
||||||
SET(LIBRT_LIBRARIES "rt")
|
|
||||||
ENDIF (HAVE_CLOCK_GETTIME_IN_RT)
|
|
||||||
ENDIF (NOT HAVE_CLOCK_GETTIME)
|
|
||||||
ENDIF(I2C_REQUIRED)
|
|
||||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
|
|
||||||
IF(PCSC_INCLUDE_DIRS)
|
IF(PCSC_INCLUDE_DIRS)
|
||||||
INCLUDE_DIRECTORIES(${PCSC_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(${PCSC_INCLUDE_DIRS})
|
||||||
@ -182,123 +119,40 @@ ENDIF(PCSC_INCLUDE_DIRS)
|
|||||||
IF(LIBUSB_INCLUDE_DIRS)
|
IF(LIBUSB_INCLUDE_DIRS)
|
||||||
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS})
|
||||||
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS})
|
LINK_DIRECTORIES(${LIBUSB_LIBRARY_DIRS})
|
||||||
SET(LIBUSB_FOUND TRUE)
|
|
||||||
ENDIF(LIBUSB_INCLUDE_DIRS)
|
ENDIF(LIBUSB_INCLUDE_DIRS)
|
||||||
|
|
||||||
# version.rc for Windows
|
# version.rc for Windows
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
# Date for filling in rc file information
|
# Date for filling in rc file information
|
||||||
IF (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
MACRO (GET_CURRENT_YEAR RESULT)
|
||||||
MACRO (GET_CURRENT_YEAR RESULT)
|
EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
|
||||||
EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
|
STRING(REGEX REPLACE ".*(..)/(..)/(....).*" "\\3" ${RESULT} ${${RESULT}})
|
||||||
STRING(REGEX REPLACE "\n" "" ${RESULT} ${${RESULT}})
|
ENDMACRO (GET_CURRENT_YEAR)
|
||||||
STRING(REGEX REPLACE ".*(..)/(..)/(....).*" "\\3" ${RESULT} ${${RESULT}})
|
|
||||||
ENDMACRO (GET_CURRENT_YEAR)
|
|
||||||
ELSE(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
|
||||||
MACRO (GET_CURRENT_YEAR RESULT)
|
|
||||||
EXECUTE_PROCESS(COMMAND "date" "+%Y" OUTPUT_VARIABLE ${RESULT})
|
|
||||||
STRING(REGEX REPLACE "\n" "" ${RESULT} ${${RESULT}})
|
|
||||||
ENDMACRO (GET_CURRENT_YEAR)
|
|
||||||
ENDIF(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
|
|
||||||
GET_CURRENT_YEAR(CURRENT_YEAR)
|
GET_CURRENT_YEAR(CURRENT_YEAR)
|
||||||
MESSAGE("Year for copyright is " ${CURRENT_YEAR})
|
MESSAGE("Year for copyright is " ${CURRENT_YEAR})
|
||||||
|
|
||||||
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
|
||||||
SET(RC_COMMENT "${PACKAGE_NAME} library")
|
SET(RC_COMMENT "${PACKAGE_NAME} library")
|
||||||
SET(RC_INTERNAL_NAME "${PACKAGE_NAME} ${WIN32_MODE}")
|
SET(RC_INTERNAL_NAME "${PACKAGE_NAME} ${WIN32_MODE}")
|
||||||
SET(RC_ORIGINAL_NAME ${PACKAGE_NAME}.dll)
|
SET(RC_ORIGINAL_NAME ${PACKAGE_NAME}.dll)
|
||||||
# RC_FILE_TYPE: VFT_DLL
|
SET(RC_FILE_TYPE VFT_DLL)
|
||||||
SET(RC_FILE_TYPE 0x00000002L)
|
|
||||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/windows/libnfc.rc @ONLY)
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/windows/libnfc.rc @ONLY)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(libnfc)
|
ADD_SUBDIRECTORY(libnfc)
|
||||||
ADD_SUBDIRECTORY(include)
|
ADD_SUBDIRECTORY(include)
|
||||||
|
ADD_SUBDIRECTORY(utils)
|
||||||
if (BUILD_UTILS)
|
ADD_SUBDIRECTORY(examples)
|
||||||
add_subdirectory (utils)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (BUILD_EXAMPLES)
|
|
||||||
add_subdirectory (examples)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (NOT MSVC)
|
|
||||||
# config script install path
|
|
||||||
if ( NOT DEFINED LIBNFC_CMAKE_CONFIG_DIR )
|
|
||||||
set ( LIBNFC_CMAKE_CONFIG_DIR lib${LIB_SUFFIX}/cmake/libnfc )
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set ( LIBNFC_INCLUDE_DIR ${includedir} )
|
|
||||||
set ( LIBNFC_INCLUDE_DIRS ${LIBNFC_INCLUDE_DIR} )
|
|
||||||
list ( APPEND LIBNFC_INCLUDE_DIRS ${LIBUSB_INCLUDE_DIRS} )
|
|
||||||
set ( LIBNFC_LIBRARY nfc )
|
|
||||||
set ( LIBNFC_LIBRARIES ${LIBNFC_LIBRARY} )
|
|
||||||
list ( APPEND LIBNFC_LIBRARIES ${LIBUSB_LIBRARIES} )
|
|
||||||
set ( LIBNFC_LIBRARY_DIRS ${libdir} )
|
|
||||||
set ( LIBNFC_ROOT_DIR ${prefix} )
|
|
||||||
set ( LIBNFC_VERSION_STRING ${VERSION} )
|
|
||||||
set ( LIBNFC_VERSION_MAJOR ${VERSION_MAJOR} )
|
|
||||||
set ( LIBNFC_VERSION_MINOR ${VERSION_MINOR} )
|
|
||||||
set ( LIBNFC_VERSION_PATCH ${VERSION_PATCH} )
|
|
||||||
|
|
||||||
set ( LIBNFC_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIBNFC_CMAKE_CONFIG_DIR}/UseLibNFC.cmake )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 2.8.8)
|
|
||||||
configure_file ( cmake/LibNFCConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfig.cmake @ONLY )
|
|
||||||
configure_file ( cmake/LibNFCConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfigVersion.cmake @ONLY )
|
|
||||||
else ()
|
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
configure_package_config_file (
|
|
||||||
cmake/LibNFCConfig.cmake.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfig.cmake
|
|
||||||
INSTALL_DESTINATION ${LIBNFC_CMAKE_CONFIG_DIR}
|
|
||||||
PATH_VARS
|
|
||||||
LIBNFC_USE_FILE
|
|
||||||
LIBNFC_ROOT_DIR
|
|
||||||
LIBNFC_INCLUDE_DIR
|
|
||||||
LIBNFC_INCLUDE_DIRS
|
|
||||||
LIBNFC_LIBRARY_DIRS
|
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
|
||||||
)
|
|
||||||
write_basic_package_version_file (
|
|
||||||
LibNFCConfigVersion.cmake
|
|
||||||
VERSION ${LIBNFC_VERSION_STRING}
|
|
||||||
COMPATIBILITY AnyNewerVersion
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfig.cmake
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfigVersion.cmake
|
|
||||||
cmake/UseLibNFC.cmake
|
|
||||||
DESTINATION ${LIBNFC_CMAKE_CONFIG_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Binary Package
|
# Binary Package
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET(CPACK_GENERATOR "ZIP")
|
SET(CPACK_GENERATOR "NSIS")
|
||||||
ELSE(WIN32)
|
ELSE(WIN32)
|
||||||
SET(CPACK_GENERATOR "TBZ2")
|
SET(CPACK_GENERATOR "TBZ2")
|
||||||
IF(BUILD_DEBPKG)
|
|
||||||
SET(CPACK_GENERATOR "DEB")
|
|
||||||
ENDIF(BUILD_DEBPKG)
|
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Near Field Communication (NFC) library")
|
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Near Field Communication (NFC) library")
|
||||||
SET(CPACK_PACKAGE_VENDOR "Roel Verdult")
|
SET(CPACK_PACKAGE_VENDOR "Roel Verdult")
|
||||||
SET(CPACK_PACKAGE_CONTACT "Roel Verdult <roel@libnfc.org>")
|
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
|
||||||
|
|
||||||
#Readme file
|
|
||||||
IF(WIN32)
|
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README-Windows.md")
|
|
||||||
ELSE(WIN32)
|
|
||||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
|
||||||
ENDIF(WIN32)
|
|
||||||
|
|
||||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
|
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
|
||||||
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "libnfc")
|
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "libnfc")
|
||||||
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
||||||
|
|||||||
224
ChangeLog
224
ChangeLog
@ -1,226 +1,4 @@
|
|||||||
May 22, 2020 - 1.8.0
|
Feb TBD, 2013 - 1.7.0-rc5 (release candidate)
|
||||||
--------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
- Restore nfc_modulation_type enum order to keep compatibility with libnfc 1.7.1
|
|
||||||
|
|
||||||
Changes:
|
|
||||||
- Bump revision due to changes in API introduced in v1.7.2
|
|
||||||
- Bump library version to 6.0.0
|
|
||||||
|
|
||||||
May 21, 2020 - 1.7.2 (avoid using it, incompatible with 1.7.1)
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
- Remove unreachable code
|
|
||||||
- nfc_emulate_uid: cleaner exit on interrupt
|
|
||||||
- Fix reporting of modulations and baud rates by nfc-scan-device -v
|
|
||||||
- Fix out-of-bounds access in nfc-mfultralight
|
|
||||||
- Several Cygwin compilation fixes
|
|
||||||
- Fix comparison when nfc_initiator_target_is_present() with a specified target
|
|
||||||
- Fix nfc_initiator_poll_target without tag on PN532
|
|
||||||
- Export iso14443b* symbols
|
|
||||||
- Fix udev rule which was executed too early
|
|
||||||
- Fix improper device name initialization
|
|
||||||
- Fix setenv()/unsetenv() for Windows
|
|
||||||
- Fix win32/nfc.def according to nfc.h
|
|
||||||
- Fix missing timeout in pn53x_initiator_select_passive_target()
|
|
||||||
- nfc-mfclassic: fix option to tolerate write errors
|
|
||||||
- nfc-poll: fix card removing check
|
|
||||||
- nfc-relay-picc: fix wrong open mode for file descriptor
|
|
||||||
|
|
||||||
Improvements:
|
|
||||||
- Allow ISO14443A to be used at higher baud rates
|
|
||||||
- nfc_initiator_select_passive_target() now checks against
|
|
||||||
reported modulations and baud rates for current device
|
|
||||||
- More serial devices on MAC OS X
|
|
||||||
- Add section to README to help to configure libnfc
|
|
||||||
- Various cmake improvements
|
|
||||||
- Drop PCRE dependency on Windows
|
|
||||||
- Remove deprecated readdir_r
|
|
||||||
- Markdown conversion of the text files
|
|
||||||
- Use hardcoded PN533 descriptors to be more robust on Windows
|
|
||||||
- Add support for SCL3712
|
|
||||||
- Add support for ACR1222U-C1
|
|
||||||
- Add support for NetBSD
|
|
||||||
- Add support for PN532 on RPi3 UART
|
|
||||||
- Add support for cross-compilation of 32b & 64b versions of the library for Windows
|
|
||||||
- Add pn533_usb to the kernel modules blacklist
|
|
||||||
- Add support for pn71xx NXP's NFC Controllers through Linux Libnfc-nci (untested)
|
|
||||||
- Add support for contactless PC/SC readers (only as initiator)
|
|
||||||
- Add support for Feitian R502 and bR500 into pcsc driver
|
|
||||||
- Add support for HID iClass (Picopass) support (nfc-iclass tool in external nfc-tools repo)
|
|
||||||
- Allows for sending empty data in nfc_initiator_transceive_bits
|
|
||||||
- driver i2c: respect proper timing specifications
|
|
||||||
- driver i2c: add retry on error mechanism
|
|
||||||
- nfc-mfclassic: improvements fo magic cards
|
|
||||||
- nfc-mfclassic: add option to specify UID
|
|
||||||
- nfc-mfclassic/nfc-mfsetuid: add support for new gen (1b) of magic 4K cards
|
|
||||||
- nfc-mfclassic: Add RATS support indicator
|
|
||||||
- nfc-mfsetuid: allow to write complete Block0, instead of only UID
|
|
||||||
- nfc-mfultralight: add automatic modes and --check-magic
|
|
||||||
- nfc-mfultralight: add support for magic gen2 cards
|
|
||||||
- nfc-mfultralight: add option to specify UID
|
|
||||||
- nfc-mfultralight: add support for Ultralight NTAG213/215/216
|
|
||||||
- nfc-barcode: new command to read and decode NFC Barcodes (Tag-Talks-First)
|
|
||||||
|
|
||||||
Changes:
|
|
||||||
- nfc_device_get_supported_baud_rate() takes now a "mode" parameter
|
|
||||||
- New nfc_device_get_supported_baud_rate_target_mode()
|
|
||||||
- New NFC modulation type NMT_BARCODE and nfc_barcode_info struct to support Thinfilm NFC Barcode protocol
|
|
||||||
- New NFC modulation type NMT_ISO14443BICLASS and NMT_ISO14443BICLASS struct to support HID iClass (Picopass)
|
|
||||||
- pn53x_transceive() is now part of public API
|
|
||||||
|
|
||||||
Special thanks to:
|
|
||||||
- Jim Anastassiou, Frédéric Bourgeois, Dario Carluccio, Emmanuel Dreyfus,
|
|
||||||
Julien Ehrhart, S. Fabri, John Galt, Christoph Gritschenberger,
|
|
||||||
Alexander Inyukhin, Arnaud Kapp, David Kreitschmann, Adam Laurie, Ray Lee,
|
|
||||||
Maxim Martyanov, Paul Menzel, Boris Moiseev, Yerzhan Mukhamejan,
|
|
||||||
Olliver Shinagl, Jairo Andres Suarez, Mati Vait, Marcos Vives Del Sol,
|
|
||||||
Hidde Wieringa, Simon Yorkston, timzi, usk-johnny-s, xantares, Hanno
|
|
||||||
Heinrichs, jgeslin, Mikolaj Stawiski, rstular, Khem Raj, Frank Morgner, jpwidera,
|
|
||||||
Feitian Technologies
|
|
||||||
|
|
||||||
Feb 24, 2014 - 1.7.1
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
- Fix several issues reported by Coverity Scan
|
|
||||||
(mem leaks, buff overflows, reuse after free, etc)
|
|
||||||
- More robust when several conflicting uart drivers are in the config
|
|
||||||
- Fix racing condition with uart_flush_input()
|
|
||||||
- Silent pn53x_check_communication error messages when scanning
|
|
||||||
- Fix nfc_target_init(), was returning success in case of timeout
|
|
||||||
- Windows: fix several compilation issues
|
|
||||||
- On tag selection, save current target info also for ISO14443B*
|
|
||||||
- nfc-read-forum-tag3: fix incomplete NDEF retrieval and size of output file
|
|
||||||
|
|
||||||
Improvements:
|
|
||||||
- nfc-list: New option to choose which technologies to poll for
|
|
||||||
- UART: drivers now supported under kFreeBSD
|
|
||||||
- New LIBNFC_DEVICE env var to use one reader and exclude all other readers
|
|
||||||
while LIBNFC_DEFAULT_DEVICE only prepends it to the configured devices list
|
|
||||||
- New LIBNFC_AUTO_SCAN env var to enable(default)/disable auto scan
|
|
||||||
- On tag selection, save current target info even if pnt=NULL
|
|
||||||
- On tag selection, grant NP_INFINITE_SELECT also for ISO14443B*
|
|
||||||
- Save & restore NP_INFINITE_SELECT status when changing it internally
|
|
||||||
- nfc-mfclassic: add format/wipe command (thanks to Adam Laurie)
|
|
||||||
- nfc-jewel: new utility to read/write Topaz/Jewel tags (thanks to Pim 't Hart)
|
|
||||||
- nfc_initiator_select_passive_target() provides defaults if pbtInitData=NULL
|
|
||||||
- nfc-read-forum-tag3: add -q option, add full parsing of NDEF Attribute Block
|
|
||||||
|
|
||||||
Fixes & improvements specific to nfc_initiator_target_is_present():
|
|
||||||
- Supports fully PN532 & PN533, not tested on other chips
|
|
||||||
- Fix usage after nfc_initiator_poll_target()
|
|
||||||
- Set correctly last_error
|
|
||||||
- Fix issue when there was no saved target
|
|
||||||
- Allow NULL pointer to tag
|
|
||||||
- Fix issues in case of tear off conditions
|
|
||||||
- Now works with:
|
|
||||||
* MFUL, MFC, MFC Mini, MFC 7-byte (re-selection: you'll need to auth again)
|
|
||||||
* ISO14443-4A, ISO14443-4B
|
|
||||||
* ISO14443-4B', ASK CTx, ST SRx
|
|
||||||
* Jewel
|
|
||||||
* FeliCa
|
|
||||||
|
|
||||||
Sep 03, 2013 - 1.7.0
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
- pn53x: only create a current target when at least one have been found
|
|
||||||
- pn532_uart: fix 'operation abort' feature with this driver
|
|
||||||
- pn532_uart: let more time to PN532 to wake-up, this fix some specific cases
|
|
||||||
where PN532 shown one of two runs (Thanks to Marcello Morena)
|
|
||||||
- nfc-mfclassic: allow option f for read operation too
|
|
||||||
- Avoid clash with system's htole32 if it exists
|
|
||||||
- Include <stdlib.h>, required for getenv(3)
|
|
||||||
- usb: fix USB enumeration issue (Thanks to Mike Auty)
|
|
||||||
- acr122_pcsc: fix compilation on Mac OSX 10.8.4
|
|
||||||
- Fix pn53x_initiator_transceive_bytes_timed() measures for TypeB
|
|
||||||
- Various minor fixes: warnings, style, etc.
|
|
||||||
|
|
||||||
Improvements:
|
|
||||||
- New PN532 over I2C driver, see contrib/libnfc/pn532_i2c_on_rpi.conf.sample
|
|
||||||
- ACR122/Touchatag: misc improvements
|
|
||||||
- ReadMobib/ReadNavigo: improve shell script portability
|
|
||||||
- Add ISO14443-4 chaining support for RX (MI)
|
|
||||||
- UART: add support for BeagleBone serial ports (Thanks to Johan Henselmans)
|
|
||||||
- nfc-mfultralight: allow setting of UID for special 'chinese' ultralight cards
|
|
||||||
|
|
||||||
Special thanks to:
|
|
||||||
- Laurent Latil (new pn532_i2c driver for linux)
|
|
||||||
- Nobuhiro Iwamatsu (warning fixes and debian package)
|
|
||||||
|
|
||||||
Apr 05, 2013 - 1.7.0-rc7 (release candidate)
|
|
||||||
--------------------------------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
- Fix bug when compiling without libusb
|
|
||||||
- Fix several memory leaks in error handling conditions
|
|
||||||
- Remove calls to exit() from the library
|
|
||||||
- Create safer snprint_nfc_*() instead of sprint_nfc_*() functions
|
|
||||||
- Fix warnings returned by cppcheck & clang/scan-build
|
|
||||||
- Obsolete function 'usleep' => nanosleep()
|
|
||||||
- Non reentrant function 'readdir' => readdir_r()
|
|
||||||
- Non reentrant function 'strtok' => new connstring_decode()
|
|
||||||
- Buffer may not be null-terminated after call to strncpy()
|
|
||||||
- scanf without field width limits can crash with huge input data
|
|
||||||
- Resource leaks: missing fclose()
|
|
||||||
- Dead code, unused vars & vars scopes warnings
|
|
||||||
- Unify copyright notices & update authors lists
|
|
||||||
- Windows: Fix compilation due to new usbbus file
|
|
||||||
- Windows: Clean up compiler/linker warnings
|
|
||||||
- Fixed the suppression of the auto-fixup for linking against MS built libs
|
|
||||||
- Fixed all the formatting warnings by shifting to inttypes.h specifiers
|
|
||||||
- shifted to %lu for DWORD printf
|
|
||||||
- nfc-anticol: fix ATS length
|
|
||||||
- nfc-mfclassic: fix reporting of processed blocks total
|
|
||||||
- nfc-mfclassic: detect MIFARE Plus 2K as 2K instead of 1K
|
|
||||||
- pn53x_usb/acr122_usb: check usb_open() returns before using it
|
|
||||||
|
|
||||||
Improvements:
|
|
||||||
- New PN532 over SPI driver, see contrib/libnfc/pn532_spi_on_rpi.conf.sample
|
|
||||||
- Devels HACKING file: introduce clang/scan-build & cppcheck for better code
|
|
||||||
- Better internal dependencies handling (bus <> drivers)
|
|
||||||
- Cleaner handling of portability patches
|
|
||||||
- Windows: logging via OutputDebugString(), ease debugging
|
|
||||||
- nfc-mfclassic: use smaller files for cards < 4k
|
|
||||||
- nfc-mfclassic: by defaut don't authorise wrong keyfile, use "f" to force
|
|
||||||
- quick_start_example1.c: remove err.h dependency, easier for Windowsians
|
|
||||||
- nfc-mfclassic: support some new magic cards with writeable sector #0
|
|
||||||
- nfc-anticol: add -t option to use timed functions
|
|
||||||
|
|
||||||
Changes:
|
|
||||||
- Upon malloc error, nfc_init() doesn't force exit() anymore
|
|
||||||
so now you should test if context != NULL after nfc_init() call
|
|
||||||
- API: nfc_initiator_target_is_present() & str_nfc_target()
|
|
||||||
now take a pointer to nfc_target as argument instead of passing by value
|
|
||||||
|
|
||||||
Special thanks to:
|
|
||||||
- Eugeny Boger (new pn532_spi driver for linux)
|
|
||||||
|
|
||||||
Mar 03, 2013 - 1.7.0-rc6 (release candidate)
|
|
||||||
--------------------------------------------
|
|
||||||
|
|
||||||
Fixes:
|
|
||||||
- Fix several memory leaks (nfc_drivers, libusb, config parser)
|
|
||||||
- Fix stack smash while displaying long data transmission (LOG_HEX)
|
|
||||||
- pn53x-tamashell: allow larger commands up to full extended frame
|
|
||||||
- Add missing windows file in archive (version.rc.in)
|
|
||||||
- Fix compilation warnings & potential bugs
|
|
||||||
- Fix documentation
|
|
||||||
- Fix missing malloc() calls checks
|
|
||||||
- Fix missing free() calls in some error handlers
|
|
||||||
|
|
||||||
Improvements:
|
|
||||||
- Allow to disable conffils & envvar supports on embedded platforms
|
|
||||||
- Add option to nfc-mfclassic to tolerate RW errors
|
|
||||||
|
|
||||||
Changes:
|
|
||||||
- Replace usb_set_debug() in applications by LIBNFC_LOG_LEVEL libusb group
|
|
||||||
|
|
||||||
Feb 16, 2013 - 1.7.0-rc5 (release candidate)
|
|
||||||
--------------------------------------------
|
|
||||||
|
|
||||||
Fixes:
|
Fixes:
|
||||||
- Add missing sample configuration file in archive
|
- Add missing sample configuration file in archive
|
||||||
|
|||||||
2486
Doxyfile.in
2486
Doxyfile.in
File diff suppressed because it is too large
Load Diff
44
HACKING
Normal file
44
HACKING
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
Hello hackers!
|
||||||
|
|
||||||
|
General remarks about contributing
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Contributions to the libnfc are welcome!
|
||||||
|
Here are some directions to get you started:
|
||||||
|
|
||||||
|
1. Follow style conventions
|
||||||
|
The source code of the library trend to follow some conventions so that it
|
||||||
|
is consistent in style and thus easier to read.
|
||||||
|
Look around and respect the same style.
|
||||||
|
Don't use tabs. Increment unit is two spaces.
|
||||||
|
Don't leave dandling spaces or tabs at EOL.
|
||||||
|
Helper script to get some uniformity in the style:
|
||||||
|
$ make style
|
||||||
|
|
||||||
|
If you use vim see the "Vim: How to prevent trailing whitespaces"
|
||||||
|
http://www.carbon-project.org/Vim__How_to_prevent_trailing_whitespaces.html
|
||||||
|
|
||||||
|
2. Chase warnings: no warning should be introduced by your changes
|
||||||
|
Depending what you touch, you can check with:
|
||||||
|
2.1 When using autotools
|
||||||
|
$ autoreconf -Wall -vis
|
||||||
|
2.2 When compiling
|
||||||
|
$ export CFLAGS="-Wall -g -O2 -Wextra -pipe -funsigned-char -fstrict-aliasing \
|
||||||
|
-Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wunused \
|
||||||
|
-Wuninitialized -Wpointer-arith -Wredundant-decls -Winline -Wformat \
|
||||||
|
-Wformat-security -Wswitch-enum -Winit-self -Wmissing-include-dirs \
|
||||||
|
-Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition \
|
||||||
|
-Wbad-function-cast -Wnested-externs -Wmissing-declarations"
|
||||||
|
$ ./configure
|
||||||
|
$ make
|
||||||
|
2.3 When Debianizing
|
||||||
|
$ lintian *deb
|
||||||
|
|
||||||
|
3. Preserve cross-platform compatility
|
||||||
|
The source code should remain compilable across various platforms,
|
||||||
|
including some you probably cannot test alone so keep it in mind.
|
||||||
|
Supported platforms:
|
||||||
|
- Linux
|
||||||
|
- FreeBSD
|
||||||
|
- Mac OS X
|
||||||
|
- Windows with Mingw
|
||||||
68
HACKING.md
68
HACKING.md
@ -1,68 +0,0 @@
|
|||||||
Hello hackers!
|
|
||||||
|
|
||||||
General remarks about contributing
|
|
||||||
----------------------------------
|
|
||||||
|
|
||||||
Contributions to the libnfc are welcome!
|
|
||||||
Here are some directions to get you started:
|
|
||||||
|
|
||||||
1. Follow style conventions
|
|
||||||
The source code of the library trend to follow some conventions so that it
|
|
||||||
is consistent in style and thus easier to read.
|
|
||||||
Look around and respect the same style.
|
|
||||||
Don't use tabs. Increment unit is two spaces.
|
|
||||||
Don't leave dandling spaces or tabs at EOL.
|
|
||||||
Helper script to get some uniformity in the style:
|
|
||||||
$ make style
|
|
||||||
|
|
||||||
If you use vim see the [Vim: How to prevent trailing whitespaces](http://www.carbon-project.org/Vim__How_to_prevent_trailing_whitespaces.html).
|
|
||||||
|
|
||||||
2. Chase warnings: no warning should be introduced by your changes
|
|
||||||
Depending what you touch, you can check with:
|
|
||||||
|
|
||||||
2.1 When using autotools
|
|
||||||
|
|
||||||
$ autoreconf -Wall -vis
|
|
||||||
|
|
||||||
2.2 When compiling
|
|
||||||
|
|
||||||
2.2.1 Using extra flags:
|
|
||||||
|
|
||||||
$ export CFLAGS="-Wall -g -O2 -Wextra -pipe -funsigned-char -fstrict-aliasing \
|
|
||||||
-Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wunused \
|
|
||||||
-Wuninitialized -Wpointer-arith -Wredundant-decls -Winline -Wformat \
|
|
||||||
-Wformat-security -Wswitch-enum -Winit-self -Wmissing-include-dirs \
|
|
||||||
-Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition \
|
|
||||||
-Wbad-function-cast -Wnested-externs -Wmissing-declarations"
|
|
||||||
$ ./configure
|
|
||||||
$ make clean
|
|
||||||
$ make
|
|
||||||
|
|
||||||
2.2.2 Using clang:
|
|
||||||
|
|
||||||
You can use same CFLAGS but also `-Wunreachable-code`
|
|
||||||
|
|
||||||
$ scan-build ./configure
|
|
||||||
$ make clean
|
|
||||||
$ scan-build make
|
|
||||||
|
|
||||||
2.2.3 Using `cppcheck` (v1.58 or higher):
|
|
||||||
|
|
||||||
$ make cppcheck
|
|
||||||
|
|
||||||
2.3 When Debianizing
|
|
||||||
|
|
||||||
$ lintian --info --display-info --display-experimental *deb
|
|
||||||
or (shorter version)
|
|
||||||
$ lintian -iIE *deb
|
|
||||||
|
|
||||||
3. Preserve cross-platform compatibility
|
|
||||||
|
|
||||||
The source code should remain compilable across various platforms,
|
|
||||||
including some you probably cannot test alone so keep it in mind.
|
|
||||||
Supported platforms:
|
|
||||||
|
|
||||||
- Linux
|
|
||||||
- FreeBSD
|
|
||||||
- Mac OS X
|
|
||||||
- Windows with MinGW
|
|
||||||
31
Makefile.am
31
Makefile.am
@ -2,13 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
|
|||||||
|
|
||||||
AM_CFLAGS = $(LIBNFC_CFLAGS)
|
AM_CFLAGS = $(LIBNFC_CFLAGS)
|
||||||
|
|
||||||
SUBDIRS = libnfc utils
|
SUBDIRS = libnfc utils examples include contrib cmake test
|
||||||
|
|
||||||
if EXAMPLE_ENABLED
|
|
||||||
SUBDIRS += examples
|
|
||||||
endif
|
|
||||||
|
|
||||||
SUBDIRS += include contrib cmake test
|
|
||||||
|
|
||||||
pkgconfigdir = $(libdir)/pkgconfig
|
pkgconfigdir = $(libdir)/pkgconfig
|
||||||
pkgconfig_DATA = libnfc.pc
|
pkgconfig_DATA = libnfc.pc
|
||||||
@ -16,12 +10,8 @@ pkgconfig_DATA = libnfc.pc
|
|||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
CMakeLists.txt \
|
CMakeLists.txt \
|
||||||
Doxyfile \
|
Doxyfile \
|
||||||
HACKING.md \
|
README-Windows.txt \
|
||||||
NEWS.md \
|
libnfc.conf.sample
|
||||||
README.md \
|
|
||||||
README-Windows.md \
|
|
||||||
libnfc.conf.sample \
|
|
||||||
mingw-cross-compile.sh
|
|
||||||
|
|
||||||
CLEANFILES = Doxygen.log coverage.info libnfc.pc
|
CLEANFILES = Doxygen.log coverage.info libnfc.pc
|
||||||
|
|
||||||
@ -44,18 +34,5 @@ style:
|
|||||||
find . -name "*.[ch]" -exec astyle --formatted --mode=c --suffix=none \
|
find . -name "*.[ch]" -exec astyle --formatted --mode=c --suffix=none \
|
||||||
--indent=spaces=2 --indent-switches --indent-preprocessor \
|
--indent=spaces=2 --indent-switches --indent-preprocessor \
|
||||||
--keep-one-line-blocks --max-instatement-indent=60 \
|
--keep-one-line-blocks --max-instatement-indent=60 \
|
||||||
--style=linux --pad-oper --unpad-paren --pad-header \
|
--brackets=linux --pad-oper --unpad-paren --pad-header \
|
||||||
--align-pointer=name {} \;
|
--align-pointer=name {} \;
|
||||||
|
|
||||||
cppcheck:
|
|
||||||
cppcheck --quiet \
|
|
||||||
-I include -I libnfc -I libnfc/buses -I libnfc/chips -I libnfc/drivers \
|
|
||||||
--check-config .
|
|
||||||
cppcheck --quiet --enable=all --std=posix --std=c99 \
|
|
||||||
-I include -I libnfc -I libnfc/buses -I libnfc/chips -I libnfc/drivers \
|
|
||||||
-DLOG -D__linux__ \
|
|
||||||
-DDRIVER_PN53X_USB_ENABLED -DDRIVER_ACR122_PCSC_ENABLED \
|
|
||||||
-DDRIVER_ACR122_USB_ENABLED -DDRIVER_ACR122S_ENABLED \
|
|
||||||
-DDRIVER_PN532_UART_ENABLED -DDRIVER_ARYGON_ENABLED \
|
|
||||||
-DDRIVER_PN532_SPI_ENABLED -DDRIVER_PN532_I2C_ENABLED \
|
|
||||||
--force --inconclusive .
|
|
||||||
|
|||||||
@ -1,55 +1,3 @@
|
|||||||
New in 1.8.0:
|
|
||||||
|
|
||||||
API Changes:
|
|
||||||
- Restore nfc_modulation_type enum order to keep compatibility with libnfc 1.7.1
|
|
||||||
- Bump library version to 6.0.0
|
|
||||||
|
|
||||||
New in 1.7.2:
|
|
||||||
|
|
||||||
Drivers:
|
|
||||||
|
|
||||||
* New driver for pn71xx NXP's NFC Controllers through Linux Libnfc-nci (untested)
|
|
||||||
* New driver for contactless PC/SC readers (only as initiator)
|
|
||||||
|
|
||||||
API Changes:
|
|
||||||
|
|
||||||
* nfc_device_get_supported_baud_rate() now takes also "mode" as argument
|
|
||||||
* New nfc_device_get_supported_baud_rate_target_mode()
|
|
||||||
* New NFC modulation type NMT_BARCODE and nfc_barcode_info struct to support Thinfilm NFC Barcode protocol
|
|
||||||
* New NFC modulation type NMT_ISO14443BICLASS and NMT_ISO14443BICLASS struct to support HID iClass (Picopass)
|
|
||||||
* pn53x_transceive() is now part of public API
|
|
||||||
|
|
||||||
New in 1.7.1:
|
|
||||||
|
|
||||||
API Changes:
|
|
||||||
|
|
||||||
* nfc_initiator_select_passive_target() provides defaults if pbtInitData=NULL
|
|
||||||
* nfc_initiator_target_is_present() allow NULL pointer to tag
|
|
||||||
|
|
||||||
New in 1.7.0:
|
|
||||||
|
|
||||||
Drivers:
|
|
||||||
|
|
||||||
* New PN532 over I2C driver, see contrib/libnfc/pn532_i2c_on_rpi.conf.sample
|
|
||||||
|
|
||||||
API Changes:
|
|
||||||
|
|
||||||
* New function iso14443b_crc_append()
|
|
||||||
|
|
||||||
New in 1.7.0-rc7:
|
|
||||||
|
|
||||||
Drivers:
|
|
||||||
|
|
||||||
* New PN532 over SPI driver, see contrib/libnfc/pn532_spi_on_rpi.conf.sample
|
|
||||||
|
|
||||||
API Changes:
|
|
||||||
|
|
||||||
* Functions
|
|
||||||
- nfc_initiator_target_is_present() & str_nfc_target():
|
|
||||||
now take a pointer to nfc_target as argument
|
|
||||||
- nfc_init(): upon malloc error, doesn't force exit() anymore
|
|
||||||
so now you should test if context != NULL after nfc_init() call
|
|
||||||
|
|
||||||
New in 1.7.0-rc5:
|
New in 1.7.0-rc5:
|
||||||
|
|
||||||
API Changes:
|
API Changes:
|
||||||
@ -71,7 +19,7 @@ Configuration:
|
|||||||
activation. This file (/etc/nfc/libnfc.conf under GNU/Linux systems)
|
activation. This file (/etc/nfc/libnfc.conf under GNU/Linux systems)
|
||||||
supports already some keywords:
|
supports already some keywords:
|
||||||
- "allow_autoscan" to enable/disable device auto-detection feature;
|
- "allow_autoscan" to enable/disable device auto-detection feature;
|
||||||
- "allow_intrusive_scan" to enable/disable intrusive auto-detection
|
- "allow_intrusive_autoscan" to enable/disable intrusive auto-detection
|
||||||
(ie. serial port probing);
|
(ie. serial port probing);
|
||||||
- "log_level" to select library verbosity;
|
- "log_level" to select library verbosity;
|
||||||
- "device.name" and "device.connstring" to define a user device,
|
- "device.name" and "device.connstring" to define a user device,
|
||||||
159
README
Normal file
159
README
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
*-
|
||||||
|
* Public platform independent Near Field Communication (NFC) library
|
||||||
|
* Copyright (C) 2009, Roel Verdult
|
||||||
|
* Copyright (C) 2010, Romain Tartière, Romuald Conty
|
||||||
|
-*
|
||||||
|
|
||||||
|
General Information
|
||||||
|
===================
|
||||||
|
|
||||||
|
libnfc is a library which allows userspace application access to NFC devices.
|
||||||
|
|
||||||
|
The official web site is:
|
||||||
|
http://www.nfc-tools.org/
|
||||||
|
|
||||||
|
The official forum site is:
|
||||||
|
http://www.libnfc.org/community/
|
||||||
|
|
||||||
|
The official development site is:
|
||||||
|
http://libnfc.googlecode.com/
|
||||||
|
|
||||||
|
Important note: this file covers POSIX systems, for Windows please read README-Windows.txt
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
============
|
||||||
|
|
||||||
|
Some NFC drivers depend on third party software:
|
||||||
|
|
||||||
|
* pn53x_usb & acr122_usb:
|
||||||
|
|
||||||
|
- libusb-0.1 http://libusb.sf.net
|
||||||
|
|
||||||
|
* acr122_pcsc:
|
||||||
|
|
||||||
|
- pcsc-lite http://pcsclite.alioth.debian.org/
|
||||||
|
|
||||||
|
The regression test suite depends on the cutter framework:
|
||||||
|
http://cutter.sf.net
|
||||||
|
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
See the file 'INSTALL' for configure, build and install details.
|
||||||
|
|
||||||
|
Additionnally, you may need to grant permissions to your user to drive your device.
|
||||||
|
Under GNU/Linux systems, if you use udev, you could use the provided udev rules.
|
||||||
|
e.g. under Debian, Ubuntu, etc.
|
||||||
|
sudo cp contrib/udev/42-pn53x.rules /lib/udev/rules.d/
|
||||||
|
|
||||||
|
Under FreeBSD, if you use devd, there is also a rules file: contrib/devd/pn53x.conf.
|
||||||
|
|
||||||
|
How to report bugs
|
||||||
|
==================
|
||||||
|
|
||||||
|
To report a bug, visit http://code.google.com/p/libnfc/issues/list and fill
|
||||||
|
out a bug report form.
|
||||||
|
|
||||||
|
If you have questions, remarks, we encourage you to post this in the developers
|
||||||
|
community:
|
||||||
|
http://www.libnfc.org/community
|
||||||
|
|
||||||
|
Please make sure to include:
|
||||||
|
|
||||||
|
* The version of libnfc
|
||||||
|
|
||||||
|
* Information about your system. For instance:
|
||||||
|
|
||||||
|
- What operating system and version
|
||||||
|
- For Linux, what version of the C library
|
||||||
|
|
||||||
|
And anything else you think is relevant.
|
||||||
|
|
||||||
|
* A trace with debug activated.
|
||||||
|
|
||||||
|
Reproduce the bug with debug, e.g. if it was:
|
||||||
|
$ nfc-list -v
|
||||||
|
run it as:
|
||||||
|
$ LIBNFC_LOG_LEVEL=3 nfc-list -v
|
||||||
|
|
||||||
|
* How to reproduce the bug.
|
||||||
|
|
||||||
|
Please include a short test program that exhibits the behavior.
|
||||||
|
As a last resort, you can also provide a pointer to a larger piece
|
||||||
|
of software that can be downloaded.
|
||||||
|
|
||||||
|
* If the bug was a crash, the exact text that was printed out
|
||||||
|
when the crash occured.
|
||||||
|
|
||||||
|
* Further information such as stack traces may be useful, but
|
||||||
|
is not necessary.
|
||||||
|
|
||||||
|
Patches
|
||||||
|
=======
|
||||||
|
|
||||||
|
Patches can be posted to http://code.google.com/p/libnfc/issues/list or
|
||||||
|
can be sent directly to libnfc's developers:
|
||||||
|
http://nfc-tools.org/index.php?title=Contact
|
||||||
|
|
||||||
|
If the patch fixes a bug, it is usually a good idea to include
|
||||||
|
all the information described in "How to Report Bugs".
|
||||||
|
|
||||||
|
Building
|
||||||
|
========
|
||||||
|
|
||||||
|
It should be as simple as running these two commands:
|
||||||
|
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
|
||||||
|
Troubleshooting
|
||||||
|
===============
|
||||||
|
|
||||||
|
Touchatag/ACR122:
|
||||||
|
-----------------
|
||||||
|
If your Touchatag or ACR122 device fails being detected by libnfc, make sure
|
||||||
|
that PCSC-lite daemon (pcscd) is installed and is running.
|
||||||
|
|
||||||
|
If your Touchatag or ACR122 device fails being detected by PCSC-lite daemon
|
||||||
|
(pcsc_scan doesn't see anything) then try removing the bogus firmware detection
|
||||||
|
of libccid: edit libccid_Info.plist configuration file (usually
|
||||||
|
/etc/libccid_Info.plist) and locate "<key>ifdDriverOptions</key>", turn
|
||||||
|
"<string>0x0000</string>" value into 0x0004 to allow bogus devices and restart
|
||||||
|
pcscd daemon.
|
||||||
|
|
||||||
|
ACR122:
|
||||||
|
-------
|
||||||
|
Using an ACR122 device with libnfc and without tag (e.g. to use NFCIP modes or
|
||||||
|
card emulation) needs yet another PCSC-lite tweak: You need to allow usage of
|
||||||
|
CCID Exchange command. To do this, edit libccid_Info.plist configuration file
|
||||||
|
(usually /etc/libccid_Info.plist) and locate "<key>ifdDriverOptions</key>",
|
||||||
|
turn "<string>0x0000</string>" value into 0x0001 to allow CCID exchange or
|
||||||
|
0x0005 to allow CCID exchange and bogus devices (cf previous remark) and
|
||||||
|
restart pcscd daemon.
|
||||||
|
|
||||||
|
Warning: if you use ACS CCID drivers (acsccid), configuration file is located
|
||||||
|
in something like: /usr/lib/pcsc/drivers/ifd-acsccid.bundle/Contents/Info.plist
|
||||||
|
|
||||||
|
SCL3711:
|
||||||
|
--------
|
||||||
|
Libnfc cannot be used concurrently with the PCSC proprietary driver of SCL3711.
|
||||||
|
Two possible solutions:
|
||||||
|
* Either you don't install SCL3711 driver at all
|
||||||
|
* Or you stop the PCSC daemon when you want to use libnfc-based tools
|
||||||
|
|
||||||
|
PN533 USB device on Linux >= 3.1:
|
||||||
|
---------------------------------
|
||||||
|
Since Linux kernel version 3.1, two kernel-modules must not be loaded in order
|
||||||
|
to use libnfc : "nfc" and "pn533".
|
||||||
|
To prevent kernel from loading automatically these modules, you can blacklist
|
||||||
|
them in a modprobe conf file. This file is provided within libnfc archive:
|
||||||
|
sudo cp contrib/linux/blacklist-libnfc.conf /etc/modprobe.d/blacklist-libnfc.conf
|
||||||
|
|
||||||
|
Proprietary Notes
|
||||||
|
=================
|
||||||
|
|
||||||
|
FeliCa is s registered trademark of the Sony Corporation.
|
||||||
|
MIFARE is a trademark of NXP Semiconductors.
|
||||||
|
Jewel Topaz is a trademark of Innovision Research & Technology.
|
||||||
|
All other trademarks are the property of their respective owners.
|
||||||
|
|
||||||
@ -1,16 +1,9 @@
|
|||||||
*-
|
*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library
|
||||||
*
|
* Windows-specific parts:
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2010, Glenn Ergeerts
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2013, Alex Lian
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
-*
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* Additional contributors of Windows-specific parts:
|
|
||||||
* Copyright (C) 2010 Glenn Ergeerts
|
|
||||||
* Copyright (C) 2013 Alex Lian
|
|
||||||
-*
|
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
============
|
============
|
||||||
@ -18,6 +11,7 @@ Requirements
|
|||||||
- MinGW-w64 compiler toolchain [1]
|
- MinGW-w64 compiler toolchain [1]
|
||||||
- LibUsb-Win32 1.2.5.0 (or greater) [2]
|
- LibUsb-Win32 1.2.5.0 (or greater) [2]
|
||||||
- CMake 2.8 [3]
|
- CMake 2.8 [3]
|
||||||
|
- PCRE for Windows [4]
|
||||||
|
|
||||||
This was tested on Windows 7 64 bit, but should work on Windows Vista and
|
This was tested on Windows 7 64 bit, but should work on Windows Vista and
|
||||||
Windows XP and 32 bit as well.
|
Windows XP and 32 bit as well.
|
||||||
@ -33,15 +27,13 @@ is an example of how to generate a distribution with the above mentioned
|
|||||||
requirements fulfilled (it is assumed the CMake binaries are in the system
|
requirements fulfilled (it is assumed the CMake binaries are in the system
|
||||||
path, this is optional during installation of CMake):
|
path, this is optional during installation of CMake):
|
||||||
|
|
||||||
- Add the following directories to your PATH:
|
- Add the following directories to your PATH : c:\MinGW64\bin;c:\MinGW64\x86_64-w64-mingw32\lib32;c:\MinGW64\x86_64-w64-mingw32\include
|
||||||
|
|
||||||
c:\MinGW64\bin;c:\MinGW64\x86_64-w64-mingw32\lib32;c:\MinGW64\x86_64-w64-mingw32\include
|
|
||||||
|
|
||||||
- Now it is possible to run CMake and mingw32-make:
|
- Now it is possible to run CMake and mingw32-make:
|
||||||
|
|
||||||
C:\dev\libnfc-read-only> mkdir ..\libnfc-build
|
C:\dev\libnfc-read-only> mkdir ..\libnfc-build
|
||||||
C:\dev\libnfc-read-only> cd ..\libnfc-build
|
C:\dev\libnfc-read-only> cd ..\libnfc-build
|
||||||
C:\dev\libnfc-build> cmake-gui .
|
C:\dev\libnfc-build> cmake-gui .
|
||||||
|
|
||||||
Now you can configure the build. Press "Configure", specify "MinGW32 Makefiles"
|
Now you can configure the build. Press "Configure", specify "MinGW32 Makefiles"
|
||||||
and then you have the opportunity to set some configuration variables. If you
|
and then you have the opportunity to set some configuration variables. If you
|
||||||
@ -49,12 +41,12 @@ don't want a Debug build change the variable CMAKE_BUILD_TYPE to "Release".
|
|||||||
|
|
||||||
If a non-GUI solution is preferred one can use:
|
If a non-GUI solution is preferred one can use:
|
||||||
|
|
||||||
C:\dev\libnfc-build> cmake -G "MinGW Makefiles"
|
C:\dev\libnfc-build> cmake -G "MinGW Makefiles"
|
||||||
-DCMAKE_BUILD_TYPE=Release ..\libnfc-read-only
|
-DCMAKE_BUILD_TYPE=Release ..\libnfc-read-only
|
||||||
|
|
||||||
Now run mingw32-make to build:
|
Now run mingw32-make to build:
|
||||||
|
|
||||||
C:\dev\libnfc-read-only\bin> mingw32-make
|
C:\dev\libnfc-read-only\bin> mingw32-make
|
||||||
|
|
||||||
The build will create a shared library for Windows (nfc.dll) to link your applications against. It will compile
|
The build will create a shared library for Windows (nfc.dll) to link your applications against. It will compile
|
||||||
the tools against this shared library.
|
the tools against this shared library.
|
||||||
@ -64,7 +56,6 @@ References
|
|||||||
[1] the easiest way is to use the TDM-GCC installer.
|
[1] the easiest way is to use the TDM-GCC installer.
|
||||||
Make sure to select MinGW-w64 in the installer, the regular MinGW does not contain headers for PCSC.
|
Make sure to select MinGW-w64 in the installer, the regular MinGW does not contain headers for PCSC.
|
||||||
http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm64-gcc-4.5.1.exe/download
|
http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm64-gcc-4.5.1.exe/download
|
||||||
|
|
||||||
[2] http://sourceforge.net/projects/libusb-win32/files/
|
[2] http://sourceforge.net/projects/libusb-win32/files/
|
||||||
|
|
||||||
[3] http://www.cmake.org
|
[3] http://www.cmake.org
|
||||||
|
[4] http://gnuwin32.sourceforge.net/packages/pcre.htm
|
||||||
250
README.md
250
README.md
@ -1,250 +0,0 @@
|
|||||||
```
|
|
||||||
*-
|
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
|
||||||
*
|
|
||||||
* Libnfc historical contributors:
|
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2015 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* Additional contributors:
|
|
||||||
* See AUTHORS file
|
|
||||||
-*
|
|
||||||
```
|
|
||||||
|
|
||||||
General Information
|
|
||||||
===================
|
|
||||||
|
|
||||||
libnfc is a library which allows userspace application access to NFC devices.
|
|
||||||
|
|
||||||
The official web site is:
|
|
||||||
http://www.nfc-tools.org/
|
|
||||||
|
|
||||||
The official forum site is:
|
|
||||||
http://www.libnfc.org/community/
|
|
||||||
|
|
||||||
The official development site is:
|
|
||||||
https://github.com/nfc-tools/libnfc
|
|
||||||
|
|
||||||
Important note: this file covers POSIX systems, for Windows please read README-Windows.md
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
============
|
|
||||||
|
|
||||||
Some NFC drivers depend on third party software:
|
|
||||||
|
|
||||||
* pn53x_usb & acr122_usb:
|
|
||||||
|
|
||||||
- libusb-0.1 http://libusb.sf.net
|
|
||||||
|
|
||||||
* acr122_pcsc:
|
|
||||||
|
|
||||||
- pcsc-lite https://pcsclite.apdu.fr/
|
|
||||||
- pcsc:
|
|
||||||
|
|
||||||
- Support build with pcsc driver, which can be using all compatible readers, Feitian R502 and bR500 already passed the test.
|
|
||||||
|
|
||||||
The regression test suite depends on the cutter framework:
|
|
||||||
http://cutter.sf.net
|
|
||||||
|
|
||||||
Building
|
|
||||||
========
|
|
||||||
|
|
||||||
Note: If working directly from a git clone of the repository, some of the files need to be generated first. To do this run
|
|
||||||
`autoreconf -vis`
|
|
||||||
|
|
||||||
Alternatively use a .tar.bz2 version of a packaged release (which already contains ./configure):
|
|
||||||
https://github.com/nfc-tools/libnfc/releases/
|
|
||||||
|
|
||||||
The build should be as simple as running these commands:
|
|
||||||
|
|
||||||
./configure
|
|
||||||
make
|
|
||||||
|
|
||||||
|
|
||||||
To build with specific driver(s), see option `--with-drivers=...` detailed in `./configure --help`.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
make install
|
|
||||||
|
|
||||||
You may need to grant permissions to your user to drive your device.
|
|
||||||
Under GNU/Linux systems, if you use udev, you could use the provided udev rules.
|
|
||||||
e.g. under Debian, Ubuntu, etc.
|
|
||||||
|
|
||||||
sudo cp contrib/udev/93-pn53x.rules /lib/udev/rules.d/
|
|
||||||
|
|
||||||
Under FreeBSD, if you use devd, there is also a rules file: contrib/devd/pn53x.conf.
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
=============
|
|
||||||
|
|
||||||
In order to change the default behavior of the library, the libnfc uses a
|
|
||||||
configuration file located in sysconfdir (as provided to ./configure).
|
|
||||||
|
|
||||||
A sample commented file is available in sources: libnfc.conf.sample
|
|
||||||
|
|
||||||
If you have compiled using:
|
|
||||||
|
|
||||||
./configure --prefix=/usr --sysconfdir=/etc
|
|
||||||
|
|
||||||
you can make configuration directory and copy the sample file:
|
|
||||||
|
|
||||||
sudo mkdir /etc/nfc
|
|
||||||
sudo cp libnfc.conf.sample /etc/nfc/libnfc.conf
|
|
||||||
|
|
||||||
To configure multiple devices, you can either modify libnfc.conf or create a
|
|
||||||
file per device in a nfc/devices.d directory:
|
|
||||||
|
|
||||||
sudo mkdir -p /etc/nfc/devices.d
|
|
||||||
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
|
|
||||||
==================
|
|
||||||
|
|
||||||
To report a bug, visit https://github.com/nfc-tools/libnfc/issues and fill
|
|
||||||
out a bug report form.
|
|
||||||
|
|
||||||
If you have questions, remarks, we encourage you to post this in the developers
|
|
||||||
community:
|
|
||||||
http://www.libnfc.org/community
|
|
||||||
|
|
||||||
Please make sure to include:
|
|
||||||
|
|
||||||
* The version of libnfc
|
|
||||||
|
|
||||||
* Information about your system. For instance:
|
|
||||||
|
|
||||||
- What operating system and version
|
|
||||||
- For Linux, what version of the C library
|
|
||||||
|
|
||||||
And anything else you think is relevant.
|
|
||||||
|
|
||||||
* A trace with debug activated.
|
|
||||||
|
|
||||||
Reproduce the bug with debug, e.g. if it was:
|
|
||||||
|
|
||||||
$ nfc-list -v
|
|
||||||
|
|
||||||
run it as:
|
|
||||||
|
|
||||||
$ LIBNFC_LOG_LEVEL=3 nfc-list -v
|
|
||||||
|
|
||||||
* How to reproduce the bug.
|
|
||||||
|
|
||||||
Please include a short test program that exhibits the behavior.
|
|
||||||
|
|
||||||
As a last resort, you can also provide a pointer to a larger piece
|
|
||||||
|
|
||||||
of software that can be downloaded.
|
|
||||||
|
|
||||||
* If the bug was a crash, the exact text that was printed out
|
|
||||||
|
|
||||||
when the crash occured.
|
|
||||||
|
|
||||||
* Further information such as stack traces may be useful, but
|
|
||||||
|
|
||||||
is not necessary.
|
|
||||||
|
|
||||||
Patches
|
|
||||||
=======
|
|
||||||
|
|
||||||
Patches can be posted to https://github.com/nfc-tools/libnfc/issues
|
|
||||||
|
|
||||||
If the patch fixes a bug, it is usually a good idea to include
|
|
||||||
all the information described in "How to Report Bugs".
|
|
||||||
|
|
||||||
Troubleshooting
|
|
||||||
===============
|
|
||||||
|
|
||||||
Touchatag/ACR122:
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
If your Touchatag or ACR122 device fails being detected by libnfc, make sure
|
|
||||||
that PCSC-lite daemon (`pcscd`) is installed and is running.
|
|
||||||
|
|
||||||
If your Touchatag or ACR122 device fails being detected by PCSC-lite daemon
|
|
||||||
(`pcsc_scan` doesn't see anything) then try removing the bogus firmware detection
|
|
||||||
of libccid: edit libccid_Info.plist configuration file (usually
|
|
||||||
`/etc/libccid_Info.plist`) and locate `<key>ifdDriverOptions</key>`, turn
|
|
||||||
`<string>0x0000</string>` value into `0x0004` to allow bogus devices and restart
|
|
||||||
pcscd daemon.
|
|
||||||
|
|
||||||
ACR122:
|
|
||||||
-------
|
|
||||||
|
|
||||||
Using an ACR122 device with libnfc and without tag (e.g. to use NFCIP modes or
|
|
||||||
card emulation) needs yet another PCSC-lite tweak: You need to allow usage of
|
|
||||||
CCID Exchange command. To do this, edit `libccid_Info.plist` configuration file
|
|
||||||
(usually `/etc/libccid_Info.plist`) and locate `<key>ifdDriverOptions</key>`,
|
|
||||||
turn `<string>0x0000</string>` value into `0x0001` to allow CCID exchange or
|
|
||||||
`0x0005` to allow CCID exchange and bogus devices (cf previous remark) and
|
|
||||||
restart pcscd daemon.
|
|
||||||
|
|
||||||
Warning: if you use ACS CCID drivers (acsccid), configuration file is located
|
|
||||||
in something like: `/usr/lib/pcsc/drivers/ifd-acsccid.bundle/Contents/Info.plist`
|
|
||||||
|
|
||||||
SCL3711:
|
|
||||||
--------
|
|
||||||
|
|
||||||
Libnfc cannot be used concurrently with the PCSC proprietary driver of SCL3711.
|
|
||||||
Two possible solutions:
|
|
||||||
|
|
||||||
* Either you don't install SCL3711 driver at all
|
|
||||||
* Or you stop the PCSC daemon when you want to use libnfc-based tools
|
|
||||||
|
|
||||||
PN533 USB device on Linux >= 3.1:
|
|
||||||
---------------------------------
|
|
||||||
|
|
||||||
Since Linux kernel version 3.1, a few kernel-modules must not be loaded in order
|
|
||||||
to use libnfc : "nfc", "pn533" and "pn533_usb".
|
|
||||||
To prevent kernel from loading automatically these modules, you can blacklist
|
|
||||||
them in a modprobe conf file. This file is provided within libnfc archive:
|
|
||||||
|
|
||||||
sudo cp contrib/linux/blacklist-libnfc.conf /etc/modprobe.d/blacklist-libnfc.conf
|
|
||||||
|
|
||||||
FEITIAN bR500 and R502:
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
Libnfc can work with PCSC proprietary driver of bR500 and R502, which is already available on most Linux setups.
|
|
||||||
To activate the PCSC support: `./configure --with-drivers=pcsc`.
|
|
||||||
Readers known to work:
|
|
||||||
|
|
||||||
- Feitian bR500
|
|
||||||
- Feitian R502 Dual interface reader
|
|
||||||
- Feitian R502 CL(Contactless) reader
|
|
||||||
|
|
||||||
These readers are support by CCID since v1.4.25, make sure your CCID driver version higher or equal to 1.4.25.
|
|
||||||
|
|
||||||
On MacOS, you can check your CCID version with the following command, and if required, you can install latest CCID driver from [https://github.com/martinpaljak/osx-ccid-installer/releases](https://github.com/martinpaljak/osx-ccid-installer/releases)
|
|
||||||
|
|
||||||
```
|
|
||||||
grep -A 1 CFBundleShortVersionString /usr/local/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist
|
|
||||||
```
|
|
||||||
|
|
||||||
On Linux, you can check your CCID version with the following command, and if required, you can install latest CCID driver from [https://ccid.apdu.fr/](https://ccid.apdu.fr/)
|
|
||||||
|
|
||||||
```
|
|
||||||
grep -A 1 CFBundleShortVersionString /usr/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist
|
|
||||||
```
|
|
||||||
|
|
||||||
Proprietary Notes
|
|
||||||
=================
|
|
||||||
FeliCa is a registered trademark of the Sony Corporation.
|
|
||||||
MIFARE is a trademark of NXP Semiconductors.
|
|
||||||
Jewel Topaz is a trademark of Innovision Research & Technology.
|
|
||||||
All other trademarks are the property of their respective owners.
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
# -*- cmake -*-
|
|
||||||
|
|
||||||
|
|
||||||
# Use the following variables to compile and link against LibNFC:
|
|
||||||
# LIBNFC_FOUND - True if LibNFC was found on your system
|
|
||||||
# LIBNFC_USE_FILE - The file making LibNFC usable
|
|
||||||
# LIBNFC_DEFINITIONS - Definitions needed to build with LibNFC
|
|
||||||
# LIBNFC_INCLUDE_DIR - Directory where nfc/nfc.h can be found
|
|
||||||
# LIBNFC_INCLUDE_DIRS - List of directories of LibNFC and it's dependencies
|
|
||||||
# LIBNFC_LIBRARY - LibNFC library location
|
|
||||||
# LIBNFC_LIBRARIES - List of libraries to link against LibNFC library
|
|
||||||
# LIBNFC_LIBRARY_DIRS - List of directories containing LibNFC' libraries
|
|
||||||
# LIBNFC_ROOT_DIR - The base directory of LibNFC
|
|
||||||
# LIBNFC_VERSION_STRING - A human-readable string containing the version
|
|
||||||
# LIBNFC_VERSION_MAJOR - The major version of LibNFC
|
|
||||||
# LIBNFC_VERSION_MINOR - The minor version of LibNFC
|
|
||||||
# LIBNFC_VERSION_PATCH - The patch version of LibNFC
|
|
||||||
|
|
||||||
set ( LIBNFC_FOUND 1 )
|
|
||||||
set ( LIBNFC_USE_FILE "@LIBNFC_USE_FILE@" )
|
|
||||||
|
|
||||||
set ( LIBNFC_DEFINITIONS "@LIBNFC_DEFINITIONS@" )
|
|
||||||
set ( LIBNFC_INCLUDE_DIR "@LIBNFC_INCLUDE_DIR@" )
|
|
||||||
set ( LIBNFC_INCLUDE_DIRS "@LIBNFC_INCLUDE_DIRS@" )
|
|
||||||
set ( LIBNFC_LIBRARY "@LIBNFC_LIBRARY@" )
|
|
||||||
set ( LIBNFC_LIBRARIES "@LIBNFC_LIBRARIES@" )
|
|
||||||
set ( LIBNFC_LIBRARY_DIRS "@LIBNFC_LIBRARY_DIRS@" )
|
|
||||||
set ( LIBNFC_ROOT_DIR "@LIBNFC_ROOT_DIR@" )
|
|
||||||
|
|
||||||
set ( LIBNFC_VERSION_STRING "@LIBNFC_VERSION_STRING@" )
|
|
||||||
set ( LIBNFC_VERSION_MAJOR "@LIBNFC_VERSION_MAJOR@" )
|
|
||||||
set ( LIBNFC_VERSION_MINOR "@LIBNFC_VERSION_MINOR@" )
|
|
||||||
set ( LIBNFC_VERSION_PATCH "@LIBNFC_VERSION_PATCH@" )
|
|
||||||
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
# This is a basic version file for the Config-mode of find_package().
|
|
||||||
# It is used by write_basic_package_version_file() as input file for configure_file()
|
|
||||||
# to create a version-file which can be installed along a config.cmake file.
|
|
||||||
#
|
|
||||||
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
|
|
||||||
# the requested version string are exactly the same and it sets
|
|
||||||
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
|
|
||||||
# The variable CVF_VERSION must be set before calling configure_file().
|
|
||||||
|
|
||||||
set(PACKAGE_VERSION "@LIBNFC_VERSION_STRING@")
|
|
||||||
|
|
||||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
|
||||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
|
||||||
else()
|
|
||||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
|
||||||
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
|
|
||||||
set(PACKAGE_VERSION_EXACT TRUE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
|
||||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
|
||||||
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
|
||||||
math(EXPR installedBits "8 * 8")
|
|
||||||
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
|
||||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
|
||||||
endif()
|
|
||||||
@ -3,7 +3,4 @@ SUBDIRS = modules
|
|||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
FixBundle.cmake.in \
|
FixBundle.cmake.in \
|
||||||
config_posix.h.cmake \
|
config_posix.h.cmake \
|
||||||
config_windows.h.cmake \
|
config_windows.h.cmake
|
||||||
LibNFCConfig.cmake.in \
|
|
||||||
LibNFCConfigVersion.cmake.in \
|
|
||||||
UseLibNFC.cmake
|
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
# -*- cmake -*-
|
|
||||||
|
|
||||||
add_definitions ( ${LIBNFC_DEFINITIONS} )
|
|
||||||
include_directories ( ${LIBNFC_INCLUDE_DIRS} )
|
|
||||||
link_directories ( ${LIBNFC_LIBRARY_DIRS} )
|
|
||||||
@ -26,17 +26,9 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
|
|||||||
|
|
||||||
IF(NOT LIBUSB_FOUND)
|
IF(NOT LIBUSB_FOUND)
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
IF(MINGW)
|
FIND_PATH(LIBUSB_INCLUDE_DIRS lusb0_usb.h "$ENV{ProgramFiles}/LibUSB-Win32/include" NO_SYSTEM_ENVIRONMENT_PATH)
|
||||||
FIND_PATH(LIBUSB_INCLUDE_DIRS lusb0_usb.h "${CMAKE_CURRENT_BINARY_DIR}/LibUSB-Win32/include" NO_SYSTEM_ENVIRONMENT_PATH)
|
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramFiles}/LibUSB-Win32/lib/gcc")
|
||||||
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "${CMAKE_CURRENT_BINARY_DIR}/LibUSB-Win32/lib/gcc")
|
SET(LIBUSB_LIBRARY_DIR "$ENV{ProgramFiles}/LibUSB-Win32/bin/x86/")
|
||||||
SET(LIBUSB_LIBRARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/LibUSB-Win32/bin/x86/")
|
|
||||||
ELSE(MINGW)
|
|
||||||
FIND_PATH(LIBUSB_INCLUDE_DIRS lusb0_usb.h "$ENV{ProgramW6432}/libusb-win32/include" NO_SYSTEM_ENVIRONMENT_PATH)
|
|
||||||
FIND_LIBRARY(LIBUSB_LIBRARIES NAMES libusb PATHS "$ENV{ProgramW6432}/libusb-win32/lib/msvc_x64")
|
|
||||||
SET(LIBUSB_LIBRARY_DIR "$ENV{ProgramW6432}/libusb-win32/bin/amd64/")
|
|
||||||
ENDIF(MINGW)
|
|
||||||
# Must fix up variable to avoid backslashes during packaging
|
|
||||||
STRING(REGEX REPLACE "\\\\" "/" LIBUSB_LIBRARY_DIR ${LIBUSB_LIBRARY_DIR})
|
|
||||||
ELSE(WIN32)
|
ELSE(WIN32)
|
||||||
# If not under Windows we use PkgConfig
|
# If not under Windows we use PkgConfig
|
||||||
FIND_PACKAGE (PkgConfig)
|
FIND_PACKAGE (PkgConfig)
|
||||||
|
|||||||
40
cmake/modules/FindPCRE.cmake
Normal file
40
cmake/modules/FindPCRE.cmake
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# This CMake script wants to use pcre functionality needed for windows
|
||||||
|
# compilation. However, since PCRE isn't really a default install location
|
||||||
|
# there isn't much to search.
|
||||||
|
#
|
||||||
|
# Operating Systems Supported:
|
||||||
|
# - Windows (requires MinGW)
|
||||||
|
# Tested with Windows XP/Windows 7
|
||||||
|
#
|
||||||
|
# This should work for both 32 bit and 64 bit systems.
|
||||||
|
#
|
||||||
|
# Author: A. Lian <alex.lian@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
IF(NOT PCRE_FOUND)
|
||||||
|
FIND_PATH(PCRE_INCLUDE_DIRS regex.h)
|
||||||
|
FIND_LIBRARY(PCRE_LIBRARIES NAMES PCRE pcre)
|
||||||
|
|
||||||
|
IF(PCRE_INCLUDE_DIRS AND PCRE_LIBRARIES)
|
||||||
|
SET(PCRE_FOUND TRUE)
|
||||||
|
ENDIF(PCRE_INCLUDE_DIRS AND PCRE_LIBRARIES)
|
||||||
|
ENDIF(NOT PCRE_FOUND)
|
||||||
|
|
||||||
|
IF(PCRE_FOUND)
|
||||||
|
IF(NOT PCRE_FIND_QUIETLY)
|
||||||
|
MESSAGE(STATUS "Found PCRE: ${PCRE_LIBRARIES} ${PCRE_INCLUDE_DIRS}")
|
||||||
|
ENDIF (NOT PCRE_FIND_QUIETLY)
|
||||||
|
ELSE(PCRE_FOUND)
|
||||||
|
IF(PCRE_FIND_REQUIRED)
|
||||||
|
MESSAGE(FATAL_ERROR "Could not find PCRE")
|
||||||
|
ENDIF(PCRE_FIND_REQUIRED)
|
||||||
|
ENDIF(PCRE_FOUND)
|
||||||
|
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG
|
||||||
|
PCRE_LIBRARIES
|
||||||
|
PCRE_INCLUDE_DIRS
|
||||||
|
)
|
||||||
|
|
||||||
|
ENDIF(WIN32)
|
||||||
@ -1,23 +1,8 @@
|
|||||||
SET(LIBNFC_DRIVER_PCSC OFF CACHE BOOL "Enable PC/SC reader support (Depends on PC/SC)")
|
SET(LIBNFC_DRIVER_ACR122_PCSC ON CACHE BOOL "Enable ACR122 support (Depends on PC/SC)")
|
||||||
SET(LIBNFC_DRIVER_ACR122_PCSC OFF CACHE BOOL "Enable ACR122 support (Depends on PC/SC)")
|
#SET(LIBNFC_DRIVER_ACR122_USB ON CACHE BOOL "Enable ACR122 support (Direct USB connection)")
|
||||||
SET(LIBNFC_DRIVER_ACR122_USB ON CACHE BOOL "Enable ACR122 support (Direct USB connection)")
|
|
||||||
SET(LIBNFC_DRIVER_ACR122S ON CACHE BOOL "Enable ACR122S support (Use serial port)")
|
|
||||||
SET(LIBNFC_DRIVER_ARYGON ON CACHE BOOL "Enable ARYGON support (Use serial port)")
|
|
||||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
SET(LIBNFC_DRIVER_PN532_I2C ON CACHE BOOL "Enable PN532 I2C support (Use I2C bus)")
|
|
||||||
SET(LIBNFC_DRIVER_PN532_SPI ON CACHE BOOL "Enable PN532 SPI support (Use SPI bus)")
|
|
||||||
ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
SET(LIBNFC_DRIVER_PN532_I2C OFF CACHE BOOL "Enable PN532 I2C support (Use I2C bus)")
|
|
||||||
SET(LIBNFC_DRIVER_PN532_SPI OFF CACHE BOOL "Enable PN532 SPI support (Use SPI bus)")
|
|
||||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
SET(LIBNFC_DRIVER_PN532_UART ON CACHE BOOL "Enable PN532 UART support (Use serial port)")
|
|
||||||
SET(LIBNFC_DRIVER_PN53X_USB ON CACHE BOOL "Enable PN531 and PN531 USB support (Depends on libusb)")
|
SET(LIBNFC_DRIVER_PN53X_USB ON CACHE BOOL "Enable PN531 and PN531 USB support (Depends on libusb)")
|
||||||
|
SET(LIBNFC_DRIVER_ARYGON ON CACHE BOOL "Enable ARYGON support (Use serial port)")
|
||||||
IF(LIBNFC_DRIVER_PCSC)
|
SET(LIBNFC_DRIVER_PN532_UART OFF CACHE BOOL "Enable PN532 UART support (Use serial port)")
|
||||||
FIND_PACKAGE(PCSC REQUIRED)
|
|
||||||
ADD_DEFINITIONS("-DDRIVER_PCSC_ENABLED")
|
|
||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pcsc")
|
|
||||||
ENDIF(LIBNFC_DRIVER_PCSC)
|
|
||||||
|
|
||||||
IF(LIBNFC_DRIVER_ACR122_PCSC)
|
IF(LIBNFC_DRIVER_ACR122_PCSC)
|
||||||
FIND_PACKAGE(PCSC REQUIRED)
|
FIND_PACKAGE(PCSC REQUIRED)
|
||||||
@ -25,54 +10,21 @@ IF(LIBNFC_DRIVER_ACR122_PCSC)
|
|||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122_pcsc")
|
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122_pcsc")
|
||||||
ENDIF(LIBNFC_DRIVER_ACR122_PCSC)
|
ENDIF(LIBNFC_DRIVER_ACR122_PCSC)
|
||||||
|
|
||||||
IF(LIBNFC_DRIVER_ACR122_USB)
|
|
||||||
FIND_PACKAGE(LIBUSB REQUIRED)
|
|
||||||
ADD_DEFINITIONS("-DDRIVER_ACR122_USB_ENABLED")
|
|
||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122_usb")
|
|
||||||
ENDIF(LIBNFC_DRIVER_ACR122_USB)
|
|
||||||
|
|
||||||
IF(LIBNFC_DRIVER_ACR122S)
|
|
||||||
ADD_DEFINITIONS("-DDRIVER_ACR122S_ENABLED")
|
|
||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122s")
|
|
||||||
SET(UART_REQUIRED TRUE)
|
|
||||||
ENDIF(LIBNFC_DRIVER_ACR122S)
|
|
||||||
|
|
||||||
IF(LIBNFC_DRIVER_ARYGON)
|
|
||||||
ADD_DEFINITIONS("-DDRIVER_ARYGON_ENABLED")
|
|
||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/arygon")
|
|
||||||
SET(UART_REQUIRED TRUE)
|
|
||||||
ENDIF(LIBNFC_DRIVER_ARYGON)
|
|
||||||
|
|
||||||
IF(LIBNFC_DRIVER_PN532_I2C)
|
|
||||||
ADD_DEFINITIONS("-DDRIVER_PN532_I2C_ENABLED")
|
|
||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_i2c")
|
|
||||||
SET(I2C_REQUIRED TRUE)
|
|
||||||
ENDIF(LIBNFC_DRIVER_PN532_I2C)
|
|
||||||
|
|
||||||
IF(LIBNFC_DRIVER_PN532_SPI)
|
|
||||||
ADD_DEFINITIONS("-DDRIVER_PN532_SPI_ENABLED")
|
|
||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_spi")
|
|
||||||
SET(SPI_REQUIRED TRUE)
|
|
||||||
ENDIF(LIBNFC_DRIVER_PN532_SPI)
|
|
||||||
|
|
||||||
IF(LIBNFC_DRIVER_PN532_UART)
|
|
||||||
ADD_DEFINITIONS("-DDRIVER_PN532_UART_ENABLED")
|
|
||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_uart")
|
|
||||||
SET(UART_REQUIRED TRUE)
|
|
||||||
ENDIF(LIBNFC_DRIVER_PN532_UART)
|
|
||||||
|
|
||||||
IF(LIBNFC_DRIVER_PN53X_USB)
|
IF(LIBNFC_DRIVER_PN53X_USB)
|
||||||
FIND_PACKAGE(LIBUSB REQUIRED)
|
FIND_PACKAGE(LIBUSB REQUIRED)
|
||||||
ADD_DEFINITIONS("-DDRIVER_PN53X_USB_ENABLED")
|
ADD_DEFINITIONS("-DDRIVER_PN53X_USB_ENABLED")
|
||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn53x_usb")
|
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn53x_usb")
|
||||||
SET(USB_REQUIRED TRUE)
|
|
||||||
ENDIF(LIBNFC_DRIVER_PN53X_USB)
|
ENDIF(LIBNFC_DRIVER_PN53X_USB)
|
||||||
|
|
||||||
IF(LIBNFC_DRIVER_ACR122_USB)
|
IF(LIBNFC_DRIVER_ARYGON)
|
||||||
FIND_PACKAGE(LIBUSB REQUIRED)
|
ADD_DEFINITIONS("-DDRIVER_ARYGON_ENABLED")
|
||||||
ADD_DEFINITIONS("-DDRIVER_ACR122_USB_ENABLED")
|
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/arygon")
|
||||||
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/acr122_usb")
|
ENDIF(LIBNFC_DRIVER_ARYGON)
|
||||||
SET(USB_REQUIRED TRUE)
|
|
||||||
ENDIF(LIBNFC_DRIVER_ACR122_USB)
|
IF(LIBNFC_DRIVER_PN532_UART)
|
||||||
|
ADD_DEFINITIONS("-DDRIVER_PN532_UART_ENABLED")
|
||||||
|
SET(DRIVERS_SOURCES ${DRIVERS_SOURCES} "drivers/pn532_uart")
|
||||||
|
ENDIF(LIBNFC_DRIVER_PN532_UART)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/drivers)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/libnfc/drivers)
|
|
||||||
|
|||||||
@ -2,5 +2,6 @@ EXTRA_DIST = \
|
|||||||
COPYING-CMAKE-SCRIPTS \
|
COPYING-CMAKE-SCRIPTS \
|
||||||
FindLIBUSB.cmake \
|
FindLIBUSB.cmake \
|
||||||
FindPCSC.cmake \
|
FindPCSC.cmake \
|
||||||
|
FindPCRE.cmake \
|
||||||
UseDoxygen.cmake \
|
UseDoxygen.cmake \
|
||||||
LibnfcDrivers.cmake
|
LibnfcDrivers.cmake
|
||||||
|
|||||||
@ -91,7 +91,8 @@ if(DOXYGEN_FOUND AND DOXYFILE_IN)
|
|||||||
|
|
||||||
configure_file(${DOXYFILE_IN} Doxyfile ESCAPE_QUOTES IMMEDIATE @ONLY)
|
configure_file(${DOXYFILE_IN} Doxyfile ESCAPE_QUOTES IMMEDIATE @ONLY)
|
||||||
|
|
||||||
if(NOT TARGET doc)
|
get_target_property(DOC_TARGET doc TYPE)
|
||||||
|
if(NOT DOC_TARGET)
|
||||||
add_custom_target(doc)
|
add_custom_target(doc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
70
configure.ac
70
configure.ac
@ -1,7 +1,7 @@
|
|||||||
# General init
|
# General init
|
||||||
|
|
||||||
# /!\ Don't forget to update 'CMakeLists.txt' too /!\
|
# /!\ Don't forget to update 'CMakeLists.txt' too /!\
|
||||||
AC_INIT([libnfc],[1.8.0],[nfc-tools@googlegroups.com])
|
AC_INIT([libnfc],[1.7.0-rc5],[info@libnfc.org])
|
||||||
|
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ if test x"$GIT_REVISION" != x""; then
|
|||||||
AC_DEFINE_UNQUOTED([GIT_REVISION], ["$GIT_REVISION"], [GIT revision])
|
AC_DEFINE_UNQUOTED([GIT_REVISION], ["$GIT_REVISION"], [GIT revision])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE(subdir-objects dist-bzip2 no-dist-gzip foreign)
|
AM_INIT_AUTOMAKE
|
||||||
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||||
|
|
||||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
||||||
@ -39,15 +39,15 @@ case "$host" in
|
|||||||
esac
|
esac
|
||||||
AM_CONDITIONAL(POSIX_ONLY_EXAMPLES_ENABLED, [test "$WITH_POSIX_ONLY_EXAMPLES" = "1"])
|
AM_CONDITIONAL(POSIX_ONLY_EXAMPLES_ENABLED, [test "$WITH_POSIX_ONLY_EXAMPLES" = "1"])
|
||||||
|
|
||||||
PKG_PROG_PKG_CONFIG
|
AC_PATH_PROG(PKG_CONFIG, pkg-config)
|
||||||
|
if test x"$PKG_CONFIG" = x""; then
|
||||||
|
AC_MSG_ERROR([pkg-config not found.])
|
||||||
|
fi
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_HEADER_STDBOOL
|
AC_HEADER_STDBOOL
|
||||||
AC_CHECK_HEADERS([fcntl.h limits.h stdio.h stdlib.h stdint.h stddef.h stdbool.h sys/ioctl.h sys/param.h sys/time.h termios.h])
|
AC_CHECK_HEADERS([fcntl.h limits.h stdio.h stdlib.h stdint.h stddef.h stdbool.h sys/ioctl.h sys/param.h sys/time.h termios.h])
|
||||||
AC_CHECK_HEADERS([linux/spi/spidev.h], [spi_available="yes"])
|
|
||||||
AC_CHECK_HEADERS([linux/i2c-dev.h], [i2c_available="yes"])
|
|
||||||
AC_CHECK_HEADERS([linux_nfc_api.h], [nfc_nci_available="yes"])
|
|
||||||
AC_CHECK_FUNCS([memmove memset select strdup strerror strstr strtol usleep],
|
AC_CHECK_FUNCS([memmove memset select strdup strerror strstr strtol usleep],
|
||||||
[AC_DEFINE([_XOPEN_SOURCE], [600], [Enable POSIX extensions if present])])
|
[AC_DEFINE([_XOPEN_SOURCE], [600], [Enable POSIX extensions if present])])
|
||||||
|
|
||||||
@ -81,28 +81,6 @@ then
|
|||||||
AC_DEFINE([LOG], [1], [Enable log])
|
AC_DEFINE([LOG], [1], [Enable log])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Conffiles support (default:yes)
|
|
||||||
AC_ARG_ENABLE([conffiles],AS_HELP_STRING([--disable-conffiles],[Disable use of config files]),[enable_conffiles=$enableval],[enable_conffiles="yes"])
|
|
||||||
AC_MSG_CHECKING(for conffiles flag)
|
|
||||||
AC_MSG_RESULT($enable_conffiles)
|
|
||||||
AM_CONDITIONAL([WITH_CONFFILES], [test "$enable_conffiles" != "no"])
|
|
||||||
|
|
||||||
if test x"$enable_conffiles" = "xyes"
|
|
||||||
then
|
|
||||||
AC_DEFINE([CONFFILES], [1], [Enable conffiles])
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Envvars support (default:yes)
|
|
||||||
AC_ARG_ENABLE([envvars],AS_HELP_STRING([--disable-envvars],[Disable use of environment variables]),[enable_envvars=$enableval],[enable_envvars="yes"])
|
|
||||||
AC_MSG_CHECKING(for envvars flag)
|
|
||||||
AC_MSG_RESULT($enable_envvars)
|
|
||||||
AM_CONDITIONAL([WITH_ENVVARS], [test "$enable_envvars" != "no"])
|
|
||||||
|
|
||||||
if test x"$enable_envvars" = "xyes"
|
|
||||||
then
|
|
||||||
AC_DEFINE([ENVVARS], [1], [Enable envvars])
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Debug support (default:no)
|
# Debug support (default:no)
|
||||||
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Enable debug mode]),[enable_debug=$enableval],[enable_debug="no"])
|
AC_ARG_ENABLE([debug],AS_HELP_STRING([--enable-debug],[Enable debug mode]),[enable_debug=$enableval],[enable_debug="no"])
|
||||||
AC_MSG_CHECKING(for debug flag)
|
AC_MSG_CHECKING(for debug flag)
|
||||||
@ -118,29 +96,6 @@ fi
|
|||||||
# Handle --with-drivers option
|
# Handle --with-drivers option
|
||||||
LIBNFC_ARG_WITH_DRIVERS
|
LIBNFC_ARG_WITH_DRIVERS
|
||||||
|
|
||||||
# Enable UART if
|
|
||||||
AM_CONDITIONAL(UART_ENABLED, [test x"$uart_required" = x"yes"])
|
|
||||||
|
|
||||||
# Enable SPI if
|
|
||||||
AM_CONDITIONAL(SPI_ENABLED, [test x"$spi_required" = x"yes"])
|
|
||||||
|
|
||||||
# Enable I2C if
|
|
||||||
AM_CONDITIONAL(I2C_ENABLED, [test x"$i2c_required" = x"yes"])
|
|
||||||
if test x"$i2c_required" = x"yes"
|
|
||||||
then
|
|
||||||
AC_SEARCH_LIBS([clock_gettime], [rt])
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enable Libnfc-NCI if required
|
|
||||||
if test x"$nfc_nci_required" = x"yes"
|
|
||||||
then
|
|
||||||
PKG_CHECK_MODULES([LIBNFC_NCI], [libnfc-nci],
|
|
||||||
[AC_MSG_NOTICE([libnfc-nci present])],
|
|
||||||
[AC_MSG_ERROR([libnfc-nci not present but required for some drivers configuration])]
|
|
||||||
)
|
|
||||||
CFLAGS="$CFLAGS $LIBNFC_NCI_CFLAGS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Documentation (default: no)
|
# Documentation (default: no)
|
||||||
AC_ARG_ENABLE([doc],AS_HELP_STRING([--enable-doc],[Enable documentation generation.]),[enable_doc=$enableval],[enable_doc="no"])
|
AC_ARG_ENABLE([doc],AS_HELP_STRING([--enable-doc],[Enable documentation generation.]),[enable_doc=$enableval],[enable_doc="no"])
|
||||||
|
|
||||||
@ -157,14 +112,6 @@ then
|
|||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(DOC_ENABLED, [test x"$enable_doc" = xyes])
|
AM_CONDITIONAL(DOC_ENABLED, [test x"$enable_doc" = xyes])
|
||||||
|
|
||||||
# Example build (default: yes)
|
|
||||||
AC_ARG_ENABLE([example],AS_HELP_STRING([--enable-example],[Enable example build.]),[enable_example=$enableval],[enable_example="yes"])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING(for example build)
|
|
||||||
AC_MSG_RESULT($enable_example)
|
|
||||||
|
|
||||||
AM_CONDITIONAL(EXAMPLE_ENABLED, [test x"$enable_example" = xyes])
|
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
PKG_CONFIG_REQUIRES=""
|
PKG_CONFIG_REQUIRES=""
|
||||||
|
|
||||||
@ -183,10 +130,7 @@ if test x$ac_cv_with_cutter = xyes -a x$ac_cv_use_cutter = xno; then
|
|||||||
fi
|
fi
|
||||||
AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"])
|
AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"])
|
||||||
|
|
||||||
if test x"$enable_example" = "xyes"
|
|
||||||
then
|
|
||||||
AC_CHECK_READLINE
|
AC_CHECK_READLINE
|
||||||
fi
|
|
||||||
|
|
||||||
# Help us to write great code ;-)
|
# Help us to write great code ;-)
|
||||||
CFLAGS="$CFLAGS -Wall -pedantic -Wextra"
|
CFLAGS="$CFLAGS -Wall -pedantic -Wextra"
|
||||||
@ -209,8 +153,6 @@ AC_CONFIG_FILES([
|
|||||||
contrib/udev/Makefile
|
contrib/udev/Makefile
|
||||||
contrib/win32/Makefile
|
contrib/win32/Makefile
|
||||||
contrib/win32/sys/Makefile
|
contrib/win32/sys/Makefile
|
||||||
contrib/win32/libnfc/Makefile
|
|
||||||
contrib/win32/libnfc/buses/Makefile
|
|
||||||
examples/Makefile
|
examples/Makefile
|
||||||
examples/pn53x-tamashell-scripts/Makefile
|
examples/pn53x-tamashell-scripts/Makefile
|
||||||
include/Makefile
|
include/Makefile
|
||||||
|
|||||||
@ -1,7 +1,4 @@
|
|||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
arygon.conf.sample \
|
pn532_via_uart2usb.conf.sample \
|
||||||
pn532_i2c_on_rpi.conf.sample \
|
arygon.conf.sample \
|
||||||
pn532_spi_on_rpi.conf.sample \
|
pn532_uart_on_rpi.conf.sample
|
||||||
pn532_uart_on_rpi_3.conf.sample \
|
|
||||||
pn532_uart_on_rpi.conf.sample \
|
|
||||||
pn532_via_uart2usb.conf.sample
|
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
## Typical configuration file for PN532 device on R-Pi connected using I2C
|
|
||||||
## Note: to use SPI port on R-Pi, you have to load kernel modules i2c-bcm2708 and i2c-dev:
|
|
||||||
## Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist i2c-bcm2708
|
|
||||||
## Edit /etc/modules and add a new line: i2c-dev
|
|
||||||
name = "PN532 board via I2C"
|
|
||||||
connstring = pn532_i2c:/dev/i2c-0
|
|
||||||
|
|
||||||
# Note: If you have an R-Pi revision 2.0, the I2C bus #1 is now routed to connector P1
|
|
||||||
# (instead of the I2C bus #0 routed on same connector on initial board revision), so
|
|
||||||
# the configuration to use would probably be:
|
|
||||||
|
|
||||||
# connstring = pn532_i2c:/dev/i2c-1
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
## Typical configuration file for PN532 device on R-Pi connected using SPI
|
|
||||||
## Note: to use SPI port on R-Pi, you have to load kernel module spi-bcm2708:
|
|
||||||
## Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist spi-bcm2708
|
|
||||||
name = "PN532 board via SPI"
|
|
||||||
connstring = pn532_spi:/dev/spidev0.0:500000
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
## Typical configuration file for PN532 device on R-Pi connected using UART
|
## Typical configuration file for PN532 device on R-Pi connected using UART
|
||||||
## Note: to use UART port on R-Pi, you have to disable linux serial console:
|
## Note: to use UART port on R-Pi, you have to disable linux serial console:
|
||||||
## http://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/freeing-uart-on-the-pi
|
## http://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/freeing-uart-on-the-pi
|
||||||
name = "PN532 board via UART"
|
name = "PN532 board"
|
||||||
connstring = pn532_uart:/dev/ttyAMA0
|
connstring = pn532_uart:/dev/ttyAMA0
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
## Typical configuration file for PN532 device on R-Pi 3 connected using miniUART
|
|
||||||
## Note: Changes have been made to R-Pi 3 with the addition of Bluetooth LE
|
|
||||||
## The UART is now being used by the BLE module. Instead of disabling it, you can
|
|
||||||
## use the PN532 device with the "mini UART", which is still hijacked by the linux kernel
|
|
||||||
## as a serial console
|
|
||||||
##
|
|
||||||
## Tested recipe with PN532 breakout from Adafruit
|
|
||||||
##
|
|
||||||
## To enable uart on GPIO, add this line to bottom of /boot/config.txt
|
|
||||||
## enable_uart=1
|
|
||||||
##
|
|
||||||
## Stop and disable serial console:
|
|
||||||
## $ sudo systemctl stop serial-getty@ttyS0.service
|
|
||||||
## $ sudo systemctl disable serial-getty@ttyS0.service
|
|
||||||
##
|
|
||||||
## Remove console from /boot/cmdline.txt by removing:
|
|
||||||
## console=serial0,115200 Save and reboot for changes to take effect.
|
|
||||||
##
|
|
||||||
name = "PN532 board via UART"
|
|
||||||
connstring = pn532_uart:/dev/ttyS0
|
|
||||||
allow_intrusive_scan = true
|
|
||||||
|
|
||||||
@ -1,3 +1,3 @@
|
|||||||
## Typical configuration file for PN532 board (ie. microbuilder.eu / Adafruit) device
|
## Typical configuration file for PN532 board (ie. microbuilder.eu / Adafruit) device
|
||||||
name = "Adafruit PN532 board via UART"
|
name = "Adafruit PN532 board"
|
||||||
connstring = pn532_uart:/dev/ttyUSB0
|
connstring = pn532_uart:/dev/ttyUSB0
|
||||||
|
|||||||
@ -1,3 +1,2 @@
|
|||||||
blacklist nfc
|
blacklist nfc
|
||||||
blacklist pn533
|
blacklist pn533
|
||||||
blacklist pn533_usb
|
|
||||||
|
|||||||
@ -11,7 +11,6 @@ ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0193", MODE="0664", GROUP="plugdev"
|
|||||||
# PN533
|
# PN533
|
||||||
ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="2533", MODE="0664", GROUP="plugdev"
|
ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="2533", MODE="0664", GROUP="plugdev"
|
||||||
ATTRS{idVendor}=="04e6", ATTRS{idProduct}=="5591", MODE="0664", GROUP="plugdev"
|
ATTRS{idVendor}=="04e6", ATTRS{idProduct}=="5591", MODE="0664", GROUP="plugdev"
|
||||||
ATTRS{idVendor}=="04e6", ATTRS{idProduct}=="5594", MODE="0664", GROUP="plugdev"
|
|
||||||
ATTRS{idVendor}=="1fd3", ATTRS{idProduct}=="0608", MODE="0664", GROUP="plugdev"
|
ATTRS{idVendor}=="1fd3", ATTRS{idProduct}=="0608", MODE="0664", GROUP="plugdev"
|
||||||
ATTRS{idVendor}=="054c", ATTRS{idProduct}=="02e1", MODE="0664", GROUP="plugdev"
|
ATTRS{idVendor}=="054c", ATTRS{idProduct}=="02e1", MODE="0664", GROUP="plugdev"
|
||||||
|
|
||||||
@ -1,2 +1,2 @@
|
|||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
93-pn53x.rules
|
42-pn53x.rules
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
SUBDIRS = libnfc sys .
|
SUBDIRS = sys .
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
err.h \
|
err.h \
|
||||||
nfc.def \
|
nfc.def \
|
||||||
stdlib.c \
|
stdlib.c \
|
||||||
unistd.h \
|
unistd.h
|
||||||
version.rc.in
|
version.rc.in
|
||||||
|
|||||||
@ -1,870 +0,0 @@
|
|||||||
/*
|
|
||||||
* Dirent interface for Microsoft Visual Studio
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006-2012 Toni Ronkko
|
|
||||||
* This file is part of dirent. Dirent may be freely distributed
|
|
||||||
* under the MIT license. For all details and documentation, see
|
|
||||||
* https://github.com/tronkko/dirent
|
|
||||||
*/
|
|
||||||
#ifndef DIRENT_H
|
|
||||||
#define DIRENT_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Include windows.h without Windows Sockets 1.1 to prevent conflicts with
|
|
||||||
* Windows Sockets 2.0.
|
|
||||||
*/
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
/* Indicates that d_type field is available in dirent structure */
|
|
||||||
#define _DIRENT_HAVE_D_TYPE
|
|
||||||
|
|
||||||
/* Indicates that d_namlen field is available in dirent structure */
|
|
||||||
#define _DIRENT_HAVE_D_NAMLEN
|
|
||||||
|
|
||||||
/* Entries missing from MSVC 6.0 */
|
|
||||||
#if !defined(FILE_ATTRIBUTE_DEVICE)
|
|
||||||
# define FILE_ATTRIBUTE_DEVICE 0x40
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* File type and permission flags for stat(), general mask */
|
|
||||||
#if !defined(S_IFMT)
|
|
||||||
# define S_IFMT _S_IFMT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Directory bit */
|
|
||||||
#if !defined(S_IFDIR)
|
|
||||||
# define S_IFDIR _S_IFDIR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Character device bit */
|
|
||||||
#if !defined(S_IFCHR)
|
|
||||||
# define S_IFCHR _S_IFCHR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Pipe bit */
|
|
||||||
#if !defined(S_IFFIFO)
|
|
||||||
# define S_IFFIFO _S_IFFIFO
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Regular file bit */
|
|
||||||
#if !defined(S_IFREG)
|
|
||||||
# define S_IFREG _S_IFREG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Read permission */
|
|
||||||
#if !defined(S_IREAD)
|
|
||||||
# define S_IREAD _S_IREAD
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Write permission */
|
|
||||||
#if !defined(S_IWRITE)
|
|
||||||
# define S_IWRITE _S_IWRITE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Execute permission */
|
|
||||||
#if !defined(S_IEXEC)
|
|
||||||
# define S_IEXEC _S_IEXEC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Pipe */
|
|
||||||
#if !defined(S_IFIFO)
|
|
||||||
# define S_IFIFO _S_IFIFO
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Block device */
|
|
||||||
#if !defined(S_IFBLK)
|
|
||||||
# define S_IFBLK 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Link */
|
|
||||||
#if !defined(S_IFLNK)
|
|
||||||
# define S_IFLNK 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Socket */
|
|
||||||
#if !defined(S_IFSOCK)
|
|
||||||
# define S_IFSOCK 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Read user permission */
|
|
||||||
#if !defined(S_IRUSR)
|
|
||||||
# define S_IRUSR S_IREAD
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Write user permission */
|
|
||||||
#if !defined(S_IWUSR)
|
|
||||||
# define S_IWUSR S_IWRITE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Execute user permission */
|
|
||||||
#if !defined(S_IXUSR)
|
|
||||||
# define S_IXUSR 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Read group permission */
|
|
||||||
#if !defined(S_IRGRP)
|
|
||||||
# define S_IRGRP 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Write group permission */
|
|
||||||
#if !defined(S_IWGRP)
|
|
||||||
# define S_IWGRP 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Execute group permission */
|
|
||||||
#if !defined(S_IXGRP)
|
|
||||||
# define S_IXGRP 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Read others permission */
|
|
||||||
#if !defined(S_IROTH)
|
|
||||||
# define S_IROTH 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Write others permission */
|
|
||||||
#if !defined(S_IWOTH)
|
|
||||||
# define S_IWOTH 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Execute others permission */
|
|
||||||
#if !defined(S_IXOTH)
|
|
||||||
# define S_IXOTH 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Maximum length of file name */
|
|
||||||
#if !defined(PATH_MAX)
|
|
||||||
# define PATH_MAX MAX_PATH
|
|
||||||
#endif
|
|
||||||
#if !defined(FILENAME_MAX)
|
|
||||||
# define FILENAME_MAX MAX_PATH
|
|
||||||
#endif
|
|
||||||
#if !defined(NAME_MAX)
|
|
||||||
# define NAME_MAX FILENAME_MAX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* File type flags for d_type */
|
|
||||||
#define DT_UNKNOWN 0
|
|
||||||
#define DT_REG S_IFREG
|
|
||||||
#define DT_DIR S_IFDIR
|
|
||||||
#define DT_FIFO S_IFIFO
|
|
||||||
#define DT_SOCK S_IFSOCK
|
|
||||||
#define DT_CHR S_IFCHR
|
|
||||||
#define DT_BLK S_IFBLK
|
|
||||||
#define DT_LNK S_IFLNK
|
|
||||||
|
|
||||||
/* Macros for converting between st_mode and d_type */
|
|
||||||
#define IFTODT(mode) ((mode) & S_IFMT)
|
|
||||||
#define DTTOIF(type) (type)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* File type macros. Note that block devices, sockets and links cannot be
|
|
||||||
* distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
|
|
||||||
* only defined for compatibility. These macros should always return false
|
|
||||||
* on Windows.
|
|
||||||
*/
|
|
||||||
#if !defined(S_ISFIFO)
|
|
||||||
# define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
|
|
||||||
#endif
|
|
||||||
#if !defined(S_ISDIR)
|
|
||||||
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
|
||||||
#endif
|
|
||||||
#if !defined(S_ISREG)
|
|
||||||
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
|
|
||||||
#endif
|
|
||||||
#if !defined(S_ISLNK)
|
|
||||||
# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
|
|
||||||
#endif
|
|
||||||
#if !defined(S_ISSOCK)
|
|
||||||
# define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
|
|
||||||
#endif
|
|
||||||
#if !defined(S_ISCHR)
|
|
||||||
# define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
|
|
||||||
#endif
|
|
||||||
#if !defined(S_ISBLK)
|
|
||||||
# define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Return the exact length of the file name without zero terminator */
|
|
||||||
#define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
|
|
||||||
|
|
||||||
/* Return the maximum size of a file name */
|
|
||||||
#define _D_ALLOC_NAMLEN(p) ((PATH_MAX)+1)
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Wide-character version */
|
|
||||||
struct _wdirent {
|
|
||||||
/* Always zero */
|
|
||||||
long d_ino;
|
|
||||||
|
|
||||||
/* File position within stream */
|
|
||||||
long d_off;
|
|
||||||
|
|
||||||
/* Structure size */
|
|
||||||
unsigned short d_reclen;
|
|
||||||
|
|
||||||
/* Length of name without \0 */
|
|
||||||
size_t d_namlen;
|
|
||||||
|
|
||||||
/* File type */
|
|
||||||
int d_type;
|
|
||||||
|
|
||||||
/* File name */
|
|
||||||
wchar_t d_name[PATH_MAX+1];
|
|
||||||
};
|
|
||||||
typedef struct _wdirent _wdirent;
|
|
||||||
|
|
||||||
struct _WDIR {
|
|
||||||
/* Current directory entry */
|
|
||||||
struct _wdirent ent;
|
|
||||||
|
|
||||||
/* Private file data */
|
|
||||||
WIN32_FIND_DATAW data;
|
|
||||||
|
|
||||||
/* True if data is valid */
|
|
||||||
int cached;
|
|
||||||
|
|
||||||
/* Win32 search handle */
|
|
||||||
HANDLE handle;
|
|
||||||
|
|
||||||
/* Initial directory name */
|
|
||||||
wchar_t *patt;
|
|
||||||
};
|
|
||||||
typedef struct _WDIR _WDIR;
|
|
||||||
|
|
||||||
/* Multi-byte character version */
|
|
||||||
struct dirent {
|
|
||||||
/* Always zero */
|
|
||||||
long d_ino;
|
|
||||||
|
|
||||||
/* File position within stream */
|
|
||||||
long d_off;
|
|
||||||
|
|
||||||
/* Structure size */
|
|
||||||
unsigned short d_reclen;
|
|
||||||
|
|
||||||
/* Length of name without \0 */
|
|
||||||
size_t d_namlen;
|
|
||||||
|
|
||||||
/* File type */
|
|
||||||
int d_type;
|
|
||||||
|
|
||||||
/* File name */
|
|
||||||
char d_name[PATH_MAX+1];
|
|
||||||
};
|
|
||||||
typedef struct dirent dirent;
|
|
||||||
|
|
||||||
struct DIR {
|
|
||||||
struct dirent ent;
|
|
||||||
struct _WDIR *wdirp;
|
|
||||||
};
|
|
||||||
typedef struct DIR DIR;
|
|
||||||
|
|
||||||
|
|
||||||
/* Dirent functions */
|
|
||||||
static DIR *opendir (const char *dirname);
|
|
||||||
static _WDIR *_wopendir (const wchar_t *dirname);
|
|
||||||
|
|
||||||
static struct dirent *readdir (DIR *dirp);
|
|
||||||
|
|
||||||
static int readdir_r(
|
|
||||||
DIR *dirp, struct dirent *entry, struct dirent **result);
|
|
||||||
|
|
||||||
static int closedir (DIR *dirp);
|
|
||||||
static int _wclosedir (_WDIR *dirp);
|
|
||||||
|
|
||||||
/* For compatibility with Symbian */
|
|
||||||
#define wdirent _wdirent
|
|
||||||
#define WDIR _WDIR
|
|
||||||
#define wopendir _wopendir
|
|
||||||
#define wreaddir _wreaddir
|
|
||||||
#define wclosedir _wclosedir
|
|
||||||
#define wrewinddir _wrewinddir
|
|
||||||
|
|
||||||
|
|
||||||
/* Internal utility functions */
|
|
||||||
static WIN32_FIND_DATAW *dirent_first (_WDIR *dirp);
|
|
||||||
static WIN32_FIND_DATAW *dirent_next (_WDIR *dirp);
|
|
||||||
|
|
||||||
static int dirent_mbstowcs_s(
|
|
||||||
size_t *pReturnValue,
|
|
||||||
wchar_t *wcstr,
|
|
||||||
size_t sizeInWords,
|
|
||||||
const char *mbstr,
|
|
||||||
size_t count);
|
|
||||||
|
|
||||||
static int dirent_wcstombs_s(
|
|
||||||
size_t *pReturnValue,
|
|
||||||
char *mbstr,
|
|
||||||
size_t sizeInBytes,
|
|
||||||
const wchar_t *wcstr,
|
|
||||||
size_t count);
|
|
||||||
|
|
||||||
static void dirent_set_errno (int error);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open directory stream DIRNAME for read and return a pointer to the
|
|
||||||
* internal working area that is used to retrieve individual directory
|
|
||||||
* entries.
|
|
||||||
*/
|
|
||||||
static _WDIR*
|
|
||||||
_wopendir(
|
|
||||||
const wchar_t *dirname)
|
|
||||||
{
|
|
||||||
_WDIR *dirp = NULL;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
/* Must have directory name */
|
|
||||||
if (dirname == NULL || dirname[0] == '\0') {
|
|
||||||
dirent_set_errno (ENOENT);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate new _WDIR structure */
|
|
||||||
dirp = (_WDIR*) malloc (sizeof (struct _WDIR));
|
|
||||||
if (dirp != NULL) {
|
|
||||||
DWORD n;
|
|
||||||
|
|
||||||
/* Reset _WDIR structure */
|
|
||||||
dirp->handle = INVALID_HANDLE_VALUE;
|
|
||||||
dirp->patt = NULL;
|
|
||||||
dirp->cached = 0;
|
|
||||||
|
|
||||||
/* Compute the length of full path plus zero terminator
|
|
||||||
*
|
|
||||||
* Note that on WinRT there's no way to convert relative paths
|
|
||||||
* into absolute paths, so just assume it is an absolute path.
|
|
||||||
*/
|
|
||||||
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
|
||||||
n = wcslen(dirname);
|
|
||||||
# else
|
|
||||||
n = GetFullPathNameW (dirname, 0, NULL, NULL);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Allocate room for absolute directory name and search pattern */
|
|
||||||
dirp->patt = (wchar_t*) malloc (sizeof (wchar_t) * n + 16);
|
|
||||||
if (dirp->patt) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert relative directory name to an absolute one. This
|
|
||||||
* allows rewinddir() to function correctly even when current
|
|
||||||
* working directory is changed between opendir() and rewinddir().
|
|
||||||
*
|
|
||||||
* Note that on WinRT there's no way to convert relative paths
|
|
||||||
* into absolute paths, so just assume it is an absolute path.
|
|
||||||
*/
|
|
||||||
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
|
||||||
wcsncpy_s(dirp->patt, n+1, dirname, n);
|
|
||||||
# else
|
|
||||||
n = GetFullPathNameW (dirname, n, dirp->patt, NULL);
|
|
||||||
# endif
|
|
||||||
if (n > 0) {
|
|
||||||
wchar_t *p;
|
|
||||||
|
|
||||||
/* Append search pattern \* to the directory name */
|
|
||||||
p = dirp->patt + n;
|
|
||||||
if (dirp->patt < p) {
|
|
||||||
switch (p[-1]) {
|
|
||||||
case '\\':
|
|
||||||
case '/':
|
|
||||||
case ':':
|
|
||||||
/* Directory ends in path separator, e.g. c:\temp\ */
|
|
||||||
/*NOP*/;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
/* Directory name doesn't end in path separator */
|
|
||||||
*p++ = '\\';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*p++ = '*';
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
/* Open directory stream and retrieve the first entry */
|
|
||||||
if (dirent_first (dirp)) {
|
|
||||||
/* Directory stream opened successfully */
|
|
||||||
error = 0;
|
|
||||||
} else {
|
|
||||||
/* Cannot retrieve first entry */
|
|
||||||
error = 1;
|
|
||||||
dirent_set_errno (ENOENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* Cannot retrieve full path name */
|
|
||||||
dirent_set_errno (ENOENT);
|
|
||||||
error = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* Cannot allocate memory for search pattern */
|
|
||||||
error = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* Cannot allocate _WDIR structure */
|
|
||||||
error = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean up in case of error */
|
|
||||||
if (error && dirp) {
|
|
||||||
_wclosedir (dirp);
|
|
||||||
dirp = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dirp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Close directory stream opened by opendir() function. This invalidates the
|
|
||||||
* DIR structure as well as any directory entry read previously by
|
|
||||||
* _wreaddir().
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
_wclosedir(
|
|
||||||
_WDIR *dirp)
|
|
||||||
{
|
|
||||||
int ok;
|
|
||||||
if (dirp) {
|
|
||||||
|
|
||||||
/* Release search handle */
|
|
||||||
if (dirp->handle != INVALID_HANDLE_VALUE) {
|
|
||||||
FindClose (dirp->handle);
|
|
||||||
dirp->handle = INVALID_HANDLE_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release search pattern */
|
|
||||||
if (dirp->patt) {
|
|
||||||
free (dirp->patt);
|
|
||||||
dirp->patt = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release directory structure */
|
|
||||||
free (dirp);
|
|
||||||
ok = /*success*/0;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* Invalid directory stream */
|
|
||||||
dirent_set_errno (EBADF);
|
|
||||||
ok = /*failure*/-1;
|
|
||||||
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get first directory entry (internal) */
|
|
||||||
static WIN32_FIND_DATAW*
|
|
||||||
dirent_first(
|
|
||||||
_WDIR *dirp)
|
|
||||||
{
|
|
||||||
WIN32_FIND_DATAW *datap;
|
|
||||||
|
|
||||||
/* Open directory and retrieve the first entry */
|
|
||||||
dirp->handle = FindFirstFileExW(
|
|
||||||
dirp->patt, FindExInfoStandard, &dirp->data,
|
|
||||||
FindExSearchNameMatch, NULL, 0);
|
|
||||||
if (dirp->handle != INVALID_HANDLE_VALUE) {
|
|
||||||
|
|
||||||
/* a directory entry is now waiting in memory */
|
|
||||||
datap = &dirp->data;
|
|
||||||
dirp->cached = 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* Failed to re-open directory: no directory entry in memory */
|
|
||||||
dirp->cached = 0;
|
|
||||||
datap = NULL;
|
|
||||||
|
|
||||||
}
|
|
||||||
return datap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get next directory entry (internal).
|
|
||||||
*
|
|
||||||
* Returns
|
|
||||||
*/
|
|
||||||
static WIN32_FIND_DATAW*
|
|
||||||
dirent_next(
|
|
||||||
_WDIR *dirp)
|
|
||||||
{
|
|
||||||
WIN32_FIND_DATAW *p;
|
|
||||||
|
|
||||||
/* Get next directory entry */
|
|
||||||
if (dirp->cached != 0) {
|
|
||||||
|
|
||||||
/* A valid directory entry already in memory */
|
|
||||||
p = &dirp->data;
|
|
||||||
dirp->cached = 0;
|
|
||||||
|
|
||||||
} else if (dirp->handle != INVALID_HANDLE_VALUE) {
|
|
||||||
|
|
||||||
/* Get the next directory entry from stream */
|
|
||||||
if (FindNextFileW (dirp->handle, &dirp->data) != FALSE) {
|
|
||||||
/* Got a file */
|
|
||||||
p = &dirp->data;
|
|
||||||
} else {
|
|
||||||
/* The very last entry has been processed or an error occurred */
|
|
||||||
FindClose (dirp->handle);
|
|
||||||
dirp->handle = INVALID_HANDLE_VALUE;
|
|
||||||
p = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* End of directory stream reached */
|
|
||||||
p = NULL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open directory stream using plain old C-string.
|
|
||||||
*/
|
|
||||||
static DIR*
|
|
||||||
opendir(
|
|
||||||
const char *dirname)
|
|
||||||
{
|
|
||||||
struct DIR *dirp;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
/* Must have directory name */
|
|
||||||
if (dirname == NULL || dirname[0] == '\0') {
|
|
||||||
dirent_set_errno (ENOENT);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate memory for DIR structure */
|
|
||||||
dirp = (DIR*) malloc (sizeof (struct DIR));
|
|
||||||
if (dirp) {
|
|
||||||
wchar_t wname[PATH_MAX + 1];
|
|
||||||
size_t n;
|
|
||||||
|
|
||||||
/* Convert directory name to wide-character string */
|
|
||||||
error = dirent_mbstowcs_s(
|
|
||||||
&n, wname, PATH_MAX + 1, dirname, PATH_MAX + 1);
|
|
||||||
if (!error) {
|
|
||||||
|
|
||||||
/* Open directory stream using wide-character name */
|
|
||||||
dirp->wdirp = _wopendir (wname);
|
|
||||||
if (dirp->wdirp) {
|
|
||||||
/* Directory stream opened */
|
|
||||||
error = 0;
|
|
||||||
} else {
|
|
||||||
/* Failed to open directory stream */
|
|
||||||
error = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Cannot convert file name to wide-character string. This
|
|
||||||
* occurs if the string contains invalid multi-byte sequences or
|
|
||||||
* the output buffer is too small to contain the resulting
|
|
||||||
* string.
|
|
||||||
*/
|
|
||||||
error = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* Cannot allocate DIR structure */
|
|
||||||
error = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean up in case of error */
|
|
||||||
if (error && dirp) {
|
|
||||||
free (dirp);
|
|
||||||
dirp = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dirp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read next directory entry.
|
|
||||||
*/
|
|
||||||
static struct dirent*
|
|
||||||
readdir(
|
|
||||||
DIR *dirp)
|
|
||||||
{
|
|
||||||
struct dirent *entry;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read directory entry to buffer. We can safely ignore the return value
|
|
||||||
* as entry will be set to NULL in case of error.
|
|
||||||
*/
|
|
||||||
(void) readdir_r (dirp, &dirp->ent, &entry);
|
|
||||||
|
|
||||||
/* Return pointer to statically allocated directory entry */
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read next directory entry into called-allocated buffer.
|
|
||||||
*
|
|
||||||
* Returns zero on success. If the end of directory stream is reached, then
|
|
||||||
* sets result to NULL and returns zero.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
readdir_r(
|
|
||||||
DIR *dirp,
|
|
||||||
struct dirent *entry,
|
|
||||||
struct dirent **result)
|
|
||||||
{
|
|
||||||
WIN32_FIND_DATAW *datap;
|
|
||||||
|
|
||||||
/* Read next directory entry */
|
|
||||||
datap = dirent_next (dirp->wdirp);
|
|
||||||
if (datap) {
|
|
||||||
size_t n;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
/* Attempt to convert file name to multi-byte string */
|
|
||||||
error = dirent_wcstombs_s(
|
|
||||||
&n, entry->d_name, PATH_MAX + 1, datap->cFileName, PATH_MAX + 1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the file name cannot be represented by a multi-byte string,
|
|
||||||
* then attempt to use old 8+3 file name. This allows traditional
|
|
||||||
* Unix-code to access some file names despite of unicode
|
|
||||||
* characters, although file names may seem unfamiliar to the user.
|
|
||||||
*
|
|
||||||
* Be ware that the code below cannot come up with a short file
|
|
||||||
* name unless the file system provides one. At least
|
|
||||||
* VirtualBox shared folders fail to do this.
|
|
||||||
*/
|
|
||||||
if (error && datap->cAlternateFileName[0] != '\0') {
|
|
||||||
error = dirent_wcstombs_s(
|
|
||||||
&n, entry->d_name, PATH_MAX + 1,
|
|
||||||
datap->cAlternateFileName, PATH_MAX + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!error) {
|
|
||||||
DWORD attr;
|
|
||||||
|
|
||||||
/* Length of file name excluding zero terminator */
|
|
||||||
entry->d_namlen = n - 1;
|
|
||||||
|
|
||||||
/* File attributes */
|
|
||||||
attr = datap->dwFileAttributes;
|
|
||||||
if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
|
|
||||||
entry->d_type = DT_CHR;
|
|
||||||
} else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
|
|
||||||
entry->d_type = DT_DIR;
|
|
||||||
} else {
|
|
||||||
entry->d_type = DT_REG;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset dummy fields */
|
|
||||||
entry->d_ino = 0;
|
|
||||||
entry->d_off = 0;
|
|
||||||
entry->d_reclen = sizeof (struct dirent);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cannot convert file name to multi-byte string so construct
|
|
||||||
* an erroneous directory entry and return that. Note that
|
|
||||||
* we cannot return NULL as that would stop the processing
|
|
||||||
* of directory entries completely.
|
|
||||||
*/
|
|
||||||
entry->d_name[0] = '?';
|
|
||||||
entry->d_name[1] = '\0';
|
|
||||||
entry->d_namlen = 1;
|
|
||||||
entry->d_type = DT_UNKNOWN;
|
|
||||||
entry->d_ino = 0;
|
|
||||||
entry->d_off = -1;
|
|
||||||
entry->d_reclen = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return pointer to directory entry */
|
|
||||||
*result = entry;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* No more directory entries */
|
|
||||||
*result = NULL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return /*OK*/0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Close directory stream.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
closedir(
|
|
||||||
DIR *dirp)
|
|
||||||
{
|
|
||||||
int ok;
|
|
||||||
if (dirp) {
|
|
||||||
|
|
||||||
/* Close wide-character directory stream */
|
|
||||||
ok = _wclosedir (dirp->wdirp);
|
|
||||||
dirp->wdirp = NULL;
|
|
||||||
|
|
||||||
/* Release multi-byte character version */
|
|
||||||
free (dirp);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* Invalid directory stream */
|
|
||||||
dirent_set_errno (EBADF);
|
|
||||||
ok = /*failure*/-1;
|
|
||||||
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert multi-byte string to wide character string */
|
|
||||||
static int
|
|
||||||
dirent_mbstowcs_s(
|
|
||||||
size_t *pReturnValue,
|
|
||||||
wchar_t *wcstr,
|
|
||||||
size_t sizeInWords,
|
|
||||||
const char *mbstr,
|
|
||||||
size_t count)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
|
||||||
|
|
||||||
/* Microsoft Visual Studio 2005 or later */
|
|
||||||
error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* Older Visual Studio or non-Microsoft compiler */
|
|
||||||
size_t n;
|
|
||||||
|
|
||||||
/* Convert to wide-character string (or count characters) */
|
|
||||||
n = mbstowcs (wcstr, mbstr, sizeInWords);
|
|
||||||
if (!wcstr || n < count) {
|
|
||||||
|
|
||||||
/* Zero-terminate output buffer */
|
|
||||||
if (wcstr && sizeInWords) {
|
|
||||||
if (n >= sizeInWords) {
|
|
||||||
n = sizeInWords - 1;
|
|
||||||
}
|
|
||||||
wcstr[n] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Length of resulting multi-byte string WITH zero terminator */
|
|
||||||
if (pReturnValue) {
|
|
||||||
*pReturnValue = n + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Success */
|
|
||||||
error = 0;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* Could not convert string */
|
|
||||||
error = 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert wide-character string to multi-byte string */
|
|
||||||
static int
|
|
||||||
dirent_wcstombs_s(
|
|
||||||
size_t *pReturnValue,
|
|
||||||
char *mbstr,
|
|
||||||
size_t sizeInBytes, /* max size of mbstr */
|
|
||||||
const wchar_t *wcstr,
|
|
||||||
size_t count)
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
|
||||||
|
|
||||||
/* Microsoft Visual Studio 2005 or later */
|
|
||||||
error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* Older Visual Studio or non-Microsoft compiler */
|
|
||||||
size_t n;
|
|
||||||
|
|
||||||
/* Convert to multi-byte string (or count the number of bytes needed) */
|
|
||||||
n = wcstombs (mbstr, wcstr, sizeInBytes);
|
|
||||||
if (!mbstr || n < count) {
|
|
||||||
|
|
||||||
/* Zero-terminate output buffer */
|
|
||||||
if (mbstr && sizeInBytes) {
|
|
||||||
if (n >= sizeInBytes) {
|
|
||||||
n = sizeInBytes - 1;
|
|
||||||
}
|
|
||||||
mbstr[n] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Length of resulting multi-bytes string WITH zero-terminator */
|
|
||||||
if (pReturnValue) {
|
|
||||||
*pReturnValue = n + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Success */
|
|
||||||
error = 0;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* Cannot convert string */
|
|
||||||
error = 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set errno variable */
|
|
||||||
static void
|
|
||||||
dirent_set_errno(
|
|
||||||
int error)
|
|
||||||
{
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
|
||||||
|
|
||||||
/* Microsoft Visual Studio 2005 and later */
|
|
||||||
_set_errno (error);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* Non-Microsoft compiler or older Microsoft compiler */
|
|
||||||
errno = error;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif /*DIRENT_H*/
|
|
||||||
|
|
||||||
@ -1,106 +0,0 @@
|
|||||||
#include "getopt.h" // make sure you construct the header file as dictated above
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 1987, 1993, 1994
|
|
||||||
* The Regents of the University of California. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int opterr = 1, /* if error message should be printed */
|
|
||||||
optind = 1, /* index into parent argv vector */
|
|
||||||
optopt, /* character checked for validity */
|
|
||||||
optreset; /* reset getopt */
|
|
||||||
char *optarg; /* argument associated with option */
|
|
||||||
|
|
||||||
#define BADCH (int)'?'
|
|
||||||
#define BADARG (int)':'
|
|
||||||
#define EMSG ""
|
|
||||||
|
|
||||||
/*
|
|
||||||
* getopt --
|
|
||||||
* Parse argc/argv argument vector.
|
|
||||||
*/
|
|
||||||
int getopt(int nargc, char * const nargv[], const char *ostr)
|
|
||||||
{
|
|
||||||
static char *place = EMSG; /* option letter processing */
|
|
||||||
const char *oli; /* option letter list index */
|
|
||||||
|
|
||||||
if (optreset || !*place) { /* update scanning pointer */
|
|
||||||
optreset = 0;
|
|
||||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
|
||||||
place = EMSG;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if (place[1] && *++place == '-') { /* found "--" */
|
|
||||||
++optind;
|
|
||||||
place = EMSG;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
} /* option letter okay? */
|
|
||||||
if ((optopt = (int)*place++) == (int)':' ||
|
|
||||||
!(oli = strchr(ostr, optopt))) {
|
|
||||||
/*
|
|
||||||
* if the user didn't specify '-' as an option,
|
|
||||||
* assume it means -1.
|
|
||||||
*/
|
|
||||||
if (optopt == (int)'-')
|
|
||||||
return (-1);
|
|
||||||
if (!*place)
|
|
||||||
++optind;
|
|
||||||
if (opterr && *ostr != ':')
|
|
||||||
(void)printf("illegal option -- %c\n", optopt);
|
|
||||||
return (BADCH);
|
|
||||||
}
|
|
||||||
if (*++oli != ':') { /* don't need argument */
|
|
||||||
optarg = NULL;
|
|
||||||
if (!*place)
|
|
||||||
++optind;
|
|
||||||
}
|
|
||||||
else { /* need an argument */
|
|
||||||
if (*place) /* no white space */
|
|
||||||
optarg = place;
|
|
||||||
else if (nargc <= ++optind) { /* no arg */
|
|
||||||
place = EMSG;
|
|
||||||
if (*ostr == ':')
|
|
||||||
return (BADARG);
|
|
||||||
if (opterr)
|
|
||||||
(void)printf("option requires an argument -- %c\n", optopt);
|
|
||||||
return (BADCH);
|
|
||||||
}
|
|
||||||
else /* white space */
|
|
||||||
optarg = nargv[optind];
|
|
||||||
place = EMSG;
|
|
||||||
++optind;
|
|
||||||
}
|
|
||||||
return (optopt); /* dump back option letter */
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
#ifndef GETOPT_H
|
|
||||||
|
|
||||||
#define GETOPT_H
|
|
||||||
|
|
||||||
extern int opterr; /* if error message should be printed */
|
|
||||||
extern int optind; /* index into parent argv vector */
|
|
||||||
extern int optopt; /* character checked for validity */
|
|
||||||
extern int optreset; /* reset getopt */
|
|
||||||
extern char *optarg; /* argument associated with option */
|
|
||||||
|
|
||||||
int getopt(int nargc, char * const nargv[], const char *ostr);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
SUBDIRS = buses .
|
|
||||||
|
|
||||||
EXTRA_DIST = \
|
|
||||||
log-internal.c
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
EXTRA_DIST = \
|
|
||||||
uart.c
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
|
||||||
*
|
|
||||||
* Libnfc historical contributors:
|
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
* Copyright (C) 2013 Alex Lian
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
* option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "log-internal.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <strsafe.h>
|
|
||||||
|
|
||||||
static void
|
|
||||||
log_output_debug(const char *format, va_list args)
|
|
||||||
{
|
|
||||||
char buffer[1024];
|
|
||||||
HRESULT hr = StringCbVPrintf(buffer, sizeof(buffer), format, args);
|
|
||||||
// Spew what we got, even if the buffer is not sized large enough
|
|
||||||
if ((STRSAFE_E_INSUFFICIENT_BUFFER == hr) || (S_OK == hr))
|
|
||||||
OutputDebugString(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
log_vput_internal(const char *format, va_list args)
|
|
||||||
{
|
|
||||||
vfprintf(stderr, format, args);
|
|
||||||
// Additional windows output to the debug window for debugging purposes
|
|
||||||
log_output_debug(format, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
log_put_internal(const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list va;
|
|
||||||
va_start(va, format);
|
|
||||||
vfprintf(stderr, format, va);
|
|
||||||
// Additional windows output to the debug window for debugging purposes
|
|
||||||
log_output_debug(format, va);
|
|
||||||
va_end(va);
|
|
||||||
}
|
|
||||||
@ -4,10 +4,9 @@ VERSION 1.7
|
|||||||
EXPORTS
|
EXPORTS
|
||||||
nfc_init
|
nfc_init
|
||||||
nfc_exit
|
nfc_exit
|
||||||
nfc_register_driver
|
|
||||||
nfc_open
|
nfc_open
|
||||||
nfc_close
|
nfc_close
|
||||||
nfc_abort_command
|
nfc_abbort_command
|
||||||
nfc_list_devices
|
nfc_list_devices
|
||||||
nfc_idle
|
nfc_idle
|
||||||
nfc_initiator_init
|
nfc_initiator_init
|
||||||
@ -18,6 +17,7 @@ EXPORTS
|
|||||||
nfc_initiator_select_dep_target
|
nfc_initiator_select_dep_target
|
||||||
nfc_initiator_poll_dep_target
|
nfc_initiator_poll_dep_target
|
||||||
nfc_initiator_deselect_target
|
nfc_initiator_deselect_target
|
||||||
|
nfc_initiator_poll_targets
|
||||||
nfc_initiator_transceive_bytes
|
nfc_initiator_transceive_bytes
|
||||||
nfc_initiator_transceive_bits
|
nfc_initiator_transceive_bits
|
||||||
nfc_initiator_transceive_bytes_timed
|
nfc_initiator_transceive_bytes_timed
|
||||||
@ -36,22 +36,13 @@ EXPORTS
|
|||||||
nfc_device_get_connstring
|
nfc_device_get_connstring
|
||||||
nfc_device_get_supported_modulation
|
nfc_device_get_supported_modulation
|
||||||
nfc_device_get_supported_baud_rate
|
nfc_device_get_supported_baud_rate
|
||||||
nfc_device_get_supported_baud_rate_target_mode
|
|
||||||
nfc_device_set_property_int
|
nfc_device_set_property_int
|
||||||
nfc_device_set_property_bool
|
nfc_device_set_property_bool
|
||||||
nfc_emulate_target
|
|
||||||
iso14443a_crc
|
iso14443a_crc
|
||||||
iso14443a_crc_append
|
iso14443a_crc_append
|
||||||
iso14443b_crc
|
|
||||||
iso14443b_crc_append
|
|
||||||
iso14443a_locate_historical_bytes
|
iso14443a_locate_historical_bytes
|
||||||
nfc_free
|
|
||||||
nfc_version
|
nfc_version
|
||||||
nfc_device_get_information_about
|
nfc_device_get_information_about
|
||||||
str_nfc_modulation_type
|
str_nfc_modulation_type
|
||||||
str_nfc_baud_rate
|
str_nfc_baud_rate
|
||||||
str_nfc_target
|
str_nfc_target
|
||||||
pn53x_transceive
|
|
||||||
pn532_SAMConfiguration
|
|
||||||
pn53x_read_register
|
|
||||||
pn53x_write_register
|
|
||||||
|
|||||||
@ -1,57 +0,0 @@
|
|||||||
LIBRARY nfc
|
|
||||||
VERSION 1.7
|
|
||||||
|
|
||||||
EXPORTS
|
|
||||||
nfc_init
|
|
||||||
nfc_exit
|
|
||||||
nfc_register_driver
|
|
||||||
nfc_open
|
|
||||||
nfc_close
|
|
||||||
nfc_abort_command
|
|
||||||
nfc_list_devices
|
|
||||||
nfc_idle
|
|
||||||
nfc_initiator_init
|
|
||||||
nfc_initiator_init_secure_element
|
|
||||||
nfc_initiator_select_passive_target
|
|
||||||
nfc_initiator_list_passive_targets
|
|
||||||
nfc_initiator_poll_target
|
|
||||||
nfc_initiator_select_dep_target
|
|
||||||
nfc_initiator_poll_dep_target
|
|
||||||
nfc_initiator_deselect_target
|
|
||||||
nfc_initiator_transceive_bytes
|
|
||||||
nfc_initiator_transceive_bits
|
|
||||||
nfc_initiator_transceive_bytes_timed
|
|
||||||
nfc_initiator_transceive_bits_timed
|
|
||||||
nfc_initiator_target_is_present
|
|
||||||
nfc_target_init
|
|
||||||
nfc_target_send_bytes
|
|
||||||
nfc_target_receive_bytes
|
|
||||||
nfc_target_send_bits
|
|
||||||
nfc_target_receive_bits
|
|
||||||
nfc_strerror
|
|
||||||
nfc_strerror_r
|
|
||||||
nfc_perror
|
|
||||||
nfc_device_get_last_error
|
|
||||||
nfc_device_get_name
|
|
||||||
nfc_device_get_connstring
|
|
||||||
nfc_device_get_supported_modulation
|
|
||||||
nfc_device_get_supported_baud_rate
|
|
||||||
nfc_device_get_supported_baud_rate_target_mode
|
|
||||||
nfc_device_set_property_int
|
|
||||||
nfc_device_set_property_bool
|
|
||||||
nfc_emulate_target
|
|
||||||
iso14443a_crc
|
|
||||||
iso14443a_crc_append
|
|
||||||
iso14443b_crc
|
|
||||||
iso14443b_crc_append
|
|
||||||
iso14443a_locate_historical_bytes
|
|
||||||
nfc_free
|
|
||||||
nfc_version
|
|
||||||
nfc_device_get_information_about
|
|
||||||
str_nfc_modulation_type
|
|
||||||
str_nfc_baud_rate
|
|
||||||
str_nfc_target
|
|
||||||
pn53x_transceive
|
|
||||||
pn532_SAMConfiguration
|
|
||||||
pn53x_read_register
|
|
||||||
pn53x_write_register
|
|
||||||
@ -1,15 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2013 Alex Lian
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
* Copyright (C) 2013 Alex Lian
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
@ -34,24 +26,21 @@
|
|||||||
// Handle platform specific includes
|
// Handle platform specific includes
|
||||||
#include "contrib/windows.h"
|
#include "contrib/windows.h"
|
||||||
|
|
||||||
//There is no setenv()and unsetenv() in windows,but we can use putenv() instead.
|
|
||||||
int setenv(const char *name, const char *value, int overwrite)
|
int setenv(const char *name, const char *value, int overwrite)
|
||||||
{
|
{
|
||||||
char *env = getenv(name);
|
int exists = GetEnvironmentVariableA(name, NULL, 0);
|
||||||
if ((env && overwrite) || (!env)) {
|
if ((exists && overwrite) || (!exists)) {
|
||||||
char *str[32];
|
if (!SetEnvironmentVariableA(name, value)) {
|
||||||
strcpy(str, name);
|
// Set errno here correctly
|
||||||
strcat(str, "=");
|
return -1;
|
||||||
strcat(str, value);
|
}
|
||||||
return putenv(str);
|
return 0;
|
||||||
}
|
}
|
||||||
|
// Exists and overwrite is 0.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unsetenv(const char *name)
|
void unsetenv(const char *name)
|
||||||
{
|
{
|
||||||
char *str[32];
|
SetEnvironmentVariableA(name, NULL);
|
||||||
strcpy(str, name);
|
|
||||||
strcat(str, "=");
|
|
||||||
putenv(str);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2011 Romuald Conty
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
|||||||
@ -1,14 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2011, 2012, 2013 Romuald Conty
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
|||||||
@ -1,9 +1,15 @@
|
|||||||
|
#include "windows.h"
|
||||||
|
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0
|
FILEVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0
|
||||||
PRODUCTVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0
|
PRODUCTVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
FILEFLAGS 0x0L
|
#ifdef _DEBUG
|
||||||
FILEOS 0x00040004L
|
FILEFLAGS VS_FF_DEBUG|VS_FF_PRERELEASE
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0L
|
||||||
|
#endif
|
||||||
|
FILEOS VOS_NT_WINDOWS32
|
||||||
FILETYPE @RC_FILE_TYPE@
|
FILETYPE @RC_FILE_TYPE@
|
||||||
FILESUBTYPE 0x0L
|
FILESUBTYPE 0x0L
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|||||||
@ -1,15 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2010 Romuald Conty
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2011 Glenn Ergeerts
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
* Copyright (C) 2011 Glenn Ergeerts
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
@ -48,9 +41,7 @@
|
|||||||
# define ENOTSUP WSAEOPNOTSUPP
|
# define ENOTSUP WSAEOPNOTSUPP
|
||||||
# define ECONNABORTED WSAECONNABORTED
|
# define ECONNABORTED WSAECONNABORTED
|
||||||
# else
|
# else
|
||||||
#ifndef _MSC_VER
|
|
||||||
# define snprintf sprintf_s
|
# define snprintf sprintf_s
|
||||||
#endif
|
|
||||||
# define strdup _strdup
|
# define strdup _strdup
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|||||||
14
debian/.gitignore
vendored
Normal file
14
debian/.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
*.debhelper
|
||||||
|
*.log
|
||||||
|
*.substvars
|
||||||
|
autoreconf.after
|
||||||
|
autoreconf.before
|
||||||
|
files
|
||||||
|
libnfc-bin/
|
||||||
|
libnfc-dev/
|
||||||
|
libnfc-examples/
|
||||||
|
libnfc-pn53x-examples/
|
||||||
|
libnfc4.debhelper.log
|
||||||
|
libnfc4/
|
||||||
|
libnfc4-dbg/
|
||||||
|
tmp/
|
||||||
181
debian/changelog
vendored
Normal file
181
debian/changelog
vendored
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
libnfc (1.7.0~rc4-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release
|
||||||
|
|
||||||
|
-- yobibe <yobibe@gmail.com> Wed, 6 Feb 2013 12:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.7.0~rc3-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Upload to Debian. (Closes: #672795)
|
||||||
|
|
||||||
|
-- Nobuhiro Iwamatsu <iwamatsu@debian.org> Fri, 01 Feb 2013 09:01:53 +0900
|
||||||
|
|
||||||
|
libnfc (1.7.0~rc2-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release
|
||||||
|
|
||||||
|
-- romuald conty <romuald@libnfc.org> Sun, 20 Jan 2013 12:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.7.0~rc1-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release
|
||||||
|
|
||||||
|
-- romuald conty <romuald@libnfc.org> Thu, 9 Dec 2012 12:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.6.0rc1-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release
|
||||||
|
|
||||||
|
-- romuald conty <romuald@libnfc.org> Mon, 27 Feb 2012 12:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.5.1pre2.1-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* udev rules file renamed accordingly to udev's readme file
|
||||||
|
|
||||||
|
-- romuald conty <romuald@libnfc.org> Fri, 9 Dec 2011 15:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.5.1-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* Move nfc-emulate-nfcforum-tag2, nfc-emulate-nfcforum-tag4 and
|
||||||
|
nfc-relay-picc from libnfc-examples to libnfc-bin package.
|
||||||
|
* Add nfc-read-forum-tag3 to libnfc-bin package.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Mon, 10 Oct 2011 02:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.5.0pre1.4-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* All drivers are now enabled under Debian;
|
||||||
|
* Add nfc-emulate-nfcforum-tag2 and nfc-mfsetuid to libnfc-examples.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Tue, 13 May 2011 15:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.5.0pre1.3-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* Update debian/copyright.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Wed, 18 May 2011 12:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.5.0pre1.2-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* Change name of lib to libnfc2 to match SONAME major version 2.
|
||||||
|
|
||||||
|
-- Thomas Hood <jdthood@gmail.com> Fri, 13 May 2011 12:00:00 +0100
|
||||||
|
|
||||||
|
libnfc (1.5.0pre1.1-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* Change name of lib to libnfc1 to match SONAME major version 1.
|
||||||
|
* Change section and priority.
|
||||||
|
* Don't depend on automake which doesn't get run on build.
|
||||||
|
(Instead, automake-generated files are included in patches/.)
|
||||||
|
* Set debian/source/format contents to "3.0 (quilt)"
|
||||||
|
* chmod ugo+x ./configure in debian/rules.
|
||||||
|
* Depend on debhelper (>= 7) to match debian/compat.
|
||||||
|
* Make the following changes that were suggested by lintian.
|
||||||
|
* Depend on ${misc:Depends} since we use debhelper.
|
||||||
|
* Use dh_prep instead of dh_clean -k.
|
||||||
|
|
||||||
|
-- Thomas Hood <jdthood@gmail.com> Mon, 10 May 2011 12:00:00 +0100
|
||||||
|
|
||||||
|
libnfc (1.5.0-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* Experimental released version (r1019).
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Mon, 29 Apr 2011 11:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.4.2-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Tue, 21 Feb 2011 11:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.4.1-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Tue, 1 Feb 2011 10:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.4.0-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Tue, 26 Oct 2010 16:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.3.9-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Tue, 31 Aug 2010 14:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.3.4-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Wed, 31 Mar 2010 12:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.3.3-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Thu, 17 Feb 2010 15:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.3.2-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Fri, 29 Jan 2010 15:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.3.1-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Mon, 25 Jan 2010 11:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.3.0-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream release.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Thu, 14 Jan 2010 16:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.2.1-4) unstable; urgency=low
|
||||||
|
|
||||||
|
* Add udev rules for USB PN53x.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Fri, 20 Nov 2009 16:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.2.1-3) unstable; urgency=low
|
||||||
|
|
||||||
|
* Don't use CDBS anymore, should now cross compile.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Thu, 29 Sep 2009 9:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.2.1-2) unstable; urgency=low
|
||||||
|
|
||||||
|
* Add missing dependencies for ACR122 devices (pcscd).
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Fri, 23 Sep 2009 16:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.2.1-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* Description have been updated.
|
||||||
|
* Provided binairies should not be consider as tools but as examples.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Fri, 03 Sep 2009 18:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.2.1-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream version.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Fri, 24 Jul 2009 16:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.2.0-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream version.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Thu, 23 Jul 2009 15:42:42 +0100
|
||||||
|
|
||||||
|
libnfc (1.1.0-0) unstable; urgency=low
|
||||||
|
|
||||||
|
* Initial debian package.
|
||||||
|
|
||||||
|
-- Romuald Conty <romuald@libnfc.org> Wed, 22 Apr 2009 10:42:42 +0100
|
||||||
|
|
||||||
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
9
|
||||||
96
debian/control
vendored
Normal file
96
debian/control
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
Source: libnfc
|
||||||
|
Section: libs
|
||||||
|
Priority: extra
|
||||||
|
Maintainer: Nobuhiro Iwamatsu <iwamatsu@debian.org>
|
||||||
|
Build-Depends: debhelper (>= 9), dh-autoreconf, libtool, pkg-config, libusb-dev
|
||||||
|
Standards-Version: 3.9.4
|
||||||
|
Homepage: http://www.nfc-tools.org/
|
||||||
|
Vcs-Git: https://code.googlecode.com/p/libnfc/
|
||||||
|
Vcs-Browser: http://code.google.com/p/libnfc/source/browse/
|
||||||
|
|
||||||
|
Package: libnfc4
|
||||||
|
Architecture: any
|
||||||
|
Multi-Arch: same
|
||||||
|
Pre-Depends: ${misc:Pre-Depends}
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||||
|
Description: Near Field Communication (NFC) library
|
||||||
|
libnfc is a library for Near Field Communication. It abstracts the
|
||||||
|
low-level details of communicating with the devices away behind an
|
||||||
|
easy-to-use high-level API.
|
||||||
|
It supports most hardware based on the NXP PN531, PN532 or PN533
|
||||||
|
controller chips.
|
||||||
|
.
|
||||||
|
This package contains the runtime library files needed to run software
|
||||||
|
using libnfc.
|
||||||
|
|
||||||
|
Package: libnfc-dev
|
||||||
|
Section: libdevel
|
||||||
|
Architecture: any
|
||||||
|
Multi-Arch: same
|
||||||
|
Depends: ${misc:Depends}, libnfc4 (= ${binary:Version}), libusb-dev
|
||||||
|
Description: Near Field Communication (NFC) library (development files)
|
||||||
|
libnfc is a library for Near Field Communication. It abstracts the
|
||||||
|
low-level details of communicating with the devices away behind an
|
||||||
|
easy-to-use high-level API.
|
||||||
|
It supports most hardware based on the NXP PN531, PN532 or PN533
|
||||||
|
controller chips.
|
||||||
|
.
|
||||||
|
This package contains the header and development files needed to build
|
||||||
|
programs and packages using libnfc.
|
||||||
|
|
||||||
|
Package: libnfc4-dbg
|
||||||
|
Section: debug
|
||||||
|
Architecture: any
|
||||||
|
Multi-Arch: same
|
||||||
|
Depends: ${misc:Depends}, libnfc4 (= ${binary:Version})
|
||||||
|
Description: Near Field Communication (NFC) library (debugging information)
|
||||||
|
libnfc is a library for Near Field Communication. It abstracts the
|
||||||
|
low-level details of communicating with the devices away behind an
|
||||||
|
easy-to-use high-level API.
|
||||||
|
It supports most hardware based on the NXP PN531, PN532 or PN533
|
||||||
|
controller chips.
|
||||||
|
.
|
||||||
|
This package contains the debugging information.
|
||||||
|
|
||||||
|
Package: libnfc-bin
|
||||||
|
Section: utils
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}, libnfc4 (>= ${binary:Version})
|
||||||
|
Description: Near Field Communication (NFC) binaries
|
||||||
|
libnfc is a library for Near Field Communication. It abstracts the
|
||||||
|
low-level details of communicating with the devices away behind an
|
||||||
|
easy-to-use high-level API.
|
||||||
|
It supports most hardware based on the NXP PN531, PN532 or PN533
|
||||||
|
controller chips.
|
||||||
|
.
|
||||||
|
This package contains some utils that come along with libnfc, for
|
||||||
|
development or debugging purposes (including nfc-list, nfc-mfclassic,
|
||||||
|
nfc-mfultralight, etc).
|
||||||
|
|
||||||
|
Package: libnfc-examples
|
||||||
|
Section: utils
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}, libnfc4 (>= ${binary:Version})
|
||||||
|
Description: Near Field Communication (NFC) examples
|
||||||
|
libnfc is a library for Near Field Communication. It abstracts the
|
||||||
|
low-level details of communicating with the devices away behind an
|
||||||
|
easy-to-use high-level API.
|
||||||
|
It supports most hardware based on the NXP PN531, PN532 or PN533
|
||||||
|
controller chips.
|
||||||
|
.
|
||||||
|
Some examples are provided with libnfc for debugging and/or
|
||||||
|
educational purposes (nfc-anticol, nfc-emulate, etc.).
|
||||||
|
|
||||||
|
Package: libnfc-pn53x-examples
|
||||||
|
Section: utils
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}, libnfc4 (>= ${binary:Version})
|
||||||
|
Description: Near Field Communication (NFC) examples for PN53x chips only
|
||||||
|
libnfc is a library for Near Field Communication. It abstracts the
|
||||||
|
low-level details of communicating with the devices away behind an
|
||||||
|
easy-to-use high-level API.
|
||||||
|
It supports most hardware based on the NXP PN531, PN532 or PN533
|
||||||
|
controller chips.
|
||||||
|
.
|
||||||
|
Some PN53x-only examples are provided with libnfc for debugging
|
||||||
|
and/or educational purposes (pn53x-sam, pn53x-tamashell, etc.).
|
||||||
59
debian/copyright
vendored
Normal file
59
debian/copyright
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||||
|
Upstream-Name: libnfc
|
||||||
|
Source: http://libnfc.googlecode.com/
|
||||||
|
|
||||||
|
Files: *
|
||||||
|
Copyright: 2009, Roel Verdult <roel@libnfc.org>, Romuald Conty <romuald@libnfc.org>
|
||||||
|
2010-2011, Romain Tartière <romain@libnfc.org>, Romuald Conty <romuald@libnfc.org>
|
||||||
|
License: LGPL-3
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
as published by the Free Software Foundation
|
||||||
|
.
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
.
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.
|
||||||
|
On Debian GNU/Linux systems, the complete text of the GNU General
|
||||||
|
Public License, version 3, can be found in the file
|
||||||
|
/usr/share/common-licenses/LGPL-3.
|
||||||
|
|
||||||
|
Files: examples/*
|
||||||
|
Copyright: 2009, Roel Verdult <roel@libnfc.org>, Romuald Conty <romuald@libnfc.org>
|
||||||
|
2010-2011, Romain Tartière <romain@libnfc.org>, Romuald Conty <romuald@libnfc.org>
|
||||||
|
License: BSD-2-clause
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
.
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||||
|
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||||
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
Files: debian/*
|
||||||
|
Copyright: 2009-2011, Romuald Conty <romuald@libnfc.org>
|
||||||
|
2011, Thomas Hood <jdthood@gmail.com>
|
||||||
|
2013, Nobuhiro Iwamatsu <iwamatsu@debian.org>
|
||||||
|
License: GPL-2
|
||||||
|
The Debian packaging is licensed under the GPL, version 2.
|
||||||
|
.
|
||||||
|
On Debian GNU/Linux systems, the complete text of the GNU General
|
||||||
|
Public License, version 2, can be found in the file
|
||||||
|
/usr/share/common-licenses/GPL-2.
|
||||||
14
debian/libnfc-bin.install
vendored
Normal file
14
debian/libnfc-bin.install
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
debian/tmp/usr/bin/nfc-emulate-forum-tag4
|
||||||
|
debian/tmp/usr/bin/nfc-list
|
||||||
|
debian/tmp/usr/bin/nfc-mfclassic
|
||||||
|
debian/tmp/usr/bin/nfc-mfultralight
|
||||||
|
debian/tmp/usr/bin/nfc-read-forum-tag3
|
||||||
|
debian/tmp/usr/bin/nfc-relay-picc
|
||||||
|
debian/tmp/usr/bin/nfc-scan-device
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-emulate-forum-tag4.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-list.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-mfclassic.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-mfultralight.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-read-forum-tag3.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-relay-picc.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-scan-device.1
|
||||||
4
debian/libnfc-dev.install
vendored
Normal file
4
debian/libnfc-dev.install
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
debian/tmp/usr/include/nfc
|
||||||
|
debian/tmp/usr/lib/*/libnfc.a
|
||||||
|
debian/tmp/usr/lib/*/libnfc.so
|
||||||
|
debian/tmp/usr/lib/*/pkgconfig/libnfc.pc
|
||||||
18
debian/libnfc-examples.install
vendored
Normal file
18
debian/libnfc-examples.install
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
debian/tmp/usr/bin/nfc-anticol
|
||||||
|
debian/tmp/usr/bin/nfc-dep-initiator
|
||||||
|
debian/tmp/usr/bin/nfc-dep-target
|
||||||
|
debian/tmp/usr/bin/nfc-emulate-forum-tag2
|
||||||
|
debian/tmp/usr/bin/nfc-emulate-tag
|
||||||
|
debian/tmp/usr/bin/nfc-emulate-uid
|
||||||
|
debian/tmp/usr/bin/nfc-mfsetuid
|
||||||
|
debian/tmp/usr/bin/nfc-poll
|
||||||
|
debian/tmp/usr/bin/nfc-relay
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-anticol.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-dep-initiator.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-dep-target.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-emulate-forum-tag2.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-emulate-tag.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-emulate-uid.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-mfsetuid.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-poll.1
|
||||||
|
debian/tmp/usr/share/man/man1/nfc-relay.1
|
||||||
3
debian/libnfc-pn53x-examples.install
vendored
Normal file
3
debian/libnfc-pn53x-examples.install
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
debian/tmp/usr/bin/pn53x-*
|
||||||
|
debian/tmp/usr/share/man/man1/pn53x-*
|
||||||
|
examples/pn53x-tamashell-scripts/*.cmd usr/share/doc/libnfc-pn53x-examples/scripts
|
||||||
2
debian/libnfc4.install
vendored
Normal file
2
debian/libnfc4.install
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
debian/tmp/usr/lib/*/libnfc.so.*
|
||||||
|
contrib/udev/42-pn53x.rules lib/udev/rules.d/
|
||||||
55
debian/libnfc4.symbols
vendored
Normal file
55
debian/libnfc4.symbols
vendored
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
libnfc.so.4 libnfc4 #MINVER#
|
||||||
|
iso14443a_crc@Base 1.7.0~rc4
|
||||||
|
iso14443a_crc_append@Base 1.7.0~rc4
|
||||||
|
iso14443a_locate_historical_bytes@Base 1.7.0~rc4
|
||||||
|
nfc_abort_command@Base 1.7.0~rc4
|
||||||
|
nfc_close@Base 1.7.0~rc4
|
||||||
|
nfc_context_free@Base 1.7.0~rc4
|
||||||
|
nfc_context_new@Base 1.7.0~rc4
|
||||||
|
nfc_device_free@Base 1.7.0~rc4
|
||||||
|
nfc_device_get_connstring@Base 1.7.0~rc4
|
||||||
|
nfc_device_get_information_about@Base 1.7.0~rc4
|
||||||
|
nfc_device_get_last_error@Base 1.7.0~rc4
|
||||||
|
nfc_device_get_name@Base 1.7.0~rc4
|
||||||
|
nfc_device_get_supported_baud_rate@Base 1.7.0~rc4
|
||||||
|
nfc_device_get_supported_modulation@Base 1.7.0~rc4
|
||||||
|
nfc_device_new@Base 1.7.0~rc4
|
||||||
|
nfc_device_set_property_bool@Base 1.7.0~rc4
|
||||||
|
nfc_device_set_property_int@Base 1.7.0~rc4
|
||||||
|
nfc_drivers@Base 1.7.0~rc4
|
||||||
|
nfc_emulate_target@Base 1.7.0~rc4
|
||||||
|
nfc_exit@Base 1.7.0~rc4
|
||||||
|
nfc_idle@Base 1.7.0~rc4
|
||||||
|
nfc_init@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_deselect_target@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_init@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_init_secure_element@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_list_passive_targets@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_poll_dep_target@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_poll_target@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_select_dep_target@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_select_passive_target@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_target_is_present@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_transceive_bits@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_transceive_bits_timed@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_transceive_bytes@Base 1.7.0~rc4
|
||||||
|
nfc_initiator_transceive_bytes_timed@Base 1.7.0~rc4
|
||||||
|
nfc_list_devices@Base 1.7.0~rc4
|
||||||
|
nfc_open@Base 1.7.0~rc4
|
||||||
|
nfc_perror@Base 1.7.0~rc4
|
||||||
|
nfc_register_driver@Base 1.7.0~rc4-0
|
||||||
|
nfc_strerror@Base 1.7.0~rc4
|
||||||
|
nfc_strerror_r@Base 1.7.0~rc4
|
||||||
|
nfc_target_init@Base 1.7.0~rc4
|
||||||
|
nfc_target_receive_bits@Base 1.7.0~rc4
|
||||||
|
nfc_target_receive_bytes@Base 1.7.0~rc4
|
||||||
|
nfc_target_send_bits@Base 1.7.0~rc4
|
||||||
|
nfc_target_send_bytes@Base 1.7.0~rc4
|
||||||
|
nfc_version@Base 1.7.0~rc4
|
||||||
|
pn532_SAMConfiguration@Base 1.7.0~rc4
|
||||||
|
pn53x_read_register@Base 1.7.0~rc4
|
||||||
|
pn53x_transceive@Base 1.7.0~rc4
|
||||||
|
pn53x_write_register@Base 1.7.0~rc4
|
||||||
|
str_nfc_baud_rate@Base 1.7.0~rc4
|
||||||
|
str_nfc_modulation_type@Base 1.7.0~rc4
|
||||||
|
str_nfc_target@Base 1.7.0~rc4
|
||||||
35
debian/rules
vendored
Executable file
35
debian/rules
vendored
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
# -*- makefile -*-
|
||||||
|
# Sample debian/rules that uses debhelper.
|
||||||
|
# This file was originally written by Joey Hess and Craig Small.
|
||||||
|
# As a special exception, when this file is copied by dh-make into a
|
||||||
|
# dh-make output file, you may use that output file without restriction.
|
||||||
|
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
||||||
|
|
||||||
|
# Uncomment this to turn on verbose mode.
|
||||||
|
#export DH_VERBOSE=1
|
||||||
|
|
||||||
|
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
|
||||||
|
|
||||||
|
# "nocheck" option prevents from running tests (which need dedicated hardware)
|
||||||
|
export DEB_BUILD_OPTIONS=nocheck
|
||||||
|
|
||||||
|
# --enable-debug --with-drivers=all
|
||||||
|
confflags := --disable-silent-rules \
|
||||||
|
--prefix=/usr \
|
||||||
|
--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
|
||||||
|
$(NULL)
|
||||||
|
confflags += $(shell dpkg-buildflags --export=configure)
|
||||||
|
|
||||||
|
override_dh_installchangelogs:
|
||||||
|
dh_installchangelogs ChangeLog
|
||||||
|
|
||||||
|
override_dh_auto_configure:
|
||||||
|
dh_auto_configure -- $(confflags)
|
||||||
|
|
||||||
|
%:
|
||||||
|
dh $@ --with autoreconf
|
||||||
|
|
||||||
|
override_dh_strip:
|
||||||
|
dh_strip -plibnfc4 --dbg-package=libnfc4-dbg
|
||||||
|
dh_strip --remaining-packages
|
||||||
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
3.0 (quilt)
|
||||||
7
debian/watch
vendored
Normal file
7
debian/watch
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# See uscan(1) for format
|
||||||
|
|
||||||
|
# Compulsory line, this is a version 3 file
|
||||||
|
version=3
|
||||||
|
|
||||||
|
http://googlecode.debian.net/p/libnfc/libnfc-(.*)\.tar\.gz
|
||||||
|
|
||||||
@ -8,10 +8,6 @@ SET(EXAMPLES-SOURCES
|
|||||||
nfc-mfsetuid
|
nfc-mfsetuid
|
||||||
nfc-poll
|
nfc-poll
|
||||||
nfc-relay
|
nfc-relay
|
||||||
nfc-st25tb
|
|
||||||
pn53x-diagnose
|
|
||||||
pn53x-sam
|
|
||||||
pn53x-tamashell
|
|
||||||
)
|
)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libnfc)
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libnfc)
|
||||||
@ -24,15 +20,9 @@ FOREACH(source ${EXAMPLES-SOURCES})
|
|||||||
SET(RC_COMMENT "${PACKAGE_NAME} example")
|
SET(RC_COMMENT "${PACKAGE_NAME} example")
|
||||||
SET(RC_INTERNAL_NAME ${source})
|
SET(RC_INTERNAL_NAME ${source})
|
||||||
SET(RC_ORIGINAL_NAME ${source}.exe)
|
SET(RC_ORIGINAL_NAME ${source}.exe)
|
||||||
# RC_FILE_TYPE: VFT_APP
|
SET(RC_FILE_TYPE VFT_APP)
|
||||||
SET(RC_FILE_TYPE 0x00000001L)
|
|
||||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc @ONLY)
|
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc @ONLY)
|
||||||
LIST(APPEND TARGETS ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc)
|
LIST(APPEND TARGETS ${CMAKE_CURRENT_BINARY_DIR}/../windows/${source}.rc)
|
||||||
|
|
||||||
|
|
||||||
IF(${source} MATCHES "nfc-st25tb")
|
|
||||||
LIST(APPEND TARGETS ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/getopt.c)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
ADD_EXECUTABLE(${source} ${TARGETS})
|
ADD_EXECUTABLE(${source} ${TARGETS})
|
||||||
|
|||||||
@ -10,7 +10,6 @@ bin_PROGRAMS = \
|
|||||||
nfc-mfsetuid \
|
nfc-mfsetuid \
|
||||||
nfc-poll \
|
nfc-poll \
|
||||||
nfc-relay \
|
nfc-relay \
|
||||||
nfc-st25tb \
|
|
||||||
pn53x-diagnose \
|
pn53x-diagnose \
|
||||||
pn53x-sam
|
pn53x-sam
|
||||||
|
|
||||||
@ -64,9 +63,6 @@ nfc_mfsetuid_SOURCES = nfc-mfsetuid.c
|
|||||||
nfc_mfsetuid_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
nfc_mfsetuid_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/utils/libnfcutils.la
|
||||||
|
|
||||||
nfc_st25tb_SOURCES = nfc-st25tb.c
|
|
||||||
nfc_st25tb_LDADD = $(top_builddir)/libnfc/libnfc.la
|
|
||||||
|
|
||||||
pn53x_diagnose_SOURCES = pn53x-diagnose.c
|
pn53x_diagnose_SOURCES = pn53x-diagnose.c
|
||||||
pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
pn53x_diagnose_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/utils/libnfcutils.la
|
||||||
@ -78,7 +74,6 @@ pn53x_sam_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
|||||||
pn53x_tamashell_SOURCES = pn53x-tamashell.c
|
pn53x_tamashell_SOURCES = pn53x-tamashell.c
|
||||||
pn53x_tamashell_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
pn53x_tamashell_LDADD = $(top_builddir)/libnfc/libnfc.la \
|
||||||
$(top_builddir)/utils/libnfcutils.la
|
$(top_builddir)/utils/libnfcutils.la
|
||||||
pn53x_tamashell_CFLAGS = @READLINE_INCLUDES@ -I$(top_srcdir)
|
|
||||||
pn53x_tamashell_LDFLAGS = @READLINE_LIBS@
|
pn53x_tamashell_LDFLAGS = @READLINE_LIBS@
|
||||||
|
|
||||||
quick_start_example1_SOURCES = doc/quick_start_example1.c
|
quick_start_example1_SOURCES = doc/quick_start_example1.c
|
||||||
|
|||||||
@ -6,7 +6,12 @@
|
|||||||
// To compile this simple example:
|
// To compile this simple example:
|
||||||
// $ gcc -o quick_start_example1 quick_start_example1.c -lnfc
|
// $ gcc -o quick_start_example1 quick_start_example1.c -lnfc
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <err.h>
|
||||||
#include <nfc/nfc.h>
|
#include <nfc/nfc.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -31,14 +36,9 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
// Initialize libnfc and set the nfc_context
|
// Initialize libnfc and set the nfc_context
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
printf("Unable to init libnfc (malloc)\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display libnfc version
|
// Display libnfc version
|
||||||
const char *acLibnfcVersion = nfc_version();
|
const char *acLibnfcVersion = nfc_version();
|
||||||
(void)argc;
|
|
||||||
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||||
|
|
||||||
// Open, using the first available NFC device which can be in order of selection:
|
// Open, using the first available NFC device which can be in order of selection:
|
||||||
@ -49,8 +49,8 @@ main(int argc, const char *argv[])
|
|||||||
pnd = nfc_open(context, NULL);
|
pnd = nfc_open(context, NULL);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
printf("ERROR: %s\n", "Unable to open NFC device.");
|
warnx("ERROR: %s", "Unable to open NFC device.");
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
// Set opened NFC device to initiator mode
|
// Set opened NFC device to initiator mode
|
||||||
if (nfc_initiator_init(pnd) < 0) {
|
if (nfc_initiator_init(pnd) < 0) {
|
||||||
@ -82,5 +82,5 @@ main(int argc, const char *argv[])
|
|||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
// Release the context
|
// Release the context
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_SUCCESS);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,14 +28,9 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
// Initialize libnfc and set the nfc_context
|
// Initialize libnfc and set the nfc_context
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display libnfc version
|
// Display libnfc version
|
||||||
const char *acLibnfcVersion = nfc_version();
|
const char *acLibnfcVersion = nfc_version();
|
||||||
(void)argc;
|
|
||||||
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||||
|
|
||||||
// Open, using the first available NFC device which can be in order of selection:
|
// Open, using the first available NFC device which can be in order of selection:
|
||||||
@ -47,7 +42,7 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
ERR("%s", "Unable to open NFC device.");
|
ERR("%s", "Unable to open NFC device.");
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
// Set opened NFC device to initiator mode
|
// Set opened NFC device to initiator mode
|
||||||
if (nfc_initiator_init(pnd) < 0) {
|
if (nfc_initiator_init(pnd) < 0) {
|
||||||
@ -79,5 +74,5 @@ main(int argc, const char *argv[])
|
|||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
// Release the context
|
// Release the context
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_SUCCESS);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,14 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2009 Roel Verdult
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -71,7 +64,6 @@ static nfc_device *pnd;
|
|||||||
|
|
||||||
bool quiet_output = false;
|
bool quiet_output = false;
|
||||||
bool force_rats = false;
|
bool force_rats = false;
|
||||||
bool timed = false;
|
|
||||||
bool iso_ats_supported = false;
|
bool iso_ats_supported = false;
|
||||||
|
|
||||||
// ISO14443A Anti-Collision Commands
|
// ISO14443A Anti-Collision Commands
|
||||||
@ -85,23 +77,15 @@ uint8_t abtHalt[4] = { 0x50, 0x00, 0x00, 0x00 };
|
|||||||
static bool
|
static bool
|
||||||
transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
|
transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
|
||||||
{
|
{
|
||||||
uint32_t cycles = 0;
|
|
||||||
// Show transmitted command
|
// Show transmitted command
|
||||||
if (!quiet_output) {
|
if (!quiet_output) {
|
||||||
printf("Sent bits: ");
|
printf("Sent bits: ");
|
||||||
print_hex_bits(pbtTx, szTxBits);
|
print_hex_bits(pbtTx, szTxBits);
|
||||||
}
|
}
|
||||||
// Transmit the bit frame command, we don't use the arbitrary parity feature
|
// Transmit the bit frame command, we don't use the arbitrary parity feature
|
||||||
if (timed) {
|
if ((szRxBits = nfc_initiator_transceive_bits(pnd, pbtTx, szTxBits, NULL, abtRx, sizeof(abtRx), NULL)) < 0)
|
||||||
if ((szRxBits = nfc_initiator_transceive_bits_timed(pnd, pbtTx, szTxBits, NULL, abtRx, sizeof(abtRx), NULL, &cycles)) < 0)
|
return false;
|
||||||
return false;
|
|
||||||
if ((!quiet_output) && (szRxBits > 0)) {
|
|
||||||
printf("Response after %u cycles\n", cycles);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((szRxBits = nfc_initiator_transceive_bits(pnd, pbtTx, szTxBits, NULL, abtRx, sizeof(abtRx), NULL)) < 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Show received answer
|
// Show received answer
|
||||||
if (!quiet_output) {
|
if (!quiet_output) {
|
||||||
printf("Received bits: ");
|
printf("Received bits: ");
|
||||||
@ -115,7 +99,6 @@ transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
|
|||||||
static bool
|
static bool
|
||||||
transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
|
transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
|
||||||
{
|
{
|
||||||
uint32_t cycles = 0;
|
|
||||||
// Show transmitted command
|
// Show transmitted command
|
||||||
if (!quiet_output) {
|
if (!quiet_output) {
|
||||||
printf("Sent bits: ");
|
printf("Sent bits: ");
|
||||||
@ -123,21 +106,13 @@ transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
|
|||||||
}
|
}
|
||||||
int res;
|
int res;
|
||||||
// Transmit the command bytes
|
// Transmit the command bytes
|
||||||
if (timed) {
|
if ((res = nfc_initiator_transceive_bytes(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
|
||||||
if ((res = nfc_initiator_transceive_bytes_timed(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), &cycles)) < 0)
|
return false;
|
||||||
return false;
|
|
||||||
if ((!quiet_output) && (res > 0)) {
|
|
||||||
printf("Response after %u cycles\n", cycles);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((res = nfc_initiator_transceive_bytes(pnd, pbtTx, szTx, abtRx, sizeof(abtRx), 0)) < 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
szRx = res;
|
|
||||||
// Show received answer
|
// Show received answer
|
||||||
if (!quiet_output) {
|
if (!quiet_output) {
|
||||||
printf("Received bits: ");
|
printf("Received bits: ");
|
||||||
print_hex(abtRx, szRx);
|
print_hex(abtRx, res);
|
||||||
}
|
}
|
||||||
// Succesful transfer
|
// Succesful transfer
|
||||||
return true;
|
return true;
|
||||||
@ -151,7 +126,6 @@ print_usage(char *argv[])
|
|||||||
printf("\t-h\tHelp. Print this message.\n");
|
printf("\t-h\tHelp. Print this message.\n");
|
||||||
printf("\t-q\tQuiet mode. Suppress output of READER and EMULATOR data (improves timing).\n");
|
printf("\t-q\tQuiet mode. Suppress output of READER and EMULATOR data (improves timing).\n");
|
||||||
printf("\t-f\tForce RATS.\n");
|
printf("\t-f\tForce RATS.\n");
|
||||||
printf("\t-t\tMeasure response time (in cycles).\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -168,8 +142,6 @@ main(int argc, char *argv[])
|
|||||||
quiet_output = true;
|
quiet_output = true;
|
||||||
} else if (0 == strcmp(argv[arg], "-f")) {
|
} else if (0 == strcmp(argv[arg], "-f")) {
|
||||||
force_rats = true;
|
force_rats = true;
|
||||||
} else if (0 == strcmp(argv[arg], "-t")) {
|
|
||||||
timed = true;
|
|
||||||
} else {
|
} else {
|
||||||
ERR("%s is not supported option.", argv[arg]);
|
ERR("%s is not supported option.", argv[arg]);
|
||||||
print_usage(argv);
|
print_usage(argv);
|
||||||
@ -179,47 +151,34 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
nfc_context *context;
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_open(context, NULL);
|
pnd = nfc_open(context, NULL);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (!pnd) {
|
||||||
ERR("Error opening NFC reader");
|
printf("Error opening NFC reader\n");
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise NFC device as "initiator"
|
// Initialise NFC device as "initiator"
|
||||||
if (nfc_initiator_init(pnd) < 0) {
|
if (nfc_initiator_init(pnd) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_init");
|
nfc_perror(pnd, "nfc_initiator_init");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the CRC
|
// Configure the CRC
|
||||||
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
|
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
|
||||||
nfc_perror(pnd, "nfc_device_set_property_bool");
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
// Use raw send/receive methods
|
// Use raw send/receive methods
|
||||||
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
|
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
|
||||||
nfc_perror(pnd, "nfc_device_set_property_bool");
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
// Disable 14443-4 autoswitching
|
// Disable 14443-4 autoswitching
|
||||||
if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
|
if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
|
||||||
nfc_perror(pnd, "nfc_device_set_property_bool");
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +189,7 @@ main(int argc, char *argv[])
|
|||||||
printf("Error: No tag available\n");
|
printf("Error: No tag available\n");
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
memcpy(abtAtqa, abtRx, 2);
|
memcpy(abtAtqa, abtRx, 2);
|
||||||
|
|
||||||
@ -360,5 +319,5 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_SUCCESS);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2009 Roel Verdult
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2010 Romuald Conty
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -55,17 +49,14 @@
|
|||||||
#define MAX_FRAME_LEN 264
|
#define MAX_FRAME_LEN 264
|
||||||
|
|
||||||
static nfc_device *pnd;
|
static nfc_device *pnd;
|
||||||
static nfc_context *context;
|
|
||||||
|
|
||||||
static void stop_dep_communication(int sig)
|
static void stop_dep_communication(int sig)
|
||||||
{
|
{
|
||||||
(void) sig;
|
(void) sig;
|
||||||
if (pnd != NULL) {
|
if (pnd)
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
} else {
|
else
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -77,20 +68,16 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
printf("Usage: %s\n", argv[0]);
|
printf("Usage: %s\n", argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
pnd = nfc_open(context, NULL);
|
pnd = nfc_open(context, NULL);
|
||||||
if (pnd == NULL) {
|
if (!pnd) {
|
||||||
ERR("Unable to open NFC device.");
|
printf("Unable to open NFC device.\n");
|
||||||
nfc_exit(context);
|
return EXIT_FAILURE;
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
printf("NFC device: %s\n opened", nfc_device_get_name(pnd));
|
printf("NFC device: %s\n opened", nfc_device_get_name(pnd));
|
||||||
|
|
||||||
@ -98,26 +85,20 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
if (nfc_initiator_init(pnd) < 0) {
|
if (nfc_initiator_init(pnd) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_init");
|
nfc_perror(pnd, "nfc_initiator_init");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nfc_initiator_select_dep_target(pnd, NDM_PASSIVE, NBR_212, NULL, &nt, 1000) < 0) {
|
if (nfc_initiator_select_dep_target(pnd, NDM_PASSIVE, NBR_212, NULL, &nt, 1000) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_select_dep_target");
|
nfc_perror(pnd, "nfc_initiator_select_dep_target");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
print_nfc_target(&nt, false);
|
print_nfc_target(nt, false);
|
||||||
|
|
||||||
printf("Sending: %s\n", abtTx);
|
printf("Sending: %s\n", abtTx);
|
||||||
int res;
|
int res;
|
||||||
if ((res = nfc_initiator_transceive_bytes(pnd, abtTx, sizeof(abtTx), abtRx, sizeof(abtRx), 0)) < 0) {
|
if ((res = nfc_initiator_transceive_bytes(pnd, abtTx, sizeof(abtTx), abtRx, sizeof(abtRx), 0)) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_transceive_bytes");
|
nfc_perror(pnd, "nfc_initiator_transceive_bytes");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abtRx[res] = 0;
|
abtRx[res] = 0;
|
||||||
@ -125,12 +106,11 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
if (nfc_initiator_deselect_target(pnd) < 0) {
|
if (nfc_initiator_deselect_target(pnd) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_deselect_target");
|
nfc_perror(pnd, "nfc_initiator_deselect_target");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_SUCCESS);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2009 Roel Verdult
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2010 Romuald Conty
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -54,17 +48,14 @@
|
|||||||
#define MAX_FRAME_LEN 264
|
#define MAX_FRAME_LEN 264
|
||||||
|
|
||||||
static nfc_device *pnd;
|
static nfc_device *pnd;
|
||||||
static nfc_context *context;
|
|
||||||
|
|
||||||
static void stop_dep_communication(int sig)
|
static void stop_dep_communication(int sig)
|
||||||
{
|
{
|
||||||
(void) sig;
|
(void) sig;
|
||||||
if (pnd != NULL) {
|
if (pnd)
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
} else {
|
else
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -74,16 +65,8 @@ main(int argc, const char *argv[])
|
|||||||
int szRx;
|
int szRx;
|
||||||
uint8_t abtTx[] = "Hello Mars!";
|
uint8_t abtTx[] = "Hello Mars!";
|
||||||
|
|
||||||
if (argc > 1) {
|
nfc_context *context;
|
||||||
printf("Usage: %s\n", argv[0]);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
#define MAX_DEVICE_COUNT 2
|
#define MAX_DEVICE_COUNT 2
|
||||||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||||
size_t szDeviceFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
|
size_t szDeviceFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
|
||||||
@ -97,8 +80,12 @@ main(int argc, const char *argv[])
|
|||||||
pnd = nfc_open(context, connstrings[1]);
|
pnd = nfc_open(context, connstrings[1]);
|
||||||
} else {
|
} else {
|
||||||
printf("No device found.\n");
|
printf("No device found.\n");
|
||||||
nfc_exit(context);
|
return EXIT_FAILURE;
|
||||||
exit(EXIT_FAILURE);
|
}
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
printf("Usage: %s\n", argv[0]);
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_target nt = {
|
nfc_target nt = {
|
||||||
@ -122,32 +109,27 @@ main(int argc, const char *argv[])
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (!pnd) {
|
||||||
printf("Unable to open NFC device.\n");
|
printf("Unable to open NFC device.\n");
|
||||||
nfc_exit(context);
|
return EXIT_FAILURE;
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
|
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
|
||||||
|
|
||||||
signal(SIGINT, stop_dep_communication);
|
signal(SIGINT, stop_dep_communication);
|
||||||
|
|
||||||
printf("NFC device will now act as: ");
|
printf("NFC device will now act as: ");
|
||||||
print_nfc_target(&nt, false);
|
print_nfc_target(nt, false);
|
||||||
|
|
||||||
printf("Waiting for initiator request...\n");
|
printf("Waiting for initiator request...\n");
|
||||||
if ((szRx = nfc_target_init(pnd, &nt, abtRx, sizeof(abtRx), 0)) < 0) {
|
if ((szRx = nfc_target_init(pnd, &nt, abtRx, sizeof(abtRx), 0)) < 0) {
|
||||||
nfc_perror(pnd, "nfc_target_init");
|
nfc_perror(pnd, "nfc_target_init");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Initiator request received. Waiting for data...\n");
|
printf("Initiator request received. Waiting for data...\n");
|
||||||
if ((szRx = nfc_target_receive_bytes(pnd, abtRx, sizeof(abtRx), 0)) < 0) {
|
if ((szRx = nfc_target_receive_bytes(pnd, abtRx, sizeof(abtRx), 0)) < 0) {
|
||||||
nfc_perror(pnd, "nfc_target_receive_bytes");
|
nfc_perror(pnd, "nfc_target_receive_bytes");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
abtRx[(size_t) szRx] = '\0';
|
abtRx[(size_t) szRx] = '\0';
|
||||||
printf("Received: %s\n", abtRx);
|
printf("Received: %s\n", abtRx);
|
||||||
@ -155,13 +137,12 @@ main(int argc, const char *argv[])
|
|||||||
printf("Sending: %s\n", abtTx);
|
printf("Sending: %s\n", abtTx);
|
||||||
if (nfc_target_send_bytes(pnd, abtTx, sizeof(abtTx), 0) < 0) {
|
if (nfc_target_send_bytes(pnd, abtTx, sizeof(abtTx), 0) < 0) {
|
||||||
nfc_perror(pnd, "nfc_target_send_bytes");
|
nfc_perror(pnd, "nfc_target_send_bytes");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
printf("Data sent.\n");
|
printf("Data sent.\n");
|
||||||
|
|
||||||
|
error:
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_SUCCESS);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ bug, this problem is due to ACR122's internal MCU in front of NFC chip (PN532).
|
|||||||
Please report any bugs on the
|
Please report any bugs on the
|
||||||
.Em libnfc
|
.Em libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.Em https://github.com/nfc-tools/libnfc/issues
|
.Em http://code.google.com/p/libnfc/issues
|
||||||
.Sh LICENCE
|
.Sh LICENCE
|
||||||
.Em libnfc
|
.Em libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,14 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2011 Romuald Conty
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -81,16 +74,14 @@
|
|||||||
#include "utils/nfc-utils.h"
|
#include "utils/nfc-utils.h"
|
||||||
|
|
||||||
static nfc_device *pnd;
|
static nfc_device *pnd;
|
||||||
static nfc_context *context;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stop_emulation(int sig)
|
stop_emulation(int sig)
|
||||||
{
|
{
|
||||||
(void)sig;
|
(void)sig;
|
||||||
if (pnd != NULL) {
|
if (pnd) {
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
} else {
|
} else {
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,16 +185,12 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
signal(SIGINT, stop_emulation);
|
signal(SIGINT, stop_emulation);
|
||||||
|
|
||||||
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
pnd = nfc_open(context, NULL);
|
pnd = nfc_open(context, NULL);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
ERR("Unable to open NFC device");
|
ERR("Unable to open NFC device");
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,13 +198,18 @@ main(int argc, char *argv[])
|
|||||||
printf("Emulating NDEF tag now, please touch it with a second NFC device\n");
|
printf("Emulating NDEF tag now, please touch it with a second NFC device\n");
|
||||||
|
|
||||||
if (nfc_emulate_target(pnd, &emulator, 0) < 0) {
|
if (nfc_emulate_target(pnd, &emulator, 0) < 0) {
|
||||||
nfc_perror(pnd, argv[0]);
|
goto error;
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (pnd) {
|
||||||
|
nfc_perror(pnd, argv[0]);
|
||||||
|
nfc_close(pnd);
|
||||||
|
nfc_exit(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,14 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2010 Romuald Conty
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -74,9 +67,8 @@ intr_hdlr(int sig)
|
|||||||
(void) sig;
|
(void) sig;
|
||||||
printf("\nQuitting...\n");
|
printf("\nQuitting...\n");
|
||||||
if (pnd != NULL) {
|
if (pnd != NULL) {
|
||||||
nfc_abort_command(pnd);
|
nfc_close(pnd);
|
||||||
}
|
}
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -166,12 +158,7 @@ nfc_target_emulate_tag(nfc_device *dev, nfc_target *pnt)
|
|||||||
}
|
}
|
||||||
if (loop) {
|
if (loop) {
|
||||||
if (init_mfc_auth) {
|
if (init_mfc_auth) {
|
||||||
if (nfc_device_set_property_bool(dev, NP_HANDLE_CRC, false) < 0) {
|
nfc_device_set_property_bool(dev, NP_HANDLE_CRC, false);
|
||||||
nfc_perror(pnd, "nfc_target_emulate_tag");
|
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
init_mfc_auth = false;
|
init_mfc_auth = false;
|
||||||
}
|
}
|
||||||
if ((szRx = nfc_target_receive_bytes(dev, abtRx, sizeof(abtRx), 0)) < 0) {
|
if ((szRx = nfc_target_receive_bytes(dev, abtRx, sizeof(abtRx), 0)) < 0) {
|
||||||
@ -196,21 +183,16 @@ main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
// Try to open the NFC reader
|
||||||
exit(EXIT_FAILURE);
|
pnd = nfc_open(context, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
// Display libnfc version
|
// Display libnfc version
|
||||||
acLibnfcVersion = nfc_version();
|
acLibnfcVersion = nfc_version();
|
||||||
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
printf("%s uses libnfc %s\n", argv[0], acLibnfcVersion);
|
||||||
|
|
||||||
// Try to open the NFC reader
|
|
||||||
pnd = nfc_open(context, NULL);
|
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
ERR("Unable to open NFC device");
|
ERR("Unable to open NFC device");
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,9 +248,9 @@ main(int argc, char *argv[])
|
|||||||
},
|
},
|
||||||
.nti = {
|
.nti = {
|
||||||
.nai = {
|
.nai = {
|
||||||
.abtAtqa = { 0x03, 0x44 },
|
abtAtqa = { 0x03, 0x44 },
|
||||||
.abtUid = { 0x08, 0xab, 0xcd, 0xef },
|
abtUid = { 0x08, 0xab, 0xcd, 0xef },
|
||||||
.btSak = 0x20,
|
btSak = 0x20,
|
||||||
.szUidLen = 4,
|
.szUidLen = 4,
|
||||||
.abtAts = { 0x75, 0x77, 0x81, 0x02, 0x80 },
|
.abtAts = { 0x75, 0x77, 0x81, 0x02, 0x80 },
|
||||||
.szAtsLen = 5,
|
.szAtsLen = 5,
|
||||||
@ -278,20 +260,13 @@ main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
printf("%s will emulate this ISO14443-A tag:\n", argv[0]);
|
printf("%s will emulate this ISO14443-A tag:\n", argv[0]);
|
||||||
print_nfc_target(&nt, true);
|
print_nfc_target(nt, true);
|
||||||
|
|
||||||
// Switch off NP_EASY_FRAMING if target is not ISO14443-4
|
// Switch off NP_EASY_FRAMING if target is not ISO14443-4
|
||||||
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, (nt.nti.nai.btSak & SAK_ISO14443_4_COMPLIANT)) < 0) {
|
nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, (nt.nti.nai.btSak & SAK_ISO14443_4_COMPLIANT));
|
||||||
nfc_perror(pnd, "nfc_target_emulate_tag");
|
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
printf("NFC device (configured as target) is now emulating the tag, please touch it with a second NFC device (initiator)\n");
|
printf("NFC device (configured as target) is now emulating the tag, please touch it with a second NFC device (initiator)\n");
|
||||||
if (!nfc_target_emulate_tag(pnd, &nt)) {
|
if (!nfc_target_emulate_tag(pnd, &nt)) {
|
||||||
nfc_perror(pnd, "nfc_target_emulate_tag");
|
nfc_perror(pnd, "nfc_target_emulate_tag");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ fully customized UID but only of "random" UIDs, which always start with 0x08.
|
|||||||
The nfc-emulate-uid tool demonstrates that this can still be done using
|
The nfc-emulate-uid tool demonstrates that this can still be done using
|
||||||
transmission of raw frames, and the desired UID can be optionally specified.
|
transmission of raw frames, and the desired UID can be optionally specified.
|
||||||
|
|
||||||
This makes it a serious threat for security systems that rely only on the
|
This makes it a serious thread for security systems that rely only on the
|
||||||
uniqueness of the UID.
|
uniqueness of the UID.
|
||||||
|
|
||||||
Unfortunately, this example can't directly start in fully customisable
|
Unfortunately, this example can't directly start in fully customisable
|
||||||
@ -54,7 +54,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2009 Roel Verdult
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2010 Romuald Conty
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -65,7 +59,6 @@
|
|||||||
static uint8_t abtRecv[MAX_FRAME_LEN];
|
static uint8_t abtRecv[MAX_FRAME_LEN];
|
||||||
static int szRecvBits;
|
static int szRecvBits;
|
||||||
static nfc_device *pnd;
|
static nfc_device *pnd;
|
||||||
static nfc_context *context;
|
|
||||||
|
|
||||||
// ISO14443A Anti-Collision response
|
// ISO14443A Anti-Collision response
|
||||||
uint8_t abtAtqa[2] = { 0x04, 0x00 };
|
uint8_t abtAtqa[2] = { 0x04, 0x00 };
|
||||||
@ -79,10 +72,7 @@ intr_hdlr(int sig)
|
|||||||
if (pnd != NULL) {
|
if (pnd != NULL) {
|
||||||
printf("\nAborting current command...\n");
|
printf("\nAborting current command...\n");
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
nfc_close(pnd);
|
|
||||||
}
|
}
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -136,18 +126,14 @@ main(int argc, char *argv[])
|
|||||||
signal(SIGINT, intr_hdlr);
|
signal(SIGINT, intr_hdlr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to open the NFC device
|
// Try to open the NFC device
|
||||||
pnd = nfc_open(context, NULL);
|
pnd = nfc_open(context, NULL);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
ERR("Unable to open NFC device");
|
printf("Unable to open NFC device\n");
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,17 +162,13 @@ main(int argc, char *argv[])
|
|||||||
if ((szRecvBits = nfc_target_init(pnd, &nt, abtRecv, sizeof(abtRecv), 0)) < 0) {
|
if ((szRecvBits = nfc_target_init(pnd, &nt, abtRecv, sizeof(abtRecv), 0)) < 0) {
|
||||||
nfc_perror(pnd, "nfc_target_init");
|
nfc_perror(pnd, "nfc_target_init");
|
||||||
ERR("Could not come out of auto-emulation, no command was received");
|
ERR("Could not come out of auto-emulation, no command was received");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
printf("[+] Received initiator command: ");
|
printf("[+] Received initiator command: ");
|
||||||
print_hex_bits(abtRecv, (size_t) szRecvBits);
|
print_hex_bits(abtRecv, (size_t) szRecvBits);
|
||||||
printf("[+] Configuring communication\n");
|
printf("[+] Configuring communication\n");
|
||||||
if ((nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) || (nfc_device_set_property_bool(pnd, NP_HANDLE_PARITY, true) < 0)) {
|
if ((nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) || (nfc_device_set_property_bool(pnd, NP_HANDLE_PARITY, true) < 0)) {
|
||||||
nfc_perror(pnd, "nfc_device_set_property_bool");
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
printf("[+] Done, the emulated tag is initialized with UID: %02X%02X%02X%02X\n\n", abtUidBcc[0], abtUidBcc[1],
|
printf("[+] Done, the emulated tag is initialized with UID: %02X%02X%02X%02X\n\n", abtUidBcc[0], abtUidBcc[1],
|
||||||
@ -229,9 +211,7 @@ main(int argc, char *argv[])
|
|||||||
// Send and print the command to the screen
|
// Send and print the command to the screen
|
||||||
if (nfc_target_send_bits(pnd, pbtTx, szTxBits, NULL) < 0) {
|
if (nfc_target_send_bits(pnd, pbtTx, szTxBits, NULL) < 0) {
|
||||||
nfc_perror(pnd, "nfc_target_send_bits");
|
nfc_perror(pnd, "nfc_target_send_bits");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
if (!quiet_output) {
|
if (!quiet_output) {
|
||||||
printf("T: ");
|
printf("T: ");
|
||||||
@ -240,4 +220,12 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nfc_close(pnd);
|
||||||
|
nfc_exit(context);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
|
error:
|
||||||
|
nfc_close(pnd);
|
||||||
|
nfc_exit(context);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,16 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2009 Roel Verdult
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2011 Adam Laurie
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
* Copyright (C) 2011 Adam Laurie
|
|
||||||
* Copyright (C) 2014 Dario Carluccio
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -141,13 +133,12 @@ transmit_bytes(const uint8_t *pbtTx, const size_t szTx)
|
|||||||
static void
|
static void
|
||||||
print_usage(char *argv[])
|
print_usage(char *argv[])
|
||||||
{
|
{
|
||||||
printf("Usage: %s [OPTIONS] [UID|BLOCK0]\n", argv[0]);
|
printf("Usage: %s [OPTIONS] [UID]\n", argv[0]);
|
||||||
printf("Options:\n");
|
printf("Options:\n");
|
||||||
printf("\t-h\tHelp. Print this message.\n");
|
printf("\t-h\tHelp. Print this message.\n");
|
||||||
printf("\t-f\tFormat. Delete all data (set to 0xFF) and reset ACLs to default.\n");
|
printf("\t-f\tFormat. Delete all data (set to 0xFF) and reset ACLs to default.\n");
|
||||||
printf("\t-q\tQuiet mode. Suppress output of READER and CARD data (improves timing).\n");
|
printf("\t-q\tQuiet mode. Suppress output of READER and CARD data (improves timing).\n");
|
||||||
printf("\n\tSpecify UID (4 HEX bytes) to set UID, or leave blank for default '01234567'.\n");
|
printf("\n\tSpecify UID (4 HEX bytes) to set UID, or leave blank for default '01234567'.\n");
|
||||||
printf("\n\tSpecify BLOCK0 (16 HEX bytes) to set content of Block0. CRC (Byte 4) is recalculated an overwritten'.\n");
|
|
||||||
printf("\tThis utility can be used to recover cards that have been damaged by writing bad\n");
|
printf("\tThis utility can be used to recover cards that have been damaged by writing bad\n");
|
||||||
printf("\tdata (e.g. wrong BCC), thus making them non-selectable by most tools/readers.\n");
|
printf("\tdata (e.g. wrong BCC), thus making them non-selectable by most tools/readers.\n");
|
||||||
printf("\n\t*** Note: this utility only works with special Mifare 1K cards (Chinese clones).\n\n");
|
printf("\n\t*** Note: this utility only works with special Mifare 1K cards (Chinese clones).\n\n");
|
||||||
@ -179,14 +170,6 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
abtData[4] = abtData[0] ^ abtData[1] ^ abtData[2] ^ abtData[3];
|
abtData[4] = abtData[0] ^ abtData[1] ^ abtData[2] ^ abtData[3];
|
||||||
iso14443a_crc_append(abtData, 16);
|
iso14443a_crc_append(abtData, 16);
|
||||||
} else if (strlen(argv[arg]) == 32) {
|
|
||||||
for (i = 0 ; i < 16 ; ++i) {
|
|
||||||
memcpy(tmp, argv[arg] + i * 2, 2);
|
|
||||||
sscanf(tmp, "%02x", &c);
|
|
||||||
abtData[i] = (char) c;
|
|
||||||
}
|
|
||||||
abtData[4] = abtData[0] ^ abtData[1] ^ abtData[2] ^ abtData[3];
|
|
||||||
iso14443a_crc_append(abtData, 16);
|
|
||||||
} else {
|
} else {
|
||||||
ERR("%s is not supported option.", argv[arg]);
|
ERR("%s is not supported option.", argv[arg]);
|
||||||
print_usage(argv);
|
print_usage(argv);
|
||||||
@ -196,47 +179,34 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
nfc_context *context;
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_open(context, NULL);
|
pnd = nfc_open(context, NULL);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (!pnd) {
|
||||||
ERR("Error opening NFC reader");
|
printf("Error opening NFC reader\n");
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise NFC device as "initiator"
|
// Initialise NFC device as "initiator"
|
||||||
if (nfc_initiator_init(pnd) < 0) {
|
if (nfc_initiator_init(pnd) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_init");
|
nfc_perror(pnd, "nfc_initiator_init");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the CRC
|
// Configure the CRC
|
||||||
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
|
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
|
||||||
nfc_perror(pnd, "nfc_device_set_property_bool");
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
// Use raw send/receive methods
|
// Use raw send/receive methods
|
||||||
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
|
if (nfc_device_set_property_bool(pnd, NP_EASY_FRAMING, false) < 0) {
|
||||||
nfc_perror(pnd, "nfc_device_set_property_bool");
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
// Disable 14443-4 autoswitching
|
// Disable 14443-4 autoswitching
|
||||||
if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
|
if (nfc_device_set_property_bool(pnd, NP_AUTO_ISO14443_4, false) < 0) {
|
||||||
nfc_perror(pnd, "nfc_device_set_property_bool");
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +217,7 @@ main(int argc, char *argv[])
|
|||||||
printf("Error: No tag available\n");
|
printf("Error: No tag available\n");
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
return 1;
|
||||||
}
|
}
|
||||||
memcpy(abtAtqa, abtRx, 2);
|
memcpy(abtAtqa, abtRx, 2);
|
||||||
|
|
||||||
@ -365,23 +335,13 @@ main(int argc, char *argv[])
|
|||||||
// now reset UID
|
// now reset UID
|
||||||
iso14443a_crc_append(abtHalt, 2);
|
iso14443a_crc_append(abtHalt, 2);
|
||||||
transmit_bytes(abtHalt, 4);
|
transmit_bytes(abtHalt, 4);
|
||||||
|
transmit_bits(abtUnlock1, 7);
|
||||||
if (!transmit_bits(abtUnlock1, 7)) {
|
if (format) {
|
||||||
printf("Warning: Unlock command [1/2]: failed / not acknowledged.\n");
|
transmit_bytes(abtWipe, 1);
|
||||||
} else {
|
transmit_bytes(abtHalt, 4);
|
||||||
if (format) {
|
transmit_bits(abtUnlock1, 7);
|
||||||
transmit_bytes(abtWipe, 1);
|
|
||||||
transmit_bytes(abtHalt, 4);
|
|
||||||
transmit_bits(abtUnlock1, 7);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transmit_bytes(abtUnlock2, 1)) {
|
|
||||||
printf("Card unlocked\n");
|
|
||||||
} else {
|
|
||||||
printf("Warning: Unlock command [2/2]: failed / not acknowledged.\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
transmit_bytes(abtUnlock2, 1);
|
||||||
transmit_bytes(abtWrite, 4);
|
transmit_bytes(abtWrite, 4);
|
||||||
transmit_bytes(abtData, 18);
|
transmit_bytes(abtData, 18);
|
||||||
if (format) {
|
if (format) {
|
||||||
@ -393,7 +353,8 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_SUCCESS);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,15 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2011 Romain Tartiere
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2010, 2011 Romuald Conty
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
* Copyright (C) 2020 Adam Laurie
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -45,7 +38,6 @@
|
|||||||
#endif // HAVE_CONFIG_H
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <inttypes.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -60,17 +52,14 @@
|
|||||||
#define MAX_DEVICE_COUNT 16
|
#define MAX_DEVICE_COUNT 16
|
||||||
|
|
||||||
static nfc_device *pnd = NULL;
|
static nfc_device *pnd = NULL;
|
||||||
static nfc_context *context;
|
|
||||||
|
|
||||||
static void stop_polling(int sig)
|
static void stop_polling(int sig)
|
||||||
{
|
{
|
||||||
(void) sig;
|
(void) sig;
|
||||||
if (pnd != NULL)
|
if (pnd)
|
||||||
nfc_abort_command(pnd);
|
nfc_abort_command(pnd);
|
||||||
else {
|
else
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -102,42 +91,35 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
const uint8_t uiPollNr = 20;
|
const uint8_t uiPollNr = 20;
|
||||||
const uint8_t uiPeriod = 2;
|
const uint8_t uiPeriod = 2;
|
||||||
const nfc_modulation nmModulations[6] = {
|
const nfc_modulation nmModulations[5] = {
|
||||||
{ .nmt = NMT_ISO14443A, .nbr = NBR_106 },
|
{ .nmt = NMT_ISO14443A, .nbr = NBR_106 },
|
||||||
{ .nmt = NMT_ISO14443B, .nbr = NBR_106 },
|
{ .nmt = NMT_ISO14443B, .nbr = NBR_106 },
|
||||||
{ .nmt = NMT_FELICA, .nbr = NBR_212 },
|
{ .nmt = NMT_FELICA, .nbr = NBR_212 },
|
||||||
{ .nmt = NMT_FELICA, .nbr = NBR_424 },
|
{ .nmt = NMT_FELICA, .nbr = NBR_424 },
|
||||||
{ .nmt = NMT_JEWEL, .nbr = NBR_106 },
|
{ .nmt = NMT_JEWEL, .nbr = NBR_106 },
|
||||||
{ .nmt = NMT_ISO14443BICLASS, .nbr = NBR_106 },
|
|
||||||
};
|
};
|
||||||
const size_t szModulations = 6;
|
const size_t szModulations = 5;
|
||||||
|
|
||||||
nfc_target nt;
|
nfc_target nt;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
pnd = nfc_open(context, NULL);
|
pnd = nfc_open(context, NULL);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
ERR("%s", "Unable to open NFC device.");
|
ERR("%s", "Unable to open NFC device.");
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nfc_initiator_init(pnd) < 0) {
|
if (nfc_initiator_init(pnd) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_init");
|
nfc_perror(pnd, "nfc_initiator_init");
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
|
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
|
||||||
printf("NFC device will poll during %ld ms (%u pollings of %lu ms for %" PRIdPTR " modulations)\n", (unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (unsigned long) uiPeriod * 150, szModulations);
|
printf("NFC device will poll during %ld ms (%u pollings of %lu ms for %zd modulations)\n", (unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (unsigned long) uiPeriod * 150, szModulations);
|
||||||
if ((res = nfc_initiator_poll_target(pnd, nmModulations, szModulations, uiPollNr, uiPeriod, &nt)) < 0) {
|
if ((res = nfc_initiator_poll_target(pnd, nmModulations, szModulations, uiPollNr, uiPeriod, &nt)) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_poll_target");
|
nfc_perror(pnd, "nfc_initiator_poll_target");
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
@ -146,16 +128,10 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (res > 0) {
|
if (res > 0) {
|
||||||
print_nfc_target(&nt, verbose);
|
print_nfc_target(nt, verbose);
|
||||||
printf("Waiting for card removing...");
|
|
||||||
fflush(stdout);
|
|
||||||
while (0 == nfc_initiator_target_is_present(pnd, NULL)) {}
|
|
||||||
nfc_perror(pnd, "nfc_initiator_target_is_present");
|
|
||||||
printf("done.\n");
|
|
||||||
} else {
|
} else {
|
||||||
printf("No target found.\n");
|
printf("No target found.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|||||||
@ -22,7 +22,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2009 Roel Verdult
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2010 Romuald Conty
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -43,7 +37,6 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -96,13 +89,13 @@ main(int argc, char *argv[])
|
|||||||
for (arg = 1; arg < argc; arg++) {
|
for (arg = 1; arg < argc; arg++) {
|
||||||
if (0 == strcmp(argv[arg], "-h")) {
|
if (0 == strcmp(argv[arg], "-h")) {
|
||||||
print_usage(argv);
|
print_usage(argv);
|
||||||
exit(EXIT_SUCCESS);
|
return EXIT_SUCCESS;
|
||||||
} else if (0 == strcmp(argv[arg], "-q")) {
|
} else if (0 == strcmp(argv[arg], "-q")) {
|
||||||
quiet_output = true;
|
quiet_output = true;
|
||||||
} else {
|
} else {
|
||||||
ERR("%s is not supported option.", argv[arg]);
|
ERR("%s is not supported option.", argv[arg]);
|
||||||
print_usage(argv);
|
print_usage(argv);
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,26 +110,20 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
nfc_context *context;
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
nfc_connstring connstrings[MAX_DEVICE_COUNT];
|
||||||
// List available devices
|
// List available devices
|
||||||
size_t szFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
|
size_t szFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
|
||||||
|
|
||||||
if (szFound < 2) {
|
if (szFound < 2) {
|
||||||
ERR("%" PRIdPTR " device found but two opened devices are needed to relay NFC.", szFound);
|
ERR("%zd device found but two opened devices are needed to relay NFC.", szFound);
|
||||||
nfc_exit(context);
|
return EXIT_FAILURE;
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to open the NFC emulator device
|
// Try to open the NFC emulator device
|
||||||
pndTag = nfc_open(context, connstrings[0]);
|
pndTag = nfc_open(context, connstrings[0]);
|
||||||
if (pndTag == NULL) {
|
if (pndTag == NULL) {
|
||||||
ERR("Error opening NFC emulator device");
|
printf("Error opening NFC emulator device\n");
|
||||||
nfc_exit(context);
|
return EXIT_FAILURE;
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Hint: tag <---> initiator (relay) <---> target (relay) <---> original reader\n\n");
|
printf("Hint: tag <---> initiator (relay) <---> target (relay) <---> original reader\n\n");
|
||||||
@ -166,44 +153,30 @@ main(int argc, char *argv[])
|
|||||||
ERR("%s", "Initialization of NFC emulator failed");
|
ERR("%s", "Initialization of NFC emulator failed");
|
||||||
nfc_close(pndTag);
|
nfc_close(pndTag);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
printf("%s", "Configuring emulator settings...");
|
printf("%s", "Configuring emulator settings...");
|
||||||
if ((nfc_device_set_property_bool(pndTag, NP_HANDLE_CRC, false) < 0) ||
|
if ((nfc_device_set_property_bool(pndTag, NP_HANDLE_CRC, false) < 0) ||
|
||||||
(nfc_device_set_property_bool(pndTag, NP_HANDLE_PARITY, false) < 0) || (nfc_device_set_property_bool(pndTag, NP_ACCEPT_INVALID_FRAMES, true)) < 0) {
|
(nfc_device_set_property_bool(pndTag, NP_HANDLE_PARITY, false) < 0) || (nfc_device_set_property_bool(pndTag, NP_ACCEPT_INVALID_FRAMES, true)) < 0) {
|
||||||
nfc_perror(pndTag, "nfc_device_set_property_bool");
|
nfc_perror(pndTag, "nfc_device_set_property_bool");
|
||||||
nfc_close(pndTag);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
printf("%s", "Done, emulated tag is initialized");
|
printf("%s", "Done, emulated tag is initialized");
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pndReader = nfc_open(context, connstrings[1]);
|
pndReader = nfc_open(context, connstrings[1]);
|
||||||
if (pndReader == NULL) {
|
|
||||||
printf("Error opening NFC reader device\n");
|
|
||||||
nfc_close(pndTag);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("NFC reader device: %s opened", nfc_device_get_name(pndReader));
|
printf("NFC reader device: %s opened", nfc_device_get_name(pndReader));
|
||||||
printf("%s", "Configuring NFC reader settings...");
|
printf("%s", "Configuring NFC reader settings...");
|
||||||
|
|
||||||
if (nfc_initiator_init(pndReader) < 0) {
|
if (nfc_initiator_init(pndReader) < 0) {
|
||||||
nfc_perror(pndReader, "nfc_initiator_init");
|
nfc_perror(pndReader, "nfc_initiator_init");
|
||||||
nfc_close(pndTag);
|
|
||||||
nfc_close(pndReader);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if ((nfc_device_set_property_bool(pndReader, NP_HANDLE_CRC, false) < 0) ||
|
if ((nfc_device_set_property_bool(pndReader, NP_HANDLE_CRC, false) < 0) ||
|
||||||
(nfc_device_set_property_bool(pndReader, NP_HANDLE_PARITY, false) < 0) ||
|
(nfc_device_set_property_bool(pndReader, NP_HANDLE_PARITY, false) < 0) ||
|
||||||
(nfc_device_set_property_bool(pndReader, NP_ACCEPT_INVALID_FRAMES, true)) < 0) {
|
(nfc_device_set_property_bool(pndReader, NP_ACCEPT_INVALID_FRAMES, true)) < 0) {
|
||||||
nfc_perror(pndReader, "nfc_device_set_property_bool");
|
nfc_perror(pndReader, "nfc_device_set_property_bool");
|
||||||
nfc_close(pndTag);
|
|
||||||
nfc_close(pndReader);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
printf("%s", "Done, relaying frames now!");
|
printf("%s", "Done, relaying frames now!");
|
||||||
@ -216,18 +189,12 @@ main(int argc, char *argv[])
|
|||||||
// Drop down field for a very short time (original tag will reboot)
|
// Drop down field for a very short time (original tag will reboot)
|
||||||
if (nfc_device_set_property_bool(pndReader, NP_ACTIVATE_FIELD, false) < 0) {
|
if (nfc_device_set_property_bool(pndReader, NP_ACTIVATE_FIELD, false) < 0) {
|
||||||
nfc_perror(pndReader, "nfc_device_set_property_bool");
|
nfc_perror(pndReader, "nfc_device_set_property_bool");
|
||||||
nfc_close(pndTag);
|
|
||||||
nfc_close(pndReader);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (!quiet_output)
|
if (!quiet_output)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if (nfc_device_set_property_bool(pndReader, NP_ACTIVATE_FIELD, true) < 0) {
|
if (nfc_device_set_property_bool(pndReader, NP_ACTIVATE_FIELD, true) < 0) {
|
||||||
nfc_perror(pndReader, "nfc_device_set_property_bool");
|
nfc_perror(pndReader, "nfc_device_set_property_bool");
|
||||||
nfc_close(pndTag);
|
|
||||||
nfc_close(pndReader);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,9 +209,6 @@ main(int argc, char *argv[])
|
|||||||
// Redirect the answer back to the reader
|
// Redirect the answer back to the reader
|
||||||
if (nfc_target_send_bits(pndTag, abtTagRx, szTagRxBits, abtTagRxPar) < 0) {
|
if (nfc_target_send_bits(pndTag, abtTagRx, szTagRxBits, abtTagRxPar) < 0) {
|
||||||
nfc_perror(pndTag, "nfc_target_send_bits");
|
nfc_perror(pndTag, "nfc_target_send_bits");
|
||||||
nfc_close(pndTag);
|
|
||||||
nfc_close(pndReader);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
// Print the tag frame to the screen
|
// Print the tag frame to the screen
|
||||||
|
|||||||
@ -1,600 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
|
||||||
*
|
|
||||||
* Libnfc historical contributors:
|
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* 1) Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* 2 )Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* Note that this license only applies on the examples, NFC library itself is under LGPL
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file nfc-st25tb.c
|
|
||||||
* @brief Tool to operate on ISO-14443-B ST25TB* and legacy SR* cards
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Benjamin DELPY `gentilkiwi`
|
|
||||||
* https://blog.gentilkiwi.com
|
|
||||||
* benjamin@gentilkiwi.com
|
|
||||||
* Licence : https://creativecommons.org/licenses/by/4.0/
|
|
||||||
* Rely on : libnfc - https://github.com/nfc-tools/libnfc
|
|
||||||
*
|
|
||||||
* $ gcc -Wall -lnfc -o nfc-st25tb nfc-st25tb.c
|
|
||||||
* $ ./nfc-st25tb -h
|
|
||||||
*
|
|
||||||
* Tested with
|
|
||||||
* - ST25TB512-AC - (BE/Brussels/STIB ; AliExpress ones)
|
|
||||||
* - ST25TB512-AT - (FR/Lille/Ilevia ; FR/Reims/Citura ; FR/Dijon/Divia ; FR/Strasbourg/CTS)
|
|
||||||
* - SRT512 - legacy - (FR/Bordeaux/TBM)
|
|
||||||
* - SRI512 - legacy - (anonymous vending machine)
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include "config.h"
|
|
||||||
#endif // HAVE_CONFIG_H
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <nfc/nfc.h>
|
|
||||||
|
|
||||||
#if defined(WIN32) /* mingw compiler */
|
|
||||||
#include <getopt.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ST25TB_SR_BLOCK_MAX_SIZE ((uint8_t) 4) // for static arrays
|
|
||||||
typedef void(*get_info_specific) (uint8_t * systemArea);
|
|
||||||
|
|
||||||
typedef struct _st_data {
|
|
||||||
uint8_t chipId;
|
|
||||||
bool bIsLegacy;
|
|
||||||
const char *szName;
|
|
||||||
const char *szDatasheetUrl;
|
|
||||||
uint8_t blockSize;
|
|
||||||
uint8_t nbNormalBlock;
|
|
||||||
uint8_t bnSystem;
|
|
||||||
get_info_specific pfnGetInfo;
|
|
||||||
} st_data;
|
|
||||||
|
|
||||||
bool get_block_at(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt);
|
|
||||||
bool set_block_at(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt);
|
|
||||||
bool set_block_at_confirmed(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt);
|
|
||||||
const st_data * get_info(const nfc_target *pnt, bool bPrintIt);
|
|
||||||
void display_system_info(nfc_device *pnd, const st_data * stdata);
|
|
||||||
void print_hex(const uint8_t *pbtData, const size_t szBytes);
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
nfc_context *context = NULL;
|
|
||||||
nfc_device *pnd = NULL;
|
|
||||||
nfc_target nt = {0};
|
|
||||||
nfc_modulation nm = {NMT_ISO14443B2SR, NBR_106};
|
|
||||||
const st_data * stcurrent;
|
|
||||||
int opt, res;
|
|
||||||
bool bIsBlock = false, bIsRead = false, bIsWrite = false, bIsBadCli = false;
|
|
||||||
uint8_t i, blockNumber = 0, data[ST25TB_SR_BLOCK_MAX_SIZE] = {0xff, 0xff, 0xff, 0xff}; // just in case...
|
|
||||||
size_t cbData = 0;
|
|
||||||
|
|
||||||
while(!bIsBadCli && ((opt = getopt(argc, argv, ":hib:rw:")) != -1))
|
|
||||||
{
|
|
||||||
switch(opt)
|
|
||||||
{
|
|
||||||
case 'i':
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'b':
|
|
||||||
if(optarg)
|
|
||||||
{
|
|
||||||
bIsBlock = true;
|
|
||||||
blockNumber = strtoul(optarg, NULL, 0);
|
|
||||||
}
|
|
||||||
else bIsBadCli = true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r':
|
|
||||||
bIsRead = true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w':
|
|
||||||
if(optarg)
|
|
||||||
{
|
|
||||||
cbData = strlen(optarg);
|
|
||||||
if((cbData == (2*2)) || ((cbData == (4*2))))
|
|
||||||
{
|
|
||||||
cbData >>= 1;
|
|
||||||
if(cbData == 2) // sr176
|
|
||||||
{
|
|
||||||
res = sscanf(optarg, "%02hhx%02hhx", data, data + 1);
|
|
||||||
}
|
|
||||||
else // all others
|
|
||||||
{
|
|
||||||
res = sscanf(optarg, "%02hhx%02hhx%02hhx%02hhx", data, data + 1, data + 2, data + 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(res == (int) cbData)
|
|
||||||
{
|
|
||||||
bIsWrite = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!bIsWrite)
|
|
||||||
{
|
|
||||||
bIsBadCli = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: // includes -h
|
|
||||||
bIsBadCli = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!bIsBadCli)
|
|
||||||
{
|
|
||||||
if(bIsBlock && (bIsRead || bIsWrite))
|
|
||||||
{
|
|
||||||
if(bIsRead && bIsWrite)
|
|
||||||
{
|
|
||||||
printf("|mode : read then write\n");
|
|
||||||
}
|
|
||||||
else if(bIsRead)
|
|
||||||
{
|
|
||||||
printf("|mode : read\n");
|
|
||||||
}
|
|
||||||
else if(bIsWrite)
|
|
||||||
{
|
|
||||||
printf("|mode : write\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("|blk num: 0x%02hhx\n", blockNumber);
|
|
||||||
if(bIsWrite)
|
|
||||||
{
|
|
||||||
printf("|data : ");
|
|
||||||
print_hex(data, cbData);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(!bIsRead && !bIsWrite && !bIsBlock)
|
|
||||||
{
|
|
||||||
printf("|mode : info\n");
|
|
||||||
}
|
|
||||||
else bIsBadCli = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!bIsBadCli)
|
|
||||||
{
|
|
||||||
nfc_init(&context);
|
|
||||||
if(context)
|
|
||||||
{
|
|
||||||
pnd = nfc_open(context, NULL);
|
|
||||||
if(pnd)
|
|
||||||
{
|
|
||||||
res = nfc_initiator_init(pnd);
|
|
||||||
if(res == NFC_SUCCESS)
|
|
||||||
{
|
|
||||||
printf("Reader : %s - via %s\n ...wait for card...\n", nfc_device_get_name(pnd), nfc_device_get_connstring(pnd));
|
|
||||||
|
|
||||||
if (nfc_initiator_select_passive_target(pnd, nm, NULL, 0, &nt) > 0)
|
|
||||||
{
|
|
||||||
stcurrent = get_info(&nt, true);
|
|
||||||
if(stcurrent)
|
|
||||||
{
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
if(bIsBlock && (bIsRead || bIsWrite))
|
|
||||||
{
|
|
||||||
if(bIsRead)
|
|
||||||
{
|
|
||||||
get_block_at(pnd, blockNumber, NULL, 0, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bIsWrite)
|
|
||||||
{
|
|
||||||
set_block_at_confirmed(pnd, blockNumber, data, cbData, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(!bIsRead && !bIsWrite && !bIsBlock)
|
|
||||||
{
|
|
||||||
for(i = 0; i < stcurrent->nbNormalBlock; i++)
|
|
||||||
{
|
|
||||||
get_block_at(pnd, i, NULL, 0, true);
|
|
||||||
}
|
|
||||||
display_system_info(pnd, stcurrent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else printf("ERROR - nfc_initiator_init: %i\n", res);
|
|
||||||
|
|
||||||
nfc_close(pnd);
|
|
||||||
}
|
|
||||||
else printf("ERROR - nfc_open\n");
|
|
||||||
|
|
||||||
nfc_exit(context);
|
|
||||||
}
|
|
||||||
else printf("ERROR - nfc_init\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(
|
|
||||||
"Usage:\n"
|
|
||||||
" %s [-i]\n"
|
|
||||||
" %s -b N -r\n"
|
|
||||||
" %s -b N [-r] -w ABCD[EF01]\n %s -h\n"
|
|
||||||
"Options:\n"
|
|
||||||
" -i (default) information mode - will try to dump the tag content and display informations\n"
|
|
||||||
" -b N specify block number to operate on (tag dependent), needed for read (-r) and write (-w) modes\n"
|
|
||||||
" -r read mode - will try to read block (specified with -b N parameter)\n"
|
|
||||||
" -w ABCD[EF01] write mode - will try to write specicied data (2 or 4 bytes depending on tag) to block (specified with -b N parameter)\n"
|
|
||||||
" -h this help\n"
|
|
||||||
"Examples:\n"
|
|
||||||
" %s -i\n"
|
|
||||||
" Display all tag informations\n"
|
|
||||||
" %s -b 0x0e -r\n"
|
|
||||||
" Read block 0x0e (14) of the tag\n"
|
|
||||||
" %s -b 0x0d -w 0123abcd\n"
|
|
||||||
" Write block 0x0d (13) of the tag with hexadecimal value '01 23 ab cd'\n"
|
|
||||||
" %s -b 0x0c -r -w 0123abcd\n"
|
|
||||||
" Read, then write block 0x0c (12) of the tag with hexadecimal value '01 23 ab cd'\n"
|
|
||||||
"Warnings:\n"
|
|
||||||
" Be careful with: system area, counters & otp, bytes order.\n"
|
|
||||||
, argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get_block_at(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
uint8_t tx[2] = {0x08, block}, rx[ST25TB_SR_BLOCK_MAX_SIZE]; // 4 is the maximum, SR176 (only 2) will fit
|
|
||||||
int res;
|
|
||||||
|
|
||||||
res = nfc_initiator_transceive_bytes(pnd, tx, sizeof(tx), rx, sizeof(rx), 0);
|
|
||||||
if((res == 2) || (res == 4))
|
|
||||||
{
|
|
||||||
if(data)
|
|
||||||
{
|
|
||||||
if(cbData == res)
|
|
||||||
{
|
|
||||||
memcpy(data, rx, res);
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
else printf("ERROR - We got %i bytes for a %hhu buffer size?\n", res, cbData);
|
|
||||||
}
|
|
||||||
else bRet = true;
|
|
||||||
|
|
||||||
if(bPrintIt)
|
|
||||||
{
|
|
||||||
printf("[0x%02hhx] ", block);
|
|
||||||
print_hex(rx, res);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(res > 0)
|
|
||||||
{
|
|
||||||
printf("ERROR - We got %i bytes?\n", res);
|
|
||||||
}
|
|
||||||
else printf("ERROR - nfc_initiator_transceive_bytes(get): %i\n", res);
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool set_block_at(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
uint8_t tx[2 + ST25TB_SR_BLOCK_MAX_SIZE] = {0x09, block}; // 4 is the maximum, SR176 (only 2) will fit
|
|
||||||
int res;
|
|
||||||
|
|
||||||
if(cbData <= ST25TB_SR_BLOCK_MAX_SIZE)
|
|
||||||
{
|
|
||||||
memcpy(tx + 2, data, cbData);
|
|
||||||
|
|
||||||
if(bPrintIt)
|
|
||||||
{
|
|
||||||
printf(">0x%02hhx> ", block);
|
|
||||||
print_hex(data, cbData);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
res = nfc_initiator_transceive_bytes(pnd, tx, 2 + cbData, NULL, 0, 0);
|
|
||||||
if(res == NFC_ERFTRANS) // ? :')
|
|
||||||
{
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
else printf("ERROR - nfc_initiator_transceive_bytes(set): %i\n", res);
|
|
||||||
}
|
|
||||||
else printf("ERROR - Wanted to write %hhu bytes, but maximum is %hhu\n", cbData, ST25TB_SR_BLOCK_MAX_SIZE);
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool set_block_at_confirmed(nfc_device *pnd, uint8_t block, uint8_t *data, uint8_t cbData, bool bPrintIt)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
uint8_t buffer[ST25TB_SR_BLOCK_MAX_SIZE]; // maximum size will be checked in set_block_at
|
|
||||||
|
|
||||||
if(set_block_at(pnd, block, data, cbData, bPrintIt))
|
|
||||||
{
|
|
||||||
if(get_block_at(pnd, block, buffer, cbData, bPrintIt))
|
|
||||||
{
|
|
||||||
if(memcmp(data, buffer, cbData) == 0)
|
|
||||||
{
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
else if(bPrintIt)
|
|
||||||
{
|
|
||||||
printf("WARNING - not same value readed after write\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_info_st25tb512(uint8_t * systemArea)
|
|
||||||
{
|
|
||||||
uint8_t b, i;
|
|
||||||
|
|
||||||
b = ((*(uint32_t *) systemArea) >> 15) & 1;
|
|
||||||
|
|
||||||
printf(" | ST reserved : ");
|
|
||||||
for(i = 0; i < 15; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n | b15 : %hhu - %sOTP (?)\n | OTP_Lock_Reg : ", b, b ? "not " : "");
|
|
||||||
for(i = 16; i < 32; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
for(i = 16; i < 32; i++)
|
|
||||||
{
|
|
||||||
if(!(((*(uint32_t *) systemArea) >> i) & 1))
|
|
||||||
{
|
|
||||||
printf(" block 0x%02hhx is write protected\n", ((uint8_t) (i - 16)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_info_st25tb2k_4k(uint8_t * systemArea)
|
|
||||||
{
|
|
||||||
uint8_t b, i;
|
|
||||||
|
|
||||||
b = ((*(uint32_t *) systemArea) >> 15) & 1;
|
|
||||||
|
|
||||||
printf(" | ST reserved : ");
|
|
||||||
for(i = 0; i < 15; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n | b15 : %hhu - %sOTP (?)\n | OTP_Lock_RegU: ", b, b ? "not " : "");
|
|
||||||
for(i = 16; i < 24; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n | OTP_Lock_Reg : ");
|
|
||||||
for(i = 24; i < 32; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
if(!(((*(uint32_t *) systemArea) >> 24) & 1))
|
|
||||||
{
|
|
||||||
printf(" blocks 0x07 and 0x08 are write protected\n");
|
|
||||||
}
|
|
||||||
for(i = 25; i < 32; i++)
|
|
||||||
{
|
|
||||||
if(!(((*(uint32_t *) systemArea) >> i) & 1))
|
|
||||||
{
|
|
||||||
printf(" block 0x%02hhx is write protected\n", ((uint8_t) (i - 16)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_info_sr176_legacy(uint8_t * systemArea)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
printf(" | Fixed Chip_ID: 0x%1x\n | ST reserved : ", systemArea[0] & 0x0f);
|
|
||||||
for(i = 4; i < 8; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint16_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n | OTP_Lock_Reg : ");
|
|
||||||
for(i = 8; i < 16; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint16_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
for(i = 8; i < 16; i++)
|
|
||||||
{
|
|
||||||
if(((*(uint16_t *) systemArea) >> i) & 1)
|
|
||||||
{
|
|
||||||
printf(" blocks 0x%02hhx and 0x%02hhx are write protected\n", (uint8_t) ((i - 8) * 2), (uint8_t) (((i - 8) * 2) + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_info_sri_srt_512_legacy(uint8_t * systemArea)
|
|
||||||
{
|
|
||||||
uint8_t b, i;
|
|
||||||
|
|
||||||
b = ((*(uint32_t *) systemArea) >> 15) & 1;
|
|
||||||
|
|
||||||
printf(" | Fixed Chip_ID: 0x%02hhx\n | ST reserved : ", systemArea[0]);
|
|
||||||
for(i = 8; i < 15; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n | b15 : %hhu - %sOTP (?)\n | OTP_Lock_Reg : ", b, b ? "not " : "");
|
|
||||||
for(i = 16; i < 32; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
for(i = 16; i < 32; i++)
|
|
||||||
{
|
|
||||||
if(!(((*(uint32_t *) systemArea) >> i) & 1))
|
|
||||||
{
|
|
||||||
printf(" block 0x%02hhx is write protected\n", (uint8_t) (i - 16));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_info_sri2k_4k_srix4k_srix512_legacy(uint8_t * systemArea)
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
printf(" | Fixed Chip_ID: 0x%02hhx\n | ST reserved : ", systemArea[0]);
|
|
||||||
for(i = 8; i < 24; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n | OTP_Lock_Reg : ");
|
|
||||||
for(i = 24; i < 32; i++)
|
|
||||||
{
|
|
||||||
printf("%hhu", (uint8_t) (((*(uint32_t *) systemArea) >> i) & 1));
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
if(!(((*(uint32_t *) systemArea) >> 24) & 1))
|
|
||||||
{
|
|
||||||
printf(" blocks 0x07 and 0x08 are write protected\n");
|
|
||||||
}
|
|
||||||
for(i = 25; i < 32; i++)
|
|
||||||
{
|
|
||||||
if(!(((*(uint32_t *) systemArea) >> i) & 1))
|
|
||||||
{
|
|
||||||
printf(" block 0x%02hhx is write protected\n", (uint8_t) (i - 16));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const st_data STRefs[] = {
|
|
||||||
{0x1b, false, "ST25TB512-AC", "https://www.st.com/resource/en/datasheet/st25tb512-ac.pdf", 4, 16, 255, get_info_st25tb512},
|
|
||||||
{0x33, false, "ST25TB512-AT", "https://www.st.com/resource/en/datasheet/st25tb512-at.pdf", 4, 16, 255, get_info_st25tb512},
|
|
||||||
{0x3f, false, "ST25TB02K", "https://www.st.com/resource/en/datasheet/st25tb02k.pdf", 4, 64, 255, get_info_st25tb2k_4k},
|
|
||||||
{0x1f, false, "ST25TB04K", "https://www.st.com/resource/en/datasheet/st25tb04k.pdf", 4, 128, 255, get_info_st25tb2k_4k},
|
|
||||||
};
|
|
||||||
const st_data STRefs_legacy[] = {
|
|
||||||
{ 0, true, "SRI4K(s)", NULL, 4, 128, 255, NULL},
|
|
||||||
{ 2, true, "SR176", "https://www.st.com/resource/en/datasheet/sr176.pdf", 2, 15, 15, get_info_sr176_legacy},
|
|
||||||
{ 3, true, "SRIX4K", NULL, 4, 128, 255, get_info_sri2k_4k_srix4k_srix512_legacy},
|
|
||||||
{ 4, true, "SRIX512", "https://www.st.com/resource/en/datasheet/srix512.pdf", 4, 16, 255, get_info_sri2k_4k_srix4k_srix512_legacy},
|
|
||||||
{ 6, true, "SRI512", "https://www.st.com/resource/en/datasheet/sri512.pdf", 4, 16, 255, get_info_sri_srt_512_legacy},
|
|
||||||
{ 7, true, "SRI4K", "https://www.st.com/resource/en/datasheet/sri4k.pdf", 4, 128, 255, get_info_sri2k_4k_srix4k_srix512_legacy},
|
|
||||||
{12, true, "SRT512", "https://www.st.com/resource/en/datasheet/srt512.pdf", 4, 16, 255, get_info_sri_srt_512_legacy},
|
|
||||||
{15, true, "SRI2K", "https://www.st.com/resource/en/datasheet/sri2k.pdf", 4, 64, 255, get_info_sri2k_4k_srix4k_srix512_legacy},
|
|
||||||
};
|
|
||||||
|
|
||||||
const st_data * get_info(const nfc_target *pnt, bool bPrintIt)
|
|
||||||
{
|
|
||||||
const st_data *currentData = NULL;
|
|
||||||
const uint8_t *p;
|
|
||||||
uint8_t chipId, i;
|
|
||||||
|
|
||||||
if(pnt->nm.nmt == NMT_ISO14443B2SR)
|
|
||||||
{
|
|
||||||
printf("Target : %s (%s)\nUID : ", str_nfc_modulation_type(pnt->nm.nmt), str_nfc_baud_rate(pnt->nm.nbr));
|
|
||||||
print_hex(pnt->nti.nsi.abtUID, sizeof(pnt->nti.nsi.abtUID));
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
p = pnt->nti.nsi.abtUID;
|
|
||||||
if(p[7] == 0xd0) // ST25TB* / SR*
|
|
||||||
{
|
|
||||||
chipId = p[5];
|
|
||||||
printf("Manuf : 0x%02hhx - %s\n", p[6], (p[6] == 0x02) ? "STMicroelectronics" : "other");
|
|
||||||
|
|
||||||
for(i = 0; i < (sizeof(STRefs) / sizeof(STRefs[0])); i++)
|
|
||||||
{
|
|
||||||
if(chipId == STRefs[i].chipId)
|
|
||||||
{
|
|
||||||
currentData = &STRefs[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!currentData)
|
|
||||||
{
|
|
||||||
chipId >>= 2;
|
|
||||||
for(i = 0; i < (sizeof(STRefs_legacy) / sizeof(STRefs_legacy[0])); i++)
|
|
||||||
{
|
|
||||||
if(chipId == STRefs_legacy[i].chipId)
|
|
||||||
{
|
|
||||||
currentData = &STRefs_legacy[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bPrintIt && currentData)
|
|
||||||
{
|
|
||||||
printf("ChipId : 0x%02hhx - %s%s\nSerial : 0x", currentData->chipId, currentData->szName, currentData->bIsLegacy ? " (legacy)" : "");
|
|
||||||
if(currentData->bIsLegacy)
|
|
||||||
{
|
|
||||||
printf("%1hhx", (uint8_t) (p[5] & 0x03));
|
|
||||||
}
|
|
||||||
printf("%02hhx%02hhx%02hhx%02hhx%02hhx\n|blk sz : %hhu bits\n|nb blks: %hhu\n|sys idx: %hhu\n", p[4], p[3], p[2], p[1], p[0], (uint8_t) (currentData->blockSize * 8), currentData->nbNormalBlock, currentData->bnSystem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else printf("WARNI - Last byte of UID isn\'t 0xd0, but 0x%02hhx (not ST25TB / SR series?)\n", p[7]);
|
|
||||||
}
|
|
||||||
else printf("ERROR - not a NMT_ISO14443B2SR ?\n");
|
|
||||||
|
|
||||||
return currentData;
|
|
||||||
}
|
|
||||||
|
|
||||||
void display_system_info(nfc_device *pnd, const st_data * stdata)
|
|
||||||
{
|
|
||||||
uint8_t systemArea[ST25TB_SR_BLOCK_MAX_SIZE];
|
|
||||||
|
|
||||||
if(get_block_at(pnd, stdata->bnSystem, systemArea, stdata->blockSize, true))
|
|
||||||
{
|
|
||||||
if(stdata->pfnGetInfo)
|
|
||||||
{
|
|
||||||
stdata->pfnGetInfo(systemArea);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_hex(const uint8_t *pbtData, const size_t szBytes)
|
|
||||||
{
|
|
||||||
size_t szPos;
|
|
||||||
for (szPos = 0; szPos < szBytes; szPos++)
|
|
||||||
{
|
|
||||||
printf("%02hhx ", pbtData[szPos]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,14 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2010 Romuald Conty
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -58,9 +51,10 @@ int
|
|||||||
main(int argc, const char *argv[])
|
main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
nfc_device *pnd = NULL;
|
nfc_device *pnd;
|
||||||
const char *acLibnfcVersion;
|
const char *acLibnfcVersion;
|
||||||
bool result;
|
bool result;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
uint8_t abtRx[PN53x_EXTENDED_FRAME__DATA_MAX_LEN];
|
||||||
size_t szRx = sizeof(abtRx);
|
size_t szRx = sizeof(abtRx);
|
||||||
@ -69,16 +63,11 @@ main(int argc, const char *argv[])
|
|||||||
const uint8_t pncmd_diagnose_ram_test[] = { Diagnose, 0x02 };
|
const uint8_t pncmd_diagnose_ram_test[] = { Diagnose, 0x02 };
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
printf("Usage: %s", argv[0]);
|
errx(1, "usage: %s", argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_context *context;
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display libnfc version
|
// Display libnfc version
|
||||||
acLibnfcVersion = nfc_version();
|
acLibnfcVersion = nfc_version();
|
||||||
@ -92,13 +81,11 @@ main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < szFound; i++) {
|
for (i = 0; i < szFound; i++) {
|
||||||
int res = 0;
|
|
||||||
pnd = nfc_open(context, connstrings[i]);
|
pnd = nfc_open(context, connstrings[i]);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
ERR("%s", "Unable to open NFC device.");
|
ERR("%s", "Unable to open NFC device.");
|
||||||
nfc_exit(context);
|
return EXIT_FAILURE;
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("NFC device [%s] opened.\n", nfc_device_get_name(pnd));
|
printf("NFC device [%s] opened.\n", nfc_device_get_name(pnd));
|
||||||
@ -132,7 +119,4 @@ main(int argc, const char *argv[])
|
|||||||
nfc_perror(pnd, "pn53x_transceive: cannot diagnose RAM");
|
nfc_perror(pnd, "pn53x_transceive: cannot diagnose RAM");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,15 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2010 Emanuele Bertoldi
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
* Copyright (C) 2010 Emanuele Bertoldi
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -83,12 +75,10 @@ main(int argc, const char *argv[])
|
|||||||
(void) argc;
|
(void) argc;
|
||||||
(void) argv;
|
(void) argv;
|
||||||
|
|
||||||
|
int ret = EXIT_FAILURE;
|
||||||
|
|
||||||
nfc_context *context;
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display libnfc version
|
// Display libnfc version
|
||||||
const char *acLibnfcVersion = nfc_version();
|
const char *acLibnfcVersion = nfc_version();
|
||||||
@ -100,8 +90,7 @@ main(int argc, const char *argv[])
|
|||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
ERR("%s", "Unable to open NFC device.");
|
ERR("%s", "Unable to open NFC device.");
|
||||||
nfc_exit(context);
|
return EXIT_FAILURE;
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
|
printf("NFC device: %s opened\n", nfc_device_get_name(pnd));
|
||||||
@ -114,13 +103,11 @@ main(int argc, const char *argv[])
|
|||||||
printf(">> ");
|
printf(">> ");
|
||||||
|
|
||||||
// Take user's choice
|
// Take user's choice
|
||||||
int input = getchar();
|
char input = getchar();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if ((input < '1') || (input > '3')) {
|
if ((input < '1') || (input > '3')) {
|
||||||
ERR("%s", "Invalid selection.");
|
ERR("%s", "Invalid selection.");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -138,9 +125,7 @@ main(int argc, const char *argv[])
|
|||||||
// FIXME Its a private pn53x function
|
// FIXME Its a private pn53x function
|
||||||
if (pn532_SAMConfiguration(pnd, mode, 0) < 0) {
|
if (pn532_SAMConfiguration(pnd, mode, 0) < 0) {
|
||||||
nfc_perror(pnd, "pn53x_SAMConfiguration");
|
nfc_perror(pnd, "pn53x_SAMConfiguration");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
printf("Now the SAM is readable for 1 minute from an external reader.\n");
|
printf("Now the SAM is readable for 1 minute from an external reader.\n");
|
||||||
wait_one_minute();
|
wait_one_minute();
|
||||||
@ -151,17 +136,13 @@ main(int argc, const char *argv[])
|
|||||||
// Set opened NFC device to initiator mode
|
// Set opened NFC device to initiator mode
|
||||||
if (nfc_initiator_init_secure_element(pnd) < 0) {
|
if (nfc_initiator_init_secure_element(pnd) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_init_secure_element");
|
nfc_perror(pnd, "nfc_initiator_init_secure_element");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let the reader only try once to find a tag
|
// Let the reader only try once to find a tag
|
||||||
if (nfc_device_set_property_bool(pnd, NP_INFINITE_SELECT, false) < 0) {
|
if (nfc_device_set_property_bool(pnd, NP_INFINITE_SELECT, false) < 0) {
|
||||||
nfc_perror(pnd, "nfc_device_set_property_bool");
|
nfc_perror(pnd, "nfc_device_set_property_bool");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
// Read the SAM's info
|
// Read the SAM's info
|
||||||
const nfc_modulation nmSAM = {
|
const nfc_modulation nmSAM = {
|
||||||
@ -173,22 +154,16 @@ main(int argc, const char *argv[])
|
|||||||
int res;
|
int res;
|
||||||
if ((res = nfc_initiator_select_passive_target(pnd, nmSAM, NULL, 0, &nt)) < 0) {
|
if ((res = nfc_initiator_select_passive_target(pnd, nmSAM, NULL, 0, &nt)) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_select_passive_target");
|
nfc_perror(pnd, "nfc_initiator_select_passive_target");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
} else if (res == 0) {
|
} else if (res == 0) {
|
||||||
ERR("No SAM found.");
|
ERR("No SAM found.");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
} else if (res == 1) {
|
} else if (res == 1) {
|
||||||
printf("The following ISO14443A tag (SAM) was found:\n");
|
printf("The following ISO14443A tag (SAM) was found:\n");
|
||||||
print_nfc_target(&nt, true);
|
print_nfc_target(nt, true);
|
||||||
} else {
|
} else {
|
||||||
ERR("%s", "More than one ISO14442 tag found as SAM.");
|
ERR("%s", "More than one ISO14442 tag found as SAM.");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -197,9 +172,7 @@ main(int argc, const char *argv[])
|
|||||||
// FIXME Its a private pn53x function
|
// FIXME Its a private pn53x function
|
||||||
if (pn532_SAMConfiguration(pnd, mode, 0) < 0) {
|
if (pn532_SAMConfiguration(pnd, mode, 0) < 0) {
|
||||||
nfc_perror(pnd, "pn53x_SAMConfiguration");
|
nfc_perror(pnd, "pn53x_SAMConfiguration");
|
||||||
nfc_close(pnd);
|
goto error;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
uint8_t abtRx[MAX_FRAME_LEN];
|
uint8_t abtRx[MAX_FRAME_LEN];
|
||||||
|
|
||||||
@ -222,9 +195,7 @@ main(int argc, const char *argv[])
|
|||||||
printf("Please note that NFC device (configured as target) stay in target mode until it receive RATS, ATR_REQ or proprietary command.\n");
|
printf("Please note that NFC device (configured as target) stay in target mode until it receive RATS, ATR_REQ or proprietary command.\n");
|
||||||
if (nfc_target_init(pnd, &nt, abtRx, sizeof(abtRx), 0) < 0) {
|
if (nfc_target_init(pnd, &nt, abtRx, sizeof(abtRx), 0) < 0) {
|
||||||
nfc_perror(pnd, "nfc_target_init");
|
nfc_perror(pnd, "nfc_target_init");
|
||||||
nfc_close(pnd);
|
return EXIT_FAILURE;
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
// wait_one_minute ();
|
// wait_one_minute ();
|
||||||
}
|
}
|
||||||
@ -233,12 +204,15 @@ main(int argc, const char *argv[])
|
|||||||
// This should not happend... nothing to do.
|
// This should not happend... nothing to do.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
error:
|
||||||
// Disconnect from the SAM
|
// Disconnect from the SAM
|
||||||
pn532_SAMConfiguration(pnd, PSM_NORMAL, -1);
|
pn532_SAMConfiguration(pnd, PSM_NORMAL, -1);
|
||||||
|
|
||||||
// Close NFC device
|
// Close NFC device
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
#DEBUG='//;'
|
|
||||||
|
|
||||||
cat << EOF | \
|
cat << EOF | \
|
||||||
pn53x-tamashell |\
|
pn53x-tamashell |\
|
||||||
awk $DEBUG'\
|
awk '\
|
||||||
/^> #.*:/{
|
/^> #.*:/{
|
||||||
sub(/^> #/,"")
|
sub(/^> #/,"")
|
||||||
n=$0
|
n=$0
|
||||||
@ -23,33 +21,27 @@ cat << EOF | \
|
|||||||
# Select one typeB target
|
# Select one typeB target
|
||||||
4A010300
|
4A010300
|
||||||
|
|
||||||
# SELECT AID "1TIC.ICA"
|
|
||||||
4001 00a4 0400 08 315449432e494341
|
|
||||||
|
|
||||||
# Select ICC file
|
# Select ICC file
|
||||||
4001 00a4 0000 02 3f00
|
4001 80a4 0800 04 3f00 0002
|
||||||
4001 00a4 0000 02 0002
|
|
||||||
#ICC:
|
#ICC:
|
||||||
4001 00b2 0104 1d
|
4001 80b2 0104 1d
|
||||||
|
|
||||||
# Select Holder file
|
# Select Holder file
|
||||||
4001 00a4 0000 02 3f1c
|
4001 80a4 0800 04 3f00 3f1c
|
||||||
#Holder1:
|
#Holder1:
|
||||||
4001 00b2 0104 1d
|
4001 80b2 0104 1d
|
||||||
#Holder2:
|
#Holder2:
|
||||||
4001 00b2 0204 1d
|
4001 80b2 0204 1d
|
||||||
|
|
||||||
# Select EnvHol file
|
# Select EnvHol file
|
||||||
4001 00a4 0000 00
|
4001 00a4 0800 04 2000 2001
|
||||||
4001 00a4 0000 02 2000
|
|
||||||
4001 00a4 0000 02 2001
|
|
||||||
#EnvHol1:
|
#EnvHol1:
|
||||||
4001 00b2 0104 1d
|
4001 00b2 0104 1d
|
||||||
#EnvHol2:
|
#EnvHol2:
|
||||||
4001 00b2 0204 1d
|
4001 00b2 0204 1d
|
||||||
|
|
||||||
# Select EvLog file
|
# Select EvLog file
|
||||||
4001 00a4 0000 02 2010
|
4001 00a4 0800 04 2000 2010
|
||||||
#EvLog1:
|
#EvLog1:
|
||||||
4001 00b2 0104 1d
|
4001 00b2 0104 1d
|
||||||
#EvLog2:
|
#EvLog2:
|
||||||
@ -58,12 +50,12 @@ cat << EOF | \
|
|||||||
4001 00b2 0304 1d
|
4001 00b2 0304 1d
|
||||||
|
|
||||||
# Select ConList file
|
# Select ConList file
|
||||||
4001 00a4 0000 02 2050
|
4001 00a4 0800 04 2000 2050
|
||||||
#ConList:
|
#ConList:
|
||||||
4001 00b2 0104 1d
|
4001 00b2 0104 1d
|
||||||
|
|
||||||
# Select Contra file
|
# Select Contra file
|
||||||
4001 00a4 0000 02 2020
|
4001 00a4 0800 04 2000 2020
|
||||||
#Contra1:
|
#Contra1:
|
||||||
4001 00b2 0104 1d
|
4001 00b2 0104 1d
|
||||||
#Contra2:
|
#Contra2:
|
||||||
@ -90,19 +82,17 @@ cat << EOF | \
|
|||||||
4001 00b2 0c04 1d
|
4001 00b2 0c04 1d
|
||||||
|
|
||||||
# Select Counter file
|
# Select Counter file
|
||||||
4001 00a4 0000 02 2069
|
4001 00a4 0800 04 2000 2069
|
||||||
#Counter:
|
#Counter:
|
||||||
4001 00b2 0104 1d
|
4001 00b2 0104 1d
|
||||||
|
|
||||||
# Select LoadLog file
|
# Select LoadLog file
|
||||||
4001 00a4 0000 00
|
4001 00a4 0800 04 1000 1014
|
||||||
4001 00a4 0000 02 1000
|
|
||||||
4001 00a4 0000 02 1014
|
|
||||||
#LoadLog:
|
#LoadLog:
|
||||||
4001 00b2 0104 1d
|
4001 00b2 0104 1d
|
||||||
|
|
||||||
# Select Purcha file
|
# Select Purcha file
|
||||||
4001 00a4 0000 02 1015
|
4001 00a4 08 0004 1000 1015
|
||||||
#Purcha1:
|
#Purcha1:
|
||||||
4001 00b2 0104 1d
|
4001 00b2 0104 1d
|
||||||
#Purcha2:
|
#Purcha2:
|
||||||
@ -111,9 +101,7 @@ cat << EOF | \
|
|||||||
4001 00b2 0304 1d
|
4001 00b2 0304 1d
|
||||||
|
|
||||||
# Select SpecEv file
|
# Select SpecEv file
|
||||||
4001 00a4 0000 00
|
4001 00a4 08 0004 2000 2040
|
||||||
4001 00a4 0000 02 2000
|
|
||||||
4001 00a4 0000 02 2040
|
|
||||||
#SpecEv1:
|
#SpecEv1:
|
||||||
4001 00b2 0104 1d
|
4001 00b2 0104 1d
|
||||||
#SpecEv2:
|
#SpecEv2:
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
ID=$(cat << EOF | \
|
ID=$(cat << EOF | \
|
||||||
pn53x-tamashell |\
|
pn53x-tamashell |\
|
||||||
grep -A1 "^Tx: 42 01 0b 3f 80" |\
|
grep -A1 "^Tx: 42 01 0b 3f 80" |\
|
||||||
sed -e '1d' -e "s/^Rx: 00 .. .. \(.. .. .. ..\).*/\1/" -e 's/ //g'
|
grep -o -P "(?<=Rx: 00 .. .. ).. .. .. .."|sed 's/ //g'
|
||||||
# Timeouts
|
# Timeouts
|
||||||
3205000002
|
3205000002
|
||||||
# ListTarget ModeB
|
# ListTarget ModeB
|
||||||
@ -13,11 +13,6 @@ ID=$(cat << EOF | \
|
|||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ -z "$ID" ]; then
|
|
||||||
echo "Error: I was not abble to read Navigo ID" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat << EOF | \
|
cat << EOF | \
|
||||||
pn53x-tamashell |\
|
pn53x-tamashell |\
|
||||||
awk '\
|
awk '\
|
||||||
|
|||||||
@ -68,7 +68,7 @@ Please report any bugs on the
|
|||||||
.B libnfc
|
.B libnfc
|
||||||
issue tracker at:
|
issue tracker at:
|
||||||
.br
|
.br
|
||||||
.BR https://github.com/nfc-tools/libnfc/issues
|
.BR http://code.google.com/p/libnfc/issues
|
||||||
.SH LICENCE
|
.SH LICENCE
|
||||||
.B libnfc
|
.B libnfc
|
||||||
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
is licensed under the GNU Lesser General Public License (LGPL), version 3.
|
||||||
|
|||||||
@ -1,14 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library examples
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2010 Romuald Conty
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@ -55,16 +48,15 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# include <time.h>
|
// Needed by sleep() under Unix
|
||||||
# define msleep(x) do { \
|
# include <unistd.h>
|
||||||
struct timespec xsleep; \
|
# define sleep usleep
|
||||||
xsleep.tv_sec = x / 1000; \
|
# define SUSP_TIME 1000 // usecs.
|
||||||
xsleep.tv_nsec = (x - xsleep.tv_sec * 1000) * 1000 * 1000; \
|
|
||||||
nanosleep(&xsleep, NULL); \
|
|
||||||
} while (0)
|
|
||||||
#else
|
#else
|
||||||
|
// Needed by Sleep() under Windows
|
||||||
# include <winbase.h>
|
# include <winbase.h>
|
||||||
# define msleep Sleep
|
# define sleep Sleep
|
||||||
|
# define SUSP_TIME 1 // msecs.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -87,44 +79,31 @@ int main(int argc, const char *argv[])
|
|||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
if ((input = fopen(argv[1], "r")) == NULL) {
|
if ((input = fopen(argv[1], "r")) == NULL) {
|
||||||
ERR("%s", "Cannot open file.");
|
ERR("%s", "Cannot open file.");
|
||||||
exit(EXIT_FAILURE);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nfc_context *context;
|
nfc_context *context;
|
||||||
nfc_init(&context);
|
nfc_init(&context);
|
||||||
if (context == NULL) {
|
|
||||||
ERR("Unable to init libnfc (malloc)");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to open the NFC reader
|
// Try to open the NFC reader
|
||||||
pnd = nfc_open(context, NULL);
|
pnd = nfc_open(context, NULL);
|
||||||
|
|
||||||
if (pnd == NULL) {
|
if (pnd == NULL) {
|
||||||
ERR("%s", "Unable to open NFC device.");
|
ERR("%s", "Unable to open NFC device.");
|
||||||
if (input != NULL) {
|
return EXIT_FAILURE;
|
||||||
fclose(input);
|
|
||||||
}
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
|
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
|
||||||
if (nfc_initiator_init(pnd) < 0) {
|
if (nfc_initiator_init(pnd) < 0) {
|
||||||
nfc_perror(pnd, "nfc_initiator_init");
|
nfc_perror(pnd, "nfc_initiator_init");
|
||||||
if (input != NULL) {
|
|
||||||
fclose(input);
|
|
||||||
}
|
|
||||||
nfc_close(pnd);
|
|
||||||
nfc_exit(context);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *cmd;
|
||||||
const char *prompt = "> ";
|
const char *prompt = "> ";
|
||||||
while (1) {
|
while (1) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
char *cmd;
|
|
||||||
#if defined(HAVE_READLINE)
|
#if defined(HAVE_READLINE)
|
||||||
if (input == NULL) { // means we use stdin
|
if (input == NULL) { // means we use stdin
|
||||||
cmd = readline(prompt);
|
cmd = readline(prompt);
|
||||||
@ -136,7 +115,7 @@ int main(int argc, const char *argv[])
|
|||||||
add_history(cmd);
|
add_history(cmd);
|
||||||
} else {
|
} else {
|
||||||
#endif //HAVE_READLINE
|
#endif //HAVE_READLINE
|
||||||
size_t n = 512;
|
size_t n = 255;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
cmd = malloc(n);
|
cmd = malloc(n);
|
||||||
printf("%s", prompt);
|
printf("%s", prompt);
|
||||||
@ -162,21 +141,21 @@ int main(int argc, const char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (cmd[0] == 'p') {
|
if (cmd[0] == 'p') {
|
||||||
int ms = 0;
|
int s = 0;
|
||||||
offset++;
|
offset++;
|
||||||
while (isspace(cmd[offset])) {
|
while (isspace(cmd[offset])) {
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
sscanf(cmd + offset, "%10d", &ms);
|
sscanf(cmd + offset, "%d", &s);
|
||||||
printf("Pause for %i msecs\n", ms);
|
printf("Pause for %i msecs\n", s);
|
||||||
if (ms > 0) {
|
if (s > 0) {
|
||||||
msleep(ms);
|
sleep(s * SUSP_TIME);
|
||||||
}
|
}
|
||||||
free(cmd);
|
free(cmd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
szTx = 0;
|
szTx = 0;
|
||||||
for (int i = 0; i < MAX_FRAME_LEN; i++) {
|
for (int i = 0; i < MAX_FRAME_LEN - 10; i++) {
|
||||||
int size;
|
int size;
|
||||||
unsigned int byte;
|
unsigned int byte;
|
||||||
while (isspace(cmd[offset])) {
|
while (isspace(cmd[offset])) {
|
||||||
@ -220,5 +199,5 @@ int main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
nfc_close(pnd);
|
nfc_close(pnd);
|
||||||
nfc_exit(context);
|
nfc_exit(context);
|
||||||
exit(EXIT_SUCCESS);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2011 Romain Tartière
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2011 Romuald Conty
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
@ -39,29 +33,29 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
struct nfc_emulator;
|
struct nfc_emulator;
|
||||||
struct nfc_emulation_state_machine;
|
struct nfc_emulation_state_machine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct nfc_emulator
|
* @struct nfc_emulator
|
||||||
* @brief NFC emulator structure
|
* @brief NFC emulator structure
|
||||||
*/
|
*/
|
||||||
struct nfc_emulator {
|
struct nfc_emulator {
|
||||||
nfc_target *target;
|
nfc_target *target;
|
||||||
struct nfc_emulation_state_machine *state_machine;
|
struct nfc_emulation_state_machine *state_machine;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct nfc_emulation_state_machine
|
* @struct nfc_emulation_state_machine
|
||||||
* @brief NFC emulation state machine structure
|
* @brief NFC emulation state machine structure
|
||||||
*/
|
*/
|
||||||
struct nfc_emulation_state_machine {
|
struct nfc_emulation_state_machine {
|
||||||
int (*io)(struct nfc_emulator *emulator, const uint8_t *data_in, const size_t data_in_len, uint8_t *data_out, const size_t data_out_len);
|
int (*io)(struct nfc_emulator *emulator, const uint8_t *data_in, const size_t data_in_len, uint8_t *data_out, const size_t data_out_len);
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
NFC_EXPORT int nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator, const int timeout);
|
NFC_EXPORT int nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator, const int timeout);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,9 @@
|
|||||||
/*-
|
/**
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2009 Roel Verdult
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2010, 2011 Romain Tartière
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
* Copyright (C) 2010, 2011, 2012 Romuald Conty
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
* Copyright (C) 2020 Adam Laurie
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
@ -31,16 +25,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __NFC_TYPES_H__
|
#ifndef __NFC_TYPES_H__
|
||||||
#define __NFC_TYPES_H__
|
# define __NFC_TYPES_H__
|
||||||
|
|
||||||
#include <stddef.h>
|
# include <stddef.h>
|
||||||
#include <stdint.h>
|
# include <stdint.h>
|
||||||
#include <stdbool.h>
|
# include <stdbool.h>
|
||||||
#include <stdio.h>
|
# include <stdio.h>
|
||||||
|
|
||||||
#ifndef NFC_BUFSIZE_CONNSTRING
|
|
||||||
#define NFC_BUFSIZE_CONNSTRING 1024
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC context
|
* NFC context
|
||||||
@ -60,7 +50,7 @@ typedef struct nfc_driver nfc_driver;
|
|||||||
/**
|
/**
|
||||||
* Connection string
|
* Connection string
|
||||||
*/
|
*/
|
||||||
typedef char nfc_connstring[NFC_BUFSIZE_CONNSTRING];
|
typedef char nfc_connstring[1024];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properties
|
* Properties
|
||||||
@ -235,14 +225,6 @@ typedef struct {
|
|||||||
uint8_t abtAtr[33];
|
uint8_t abtAtr[33];
|
||||||
} nfc_iso14443bi_info;
|
} nfc_iso14443bi_info;
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct nfc_iso14443biclass_info
|
|
||||||
* @brief NFC ISO14443BiClass tag information
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
uint8_t abtUID[8];
|
|
||||||
} nfc_iso14443biclass_info;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct nfc_iso14443b2sr_info
|
* @struct nfc_iso14443b2sr_info
|
||||||
* @brief NFC ISO14443-2B ST SRx tag information
|
* @brief NFC ISO14443-2B ST SRx tag information
|
||||||
@ -270,15 +252,6 @@ typedef struct {
|
|||||||
uint8_t btId[4];
|
uint8_t btId[4];
|
||||||
} nfc_jewel_info;
|
} nfc_jewel_info;
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct nfc_barcode_info
|
|
||||||
* @brief Thinfilm NFC Barcode information
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
size_t szDataLen;
|
|
||||||
uint8_t abtData[32];
|
|
||||||
} nfc_barcode_info;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @union nfc_target_info
|
* @union nfc_target_info
|
||||||
* @brief Union between all kind of tags information structures.
|
* @brief Union between all kind of tags information structures.
|
||||||
@ -292,8 +265,6 @@ typedef union {
|
|||||||
nfc_iso14443b2ct_info nci;
|
nfc_iso14443b2ct_info nci;
|
||||||
nfc_jewel_info nji;
|
nfc_jewel_info nji;
|
||||||
nfc_dep_info ndi;
|
nfc_dep_info ndi;
|
||||||
nfc_barcode_info nti; // "t" for Thinfilm, "b" already used
|
|
||||||
nfc_iso14443biclass_info nhi; // hid iclass / picopass - nii already used
|
|
||||||
} nfc_target_info;
|
} nfc_target_info;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -321,9 +292,6 @@ typedef enum {
|
|||||||
NMT_ISO14443B2CT, // ISO14443-2B ASK CTx
|
NMT_ISO14443B2CT, // ISO14443-2B ASK CTx
|
||||||
NMT_FELICA,
|
NMT_FELICA,
|
||||||
NMT_DEP,
|
NMT_DEP,
|
||||||
NMT_BARCODE, // Thinfilm NFC Barcode
|
|
||||||
NMT_ISO14443BICLASS, // HID iClass 14443B mode
|
|
||||||
NMT_END_ENUM = NMT_ISO14443BICLASS, // dummy for sizing - always should alias last
|
|
||||||
} nfc_modulation_type;
|
} nfc_modulation_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
* Public platform independent Near Field Communication (NFC) library
|
||||||
*
|
*
|
||||||
* Libnfc historical contributors:
|
* Copyright (C) 2009 Roel Verdult
|
||||||
* Copyright (C) 2009 Roel Verdult
|
* Copyright (C) 2009, 2010, 2011, 2012 Romuald Conty
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tartière
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
@ -28,12 +22,14 @@
|
|||||||
* @file nfc.h
|
* @file nfc.h
|
||||||
* @brief libnfc interface
|
* @brief libnfc interface
|
||||||
*
|
*
|
||||||
* Provide all useful functions (API) to handle NFC devices.
|
* Provide all usefull functions (API) to handle NFC devices.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIBNFC_H_
|
#ifndef _LIBNFC_H_
|
||||||
# define _LIBNFC_H_
|
# define _LIBNFC_H_
|
||||||
|
|
||||||
|
# include <sys/time.h>
|
||||||
|
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# include <stdbool.h>
|
# include <stdbool.h>
|
||||||
|
|
||||||
@ -80,143 +76,140 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
# endif // __cplusplus
|
# endif // __cplusplus
|
||||||
|
|
||||||
/* Library initialization/deinitialization */
|
/* Library initialization/deinitialization */
|
||||||
NFC_EXPORT void nfc_init(nfc_context **context) ATTRIBUTE_NONNULL(1);
|
NFC_EXPORT void nfc_init(nfc_context **context) ATTRIBUTE_NONNULL(1);
|
||||||
NFC_EXPORT void nfc_exit(nfc_context *context) ATTRIBUTE_NONNULL(1);
|
NFC_EXPORT void nfc_exit(nfc_context *context) ATTRIBUTE_NONNULL(1);
|
||||||
NFC_EXPORT int nfc_register_driver(const nfc_driver *driver);
|
NFC_EXPORT int nfc_register_driver(const nfc_driver *driver);
|
||||||
|
|
||||||
/* NFC Device/Hardware manipulation */
|
/* NFC Device/Hardware manipulation */
|
||||||
NFC_EXPORT nfc_device *nfc_open(nfc_context *context, const nfc_connstring connstring) ATTRIBUTE_NONNULL(1);
|
NFC_EXPORT nfc_device *nfc_open(nfc_context *context, const nfc_connstring connstring) ATTRIBUTE_NONNULL(1);
|
||||||
NFC_EXPORT void nfc_close(nfc_device *pnd);
|
NFC_EXPORT void nfc_close(nfc_device *pnd);
|
||||||
NFC_EXPORT int nfc_abort_command(nfc_device *pnd);
|
NFC_EXPORT int nfc_abort_command(nfc_device *pnd);
|
||||||
NFC_EXPORT size_t nfc_list_devices(nfc_context *context, nfc_connstring connstrings[], size_t connstrings_len) ATTRIBUTE_NONNULL(1);
|
NFC_EXPORT size_t nfc_list_devices(nfc_context *context, nfc_connstring connstrings[], size_t connstrings_len) ATTRIBUTE_NONNULL(1);
|
||||||
NFC_EXPORT int nfc_idle(nfc_device *pnd);
|
NFC_EXPORT int nfc_idle(nfc_device *pnd);
|
||||||
|
|
||||||
/* NFC initiator: act as "reader" */
|
/* NFC initiator: act as "reader" */
|
||||||
NFC_EXPORT int nfc_initiator_init(nfc_device *pnd);
|
NFC_EXPORT int nfc_initiator_init(nfc_device *pnd);
|
||||||
NFC_EXPORT int nfc_initiator_init_secure_element(nfc_device *pnd);
|
NFC_EXPORT int nfc_initiator_init_secure_element(nfc_device *pnd);
|
||||||
NFC_EXPORT int nfc_initiator_select_passive_target(nfc_device *pnd, const nfc_modulation nm, const uint8_t *pbtInitData, const size_t szInitData, nfc_target *pnt);
|
NFC_EXPORT int nfc_initiator_select_passive_target(nfc_device *pnd, const nfc_modulation nm, const uint8_t *pbtInitData, const size_t szInitData, nfc_target *pnt);
|
||||||
NFC_EXPORT int nfc_initiator_list_passive_targets(nfc_device *pnd, const nfc_modulation nm, nfc_target ant[], const size_t szTargets);
|
NFC_EXPORT int nfc_initiator_list_passive_targets(nfc_device *pnd, const nfc_modulation nm, nfc_target ant[], const size_t szTargets);
|
||||||
NFC_EXPORT int nfc_initiator_poll_target(nfc_device *pnd, const nfc_modulation *pnmTargetTypes, const size_t szTargetTypes, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target *pnt);
|
NFC_EXPORT int nfc_initiator_poll_target(nfc_device *pnd, const nfc_modulation *pnmTargetTypes, const size_t szTargetTypes, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target *pnt);
|
||||||
NFC_EXPORT int nfc_initiator_select_dep_target(nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout);
|
NFC_EXPORT int nfc_initiator_select_dep_target(nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout);
|
||||||
NFC_EXPORT int nfc_initiator_poll_dep_target(nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout);
|
NFC_EXPORT int nfc_initiator_poll_dep_target(nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout);
|
||||||
NFC_EXPORT int nfc_initiator_deselect_target(nfc_device *pnd);
|
NFC_EXPORT int nfc_initiator_deselect_target(nfc_device *pnd);
|
||||||
NFC_EXPORT int nfc_initiator_transceive_bytes(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, int timeout);
|
NFC_EXPORT int nfc_initiator_transceive_bytes(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, int timeout);
|
||||||
NFC_EXPORT int nfc_initiator_transceive_bits(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar);
|
NFC_EXPORT int nfc_initiator_transceive_bits(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar);
|
||||||
NFC_EXPORT int nfc_initiator_transceive_bytes_timed(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, uint32_t *cycles);
|
NFC_EXPORT int nfc_initiator_transceive_bytes_timed(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, uint32_t *cycles);
|
||||||
NFC_EXPORT int nfc_initiator_transceive_bits_timed(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar, uint32_t *cycles);
|
NFC_EXPORT int nfc_initiator_transceive_bits_timed(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar, uint32_t *cycles);
|
||||||
NFC_EXPORT int nfc_initiator_target_is_present(nfc_device *pnd, const nfc_target *pnt);
|
NFC_EXPORT int nfc_initiator_target_is_present(nfc_device *pnd, const nfc_target nt);
|
||||||
|
|
||||||
/* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */
|
/* NFC target: act as tag (i.e. MIFARE Classic) or NFC target device. */
|
||||||
NFC_EXPORT int nfc_target_init(nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, const size_t szRx, int timeout);
|
NFC_EXPORT int nfc_target_init(nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, const size_t szRx, int timeout);
|
||||||
NFC_EXPORT int nfc_target_send_bytes(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout);
|
NFC_EXPORT int nfc_target_send_bytes(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout);
|
||||||
NFC_EXPORT int nfc_target_receive_bytes(nfc_device *pnd, uint8_t *pbtRx, const size_t szRx, int timeout);
|
NFC_EXPORT int nfc_target_receive_bytes(nfc_device *pnd, uint8_t *pbtRx, const size_t szRx, int timeout);
|
||||||
NFC_EXPORT int nfc_target_send_bits(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
|
NFC_EXPORT int nfc_target_send_bits(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
|
||||||
NFC_EXPORT int nfc_target_receive_bits(nfc_device *pnd, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar);
|
NFC_EXPORT int nfc_target_receive_bits(nfc_device *pnd, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar);
|
||||||
|
|
||||||
/* Error reporting */
|
/* Error reporting */
|
||||||
NFC_EXPORT const char *nfc_strerror(const nfc_device *pnd);
|
NFC_EXPORT const char *nfc_strerror(const nfc_device *pnd);
|
||||||
NFC_EXPORT int nfc_strerror_r(const nfc_device *pnd, char *buf, size_t buflen);
|
NFC_EXPORT int nfc_strerror_r(const nfc_device *pnd, char *buf, size_t buflen);
|
||||||
NFC_EXPORT void nfc_perror(const nfc_device *pnd, const char *s);
|
NFC_EXPORT void nfc_perror(const nfc_device *pnd, const char *s);
|
||||||
NFC_EXPORT int nfc_device_get_last_error(const nfc_device *pnd);
|
NFC_EXPORT int nfc_device_get_last_error(const nfc_device *pnd);
|
||||||
|
|
||||||
/* Special data accessors */
|
/* Special data accessors */
|
||||||
NFC_EXPORT const char *nfc_device_get_name(nfc_device *pnd);
|
NFC_EXPORT const char *nfc_device_get_name(nfc_device *pnd);
|
||||||
NFC_EXPORT const char *nfc_device_get_connstring(nfc_device *pnd);
|
NFC_EXPORT const char *nfc_device_get_connstring(nfc_device *pnd);
|
||||||
NFC_EXPORT int nfc_device_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt);
|
NFC_EXPORT int nfc_device_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt);
|
||||||
NFC_EXPORT int nfc_device_get_supported_baud_rate(nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
|
NFC_EXPORT int nfc_device_get_supported_baud_rate(nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
|
||||||
NFC_EXPORT int nfc_device_get_supported_baud_rate_target_mode(nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
|
|
||||||
|
|
||||||
/* Properties accessors */
|
/* Properties accessors */
|
||||||
NFC_EXPORT int nfc_device_set_property_int(nfc_device *pnd, const nfc_property property, const int value);
|
NFC_EXPORT int nfc_device_set_property_int(nfc_device *pnd, const nfc_property property, const int value);
|
||||||
NFC_EXPORT int nfc_device_set_property_bool(nfc_device *pnd, const nfc_property property, const bool bEnable);
|
NFC_EXPORT int nfc_device_set_property_bool(nfc_device *pnd, const nfc_property property, const bool bEnable);
|
||||||
|
|
||||||
/* Misc. functions */
|
/* Misc. functions */
|
||||||
NFC_EXPORT void iso14443a_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc);
|
NFC_EXPORT void iso14443a_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc);
|
||||||
NFC_EXPORT void iso14443a_crc_append(uint8_t *pbtData, size_t szLen);
|
NFC_EXPORT void iso14443a_crc_append(uint8_t *pbtData, size_t szLen);
|
||||||
NFC_EXPORT void iso14443b_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc);
|
NFC_EXPORT uint8_t *iso14443a_locate_historical_bytes(uint8_t *pbtAts, size_t szAts, size_t *pszTk);
|
||||||
NFC_EXPORT void iso14443b_crc_append(uint8_t *pbtData, size_t szLen);
|
|
||||||
NFC_EXPORT uint8_t *iso14443a_locate_historical_bytes(uint8_t *pbtAts, size_t szAts, size_t *pszTk);
|
|
||||||
|
|
||||||
NFC_EXPORT void nfc_free(void *p);
|
NFC_EXPORT void nfc_free(void *p);
|
||||||
NFC_EXPORT const char *nfc_version(void);
|
NFC_EXPORT const char *nfc_version(void);
|
||||||
NFC_EXPORT int nfc_device_get_information_about(nfc_device *pnd, char **buf);
|
NFC_EXPORT int nfc_device_get_information_about(nfc_device *pnd, char **buf);
|
||||||
|
|
||||||
/* String converter functions */
|
/* String converter functions */
|
||||||
NFC_EXPORT const char *str_nfc_modulation_type(const nfc_modulation_type nmt);
|
NFC_EXPORT const char *str_nfc_modulation_type(const nfc_modulation_type nmt);
|
||||||
NFC_EXPORT const char *str_nfc_baud_rate(const nfc_baud_rate nbr);
|
NFC_EXPORT const char *str_nfc_baud_rate(const nfc_baud_rate nbr);
|
||||||
NFC_EXPORT int str_nfc_target(char **buf, const nfc_target *pnt, bool verbose);
|
NFC_EXPORT int str_nfc_target(char **buf, const nfc_target nt, bool verbose);
|
||||||
|
|
||||||
/* Error codes */
|
/* Error codes */
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Success (no error)
|
* Success (no error)
|
||||||
*/
|
*/
|
||||||
#define NFC_SUCCESS 0
|
#define NFC_SUCCESS 0
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Input / output error, device may not be usable anymore without re-open it
|
* Input / output error, device may not be usable anymore without re-open it
|
||||||
*/
|
*/
|
||||||
#define NFC_EIO -1
|
#define NFC_EIO -1
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Invalid argument(s)
|
* Invalid argument(s)
|
||||||
*/
|
*/
|
||||||
#define NFC_EINVARG -2
|
#define NFC_EINVARG -2
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Operation not supported by device
|
* Operation not supported by device
|
||||||
*/
|
*/
|
||||||
#define NFC_EDEVNOTSUPP -3
|
#define NFC_EDEVNOTSUPP -3
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* No such device
|
* No such device
|
||||||
*/
|
*/
|
||||||
#define NFC_ENOTSUCHDEV -4
|
#define NFC_ENOTSUCHDEV -4
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Buffer overflow
|
* Buffer overflow
|
||||||
*/
|
*/
|
||||||
#define NFC_EOVFLOW -5
|
#define NFC_EOVFLOW -5
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Operation timed out
|
* Operation timed out
|
||||||
*/
|
*/
|
||||||
#define NFC_ETIMEOUT -6
|
#define NFC_ETIMEOUT -6
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Operation aborted (by user)
|
* Operation aborted (by user)
|
||||||
*/
|
*/
|
||||||
#define NFC_EOPABORTED -7
|
#define NFC_EOPABORTED -7
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Not (yet) implemented
|
* Not (yet) implemented
|
||||||
*/
|
*/
|
||||||
#define NFC_ENOTIMPL -8
|
#define NFC_ENOTIMPL -8
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Target released
|
* Target released
|
||||||
*/
|
*/
|
||||||
#define NFC_ETGRELEASED -10
|
#define NFC_ETGRELEASED -10
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Error while RF transmission
|
* Error while RF transmission
|
||||||
*/
|
*/
|
||||||
#define NFC_ERFTRANS -20
|
#define NFC_ERFTRANS -20
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* MIFARE Classic: authentication failed
|
* MIFARE Classic: authentication failed
|
||||||
*/
|
*/
|
||||||
#define NFC_EMFCAUTHFAIL -30
|
#define NFC_EMFCAUTHFAIL -30
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Software error (allocation, file/pipe creation, etc.)
|
* Software error (allocation, file/pipe creation, etc.)
|
||||||
*/
|
*/
|
||||||
#define NFC_ESOFT -80
|
#define NFC_ESOFT -80
|
||||||
/** @ingroup error
|
/** @ingroup error
|
||||||
* @hideinitializer
|
* @hideinitializer
|
||||||
* Device's internal chip error
|
* Device's internal chip error
|
||||||
*/
|
*/
|
||||||
#define NFC_ECHIP -90
|
#define NFC_ECHIP -90
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
# Allow intrusive auto-detection (default: false)
|
# Allow intrusive auto-detection (default: false)
|
||||||
# Warning: intrusive auto-detection can seriously disturb other devices
|
# Warning: intrusive auto-detection can seriously disturb other devices
|
||||||
# This option is not recommended, user should prefer to add manually his device.
|
# This option is not recommended, user should prefer to add manually his device.
|
||||||
#allow_intrusive_scan = false
|
#allow_intrusive_autoscan = false
|
||||||
|
|
||||||
# Set log level (default: error)
|
# Set log level (default: error)
|
||||||
# Valid log levels are (in order of verbosity): 0 (none), 1 (error), 2 (info), 3 (debug)
|
# Valid log levels are (in order of verbosity): 0 (none), 1 (error), 2 (info), 3 (debug)
|
||||||
|
|||||||
@ -5,9 +5,6 @@ IF(WIN32)
|
|||||||
|
|
||||||
# Add in the rc for version information in the dll
|
# Add in the rc for version information in the dll
|
||||||
LIST(APPEND WINDOWS_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/../windows/libnfc.rc)
|
LIST(APPEND WINDOWS_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/../windows/libnfc.rc)
|
||||||
IF (NOT MINGW)
|
|
||||||
LIST(APPEND WINDOWS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc_msvc.def)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
# Library's chips
|
# Library's chips
|
||||||
@ -15,41 +12,21 @@ SET(CHIPS_SOURCES chips/pn53x)
|
|||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/chips)
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/chips)
|
||||||
|
|
||||||
# Library's buses
|
# Library's buses
|
||||||
IF(USB_REQUIRED)
|
SET(BUSES_SOURCES buses/uart)
|
||||||
LIST(APPEND BUSES_SOURCES buses/usbbus)
|
|
||||||
ENDIF(USB_REQUIRED)
|
|
||||||
|
|
||||||
IF(UART_REQUIRED)
|
|
||||||
IF(WIN32)
|
|
||||||
# Windows have a special implementation for UART
|
|
||||||
LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/uart)
|
|
||||||
ELSE(WIN32)
|
|
||||||
LIST(APPEND BUSES_SOURCES buses/uart)
|
|
||||||
ENDIF(WIN32)
|
|
||||||
ENDIF(UART_REQUIRED)
|
|
||||||
|
|
||||||
IF(I2C_REQUIRED)
|
|
||||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
LIST(APPEND BUSES_SOURCES buses/i2c)
|
|
||||||
ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
# Only Linux is supported at the moment
|
|
||||||
#LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/i2c)
|
|
||||||
MESSAGE( FATAL_ERROR "I2C is only (yet) supported in Linux!" )
|
|
||||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
ENDIF(I2C_REQUIRED)
|
|
||||||
|
|
||||||
IF(SPI_REQUIRED)
|
|
||||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
LIST(APPEND BUSES_SOURCES buses/spi)
|
|
||||||
ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
# Only Linux is supported at the moment
|
|
||||||
#LIST(APPEND BUSES_SOURCES ../contrib/win32/libnfc/buses/spi)
|
|
||||||
MESSAGE( FATAL_ERROR "SPI is only (yet) supported in Linux!" )
|
|
||||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
||||||
ENDIF(SPI_REQUIRED)
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/buses)
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/buses)
|
||||||
|
|
||||||
|
INCLUDE(LibnfcDrivers)
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
# Windows now requires regex, so we utilize PCRE
|
||||||
|
# since Windows doesn't get the benefit of finding in CMake
|
||||||
|
# it has to be added manually
|
||||||
|
IF(PCRE_FOUND)
|
||||||
|
INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIRS})
|
||||||
|
LINK_DIRECTORIES(${PCRE_LIBRARY_DIRS})
|
||||||
|
ENDIF(PCRE_FOUND)
|
||||||
|
ENDIF(WIN32)
|
||||||
|
|
||||||
IF(PCSC_FOUND)
|
IF(PCSC_FOUND)
|
||||||
INCLUDE_DIRECTORIES(${PCSC_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(${PCSC_INCLUDE_DIRS})
|
||||||
LINK_DIRECTORIES(${PCSC_LIBRARY_DIRS})
|
LINK_DIRECTORIES(${PCSC_LIBRARY_DIRS})
|
||||||
@ -61,18 +38,11 @@ IF(LIBUSB_FOUND)
|
|||||||
ENDIF(LIBUSB_FOUND)
|
ENDIF(LIBUSB_FOUND)
|
||||||
|
|
||||||
# Library
|
# Library
|
||||||
SET(LIBRARY_SOURCES nfc nfc-device nfc-emulation nfc-internal conf iso14443-subr mirror-subr target-subr ${DRIVERS_SOURCES} ${BUSES_SOURCES} ${CHIPS_SOURCES} ${WINDOWS_SOURCES})
|
SET(LIBRARY_SOURCES nfc nfc-device nfc-emulation nfc-internal conf iso14443-subr mirror-subr target-subr log ${DRIVERS_SOURCES} ${BUSES_SOURCES} ${CHIPS_SOURCES} ${WINDOWS_SOURCES})
|
||||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
IF(LIBNFC_LOG)
|
IF(LIBNFC_LOG)
|
||||||
IF(WIN32)
|
LIST(APPEND LIBRARY_SOURCES log-printf)
|
||||||
IF(MINGW)
|
|
||||||
SET(CMAKE_C_FLAGS "-fgnu89-inline ${CMAKE_C_FLAGS}")
|
|
||||||
ENDIF(MINGW)
|
|
||||||
LIST(APPEND LIBRARY_SOURCES log ../contrib/win32/libnfc/log-internal)
|
|
||||||
ELSE(WIN32)
|
|
||||||
LIST(APPEND LIBRARY_SOURCES log log-internal)
|
|
||||||
ENDIF(WIN32)
|
|
||||||
ENDIF(LIBNFC_LOG)
|
ENDIF(LIBNFC_LOG)
|
||||||
ADD_LIBRARY(nfc SHARED ${LIBRARY_SOURCES})
|
ADD_LIBRARY(nfc SHARED ${LIBRARY_SOURCES})
|
||||||
|
|
||||||
@ -84,32 +54,28 @@ IF(LIBUSB_FOUND)
|
|||||||
TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES})
|
TARGET_LINK_LIBRARIES(nfc ${LIBUSB_LIBRARIES})
|
||||||
ENDIF(LIBUSB_FOUND)
|
ENDIF(LIBUSB_FOUND)
|
||||||
|
|
||||||
IF(LIBRT_FOUND)
|
SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 0)
|
||||||
TARGET_LINK_LIBRARIES(nfc ${LIBRT_LIBRARIES})
|
|
||||||
ENDIF(LIBRT_FOUND)
|
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(nfc PROPERTIES SOVERSION 6 VERSION 6.0.0)
|
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
# Libraries that are windows specific
|
# Libraries that are windows specific
|
||||||
TARGET_LINK_LIBRARIES(nfc wsock32)
|
TARGET_LINK_LIBRARIES(nfc wsock32)
|
||||||
IF(MINGW)
|
IF(PCRE_FOUND)
|
||||||
ADD_CUSTOM_COMMAND(
|
TARGET_LINK_LIBRARIES(nfc ${PCRE_LIBRARIES})
|
||||||
OUTPUT libnfc.lib
|
ENDIF(PCRE_FOUND)
|
||||||
COMMAND ${DLLTOOL} -d ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def -l ${CMAKE_CURRENT_BINARY_DIR}/libnfc.lib ${CMAKE_CURRENT_BINARY_DIR}/libnfc.dll
|
|
||||||
DEPENDS nfc ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def
|
ADD_CUSTOM_COMMAND(
|
||||||
)
|
OUTPUT libnfc.lib
|
||||||
ADD_CUSTOM_TARGET(win32lib ALL DEPENDS libnfc.lib)
|
COMMAND dlltool -d ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def -l ${CMAKE_CURRENT_BINARY_DIR}/libnfc.lib ${CMAKE_CURRENT_BINARY_DIR}/libnfc.dll
|
||||||
ELSE()
|
DEPENDS nfc ${CMAKE_CURRENT_SOURCE_DIR}/../contrib/win32/nfc.def
|
||||||
ADD_LIBRARY(win32lib ALIAS nfc)
|
)
|
||||||
ENDIF()
|
ADD_CUSTOM_TARGET(win32lib ALL DEPENDS libnfc.lib)
|
||||||
|
|
||||||
# On Windows the shared (runtime) library should be either in the same
|
# On Windows the shared (runtime) library should be either in the same
|
||||||
# directory as the excutables or in the path, we add it to same directory
|
# directory as the excutables or in the path, we add it to same directory
|
||||||
INSTALL(TARGETS nfc RUNTIME DESTINATION bin COMPONENT libraries)
|
INSTALL(TARGETS nfc RUNTIME DESTINATION bin COMPONENT libraries)
|
||||||
|
|
||||||
# At compile time we need the .LIB file, we place it in the lib directory
|
# At compile time we need the .LIB file, we place it in the lib directory
|
||||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.lib DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
|
INSTALL(TARGETS nfc ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT headers)
|
||||||
ELSE(WIN32)
|
ELSE(WIN32)
|
||||||
INSTALL(TARGETS nfc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
|
INSTALL(TARGETS nfc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|||||||
@ -3,26 +3,28 @@ SUBDIRS = chips buses drivers .
|
|||||||
# set the include path found by configure
|
# set the include path found by configure
|
||||||
AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) -DSYSCONFDIR='"$(sysconfdir)"'
|
AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) -DSYSCONFDIR='"$(sysconfdir)"'
|
||||||
|
|
||||||
|
noinst_HEADERS = \
|
||||||
|
conf.h \
|
||||||
|
drivers.h \
|
||||||
|
iso7816.h \
|
||||||
|
log.h \
|
||||||
|
mirror-subr.h \
|
||||||
|
nfc-internal.h \
|
||||||
|
target-subr.h
|
||||||
|
|
||||||
lib_LTLIBRARIES = libnfc.la
|
lib_LTLIBRARIES = libnfc.la
|
||||||
libnfc_la_SOURCES = \
|
libnfc_la_SOURCES = \
|
||||||
conf.c \
|
conf.c \
|
||||||
iso14443-subr.c \
|
iso14443-subr.c \
|
||||||
|
log.c \
|
||||||
mirror-subr.c \
|
mirror-subr.c \
|
||||||
nfc.c \
|
nfc.c \
|
||||||
nfc-device.c \
|
nfc-device.c \
|
||||||
nfc-emulation.c \
|
nfc-emulation.c \
|
||||||
nfc-internal.c \
|
nfc-internal.c \
|
||||||
target-subr.c \
|
target-subr.c
|
||||||
conf.h \
|
|
||||||
drivers.h \
|
|
||||||
iso7816.h \
|
|
||||||
log.h \
|
|
||||||
log-internal.h \
|
|
||||||
mirror-subr.h \
|
|
||||||
nfc-internal.h \
|
|
||||||
target-subr.h
|
|
||||||
|
|
||||||
libnfc_la_LDFLAGS = -no-undefined -version-info 6:0:0 -export-symbols-regex '^nfc_|^iso14443a_|^iso14443b_|^str_nfc_|pn53x_transceive|pn532_SAMConfiguration|pn53x_read_register|pn53x_write_register'
|
libnfc_la_LDFLAGS = -no-undefined -version-info 4:0:0 -export-symbols-regex '^nfc_|^iso14443a_|^str_nfc_|pn53x_transceive|pn532_SAMConfiguration|pn53x_read_register|pn53x_write_register'
|
||||||
libnfc_la_CFLAGS = @DRIVERS_CFLAGS@
|
libnfc_la_CFLAGS = @DRIVERS_CFLAGS@
|
||||||
libnfc_la_LIBADD = \
|
libnfc_la_LIBADD = \
|
||||||
$(top_builddir)/libnfc/chips/libnfcchips.la \
|
$(top_builddir)/libnfc/chips/libnfcchips.la \
|
||||||
@ -40,9 +42,10 @@ if LIBUSB_ENABLED
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if WITH_LOG
|
if WITH_LOG
|
||||||
libnfc_la_SOURCES += log.c log-internal.c
|
libnfc_la_SOURCES += log-printf.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
CMakeLists.txt \
|
CMakeLists.txt \
|
||||||
additional-pages.dox
|
log-printf.c
|
||||||
|
|
||||||
|
|||||||
@ -1,37 +1,11 @@
|
|||||||
|
|
||||||
# set the include path found by configure
|
# set the include path found by configure
|
||||||
AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS)
|
AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS)
|
||||||
|
|
||||||
|
noinst_HEADERS = uart.h
|
||||||
noinst_LTLIBRARIES = libnfcbuses.la
|
noinst_LTLIBRARIES = libnfcbuses.la
|
||||||
|
libnfcbuses_la_SOURCES = uart.c
|
||||||
libnfcbuses_la_SOURCES = empty.c
|
|
||||||
libnfcbuses_la_CFLAGS = -I$(top_srcdir)/libnfc
|
libnfcbuses_la_CFLAGS = -I$(top_srcdir)/libnfc
|
||||||
libnfcbuses_la_LIBADD =
|
|
||||||
EXTRA_DIST =
|
|
||||||
|
|
||||||
if SPI_ENABLED
|
EXTRA_DIST = uart_posix.c uart_win32.c
|
||||||
libnfcbuses_la_SOURCES += spi.c spi.h
|
|
||||||
libnfcbuses_la_CFLAGS +=
|
|
||||||
libnfcbuses_la_LIBADD +=
|
|
||||||
endif
|
|
||||||
EXTRA_DIST += spi.c spi.h
|
|
||||||
|
|
||||||
if UART_ENABLED
|
|
||||||
libnfcbuses_la_SOURCES += uart.c uart.h
|
|
||||||
libnfcbuses_la_CFLAGS +=
|
|
||||||
libnfcbuses_la_LIBADD +=
|
|
||||||
endif
|
|
||||||
EXTRA_DIST += uart.c uart.h
|
|
||||||
|
|
||||||
if LIBUSB_ENABLED
|
|
||||||
libnfcbuses_la_SOURCES += usbbus.c usbbus.h
|
|
||||||
libnfcbuses_la_CFLAGS += @libusb_CFLAGS@
|
|
||||||
libnfcbuses_la_LIBADD += @libusb_LIBS@
|
|
||||||
endif
|
|
||||||
EXTRA_DIST += usbbus.c usbbus.h
|
|
||||||
|
|
||||||
if I2C_ENABLED
|
|
||||||
libnfcbuses_la_SOURCES += i2c.c i2c.h
|
|
||||||
libnfcbuses_la_CFLAGS +=
|
|
||||||
libnfcbuses_la_LIBADD +=
|
|
||||||
endif
|
|
||||||
EXTRA_DIST += i2c.c i2c.h
|
|
||||||
|
|||||||
@ -1,2 +0,0 @@
|
|||||||
/* empty source code file */
|
|
||||||
#include <stdio.h>
|
|
||||||
@ -1,227 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Free/Libre Near Field Communication (NFC) library
|
|
||||||
*
|
|
||||||
* Libnfc historical contributors:
|
|
||||||
* Copyright (C) 2009 Roel Verdult
|
|
||||||
* Copyright (C) 2009-2013 Romuald Conty
|
|
||||||
* Copyright (C) 2010-2012 Romain Tarti?re
|
|
||||||
* Copyright (C) 2010-2013 Philippe Teuwen
|
|
||||||
* Copyright (C) 2012-2013 Ludovic Rousseau
|
|
||||||
* See AUTHORS file for a more comprehensive list of contributors.
|
|
||||||
* Additional contributors of this file:
|
|
||||||
* Copyright (C) 2013 Laurent Latil
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU Lesser General Public License as published by the
|
|
||||||
* Free Software Foundation, either version 3 of the License, or (at your
|
|
||||||
* option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file i2c.c
|
|
||||||
* @brief I2C driver (implemented / tested for Linux only currently)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include "config.h"
|
|
||||||
#endif // HAVE_CONFIG_H
|
|
||||||
#include "i2c.h"
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#include <nfc/nfc.h>
|
|
||||||
#include "nfc-internal.h"
|
|
||||||
|
|
||||||
#define LOG_GROUP NFC_LOG_GROUP_COM
|
|
||||||
#define LOG_CATEGORY "libnfc.bus.i2c"
|
|
||||||
|
|
||||||
# if defined (__linux__)
|
|
||||||
const char *i2c_ports_device_radix[] =
|
|
||||||
{ "i2c-", NULL };
|
|
||||||
# else
|
|
||||||
# error "Can't determine I2C devices standard names for your system"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
|
|
||||||
struct i2c_device_unix {
|
|
||||||
int fd; // I2C device file descriptor
|
|
||||||
};
|
|
||||||
|
|
||||||
#define I2C_DATA( X ) ((struct i2c_device_unix *) X)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Open an I2C device
|
|
||||||
*
|
|
||||||
* @param pcI2C_busName I2C bus device name
|
|
||||||
* @param devAddr address of the I2C device on the bus
|
|
||||||
* @return pointer to the I2C device structure, or INVALID_I2C_BUS, INVALID_I2C_ADDRESS error codes.
|
|
||||||
*/
|
|
||||||
i2c_device
|
|
||||||
i2c_open(const char *pcI2C_busName, uint32_t devAddr)
|
|
||||||
{
|
|
||||||
struct i2c_device_unix *id = malloc(sizeof(struct i2c_device_unix));
|
|
||||||
|
|
||||||
if (id == 0)
|
|
||||||
return INVALID_I2C_BUS ;
|
|
||||||
|
|
||||||
id->fd = open(pcI2C_busName, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
|
||||||
if (id->fd == -1) {
|
|
||||||
perror("Cannot open I2C bus");
|
|
||||||
i2c_close(id);
|
|
||||||
return INVALID_I2C_BUS ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ioctl(id->fd, I2C_SLAVE, devAddr) < 0) {
|
|
||||||
perror("Cannot select I2C device");
|
|
||||||
i2c_close(id);
|
|
||||||
return INVALID_I2C_ADDRESS ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Close the I2C device
|
|
||||||
*
|
|
||||||
* @param id I2C device to close.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
i2c_close(const i2c_device id)
|
|
||||||
{
|
|
||||||
if (I2C_DATA(id) ->fd >= 0) {
|
|
||||||
close(I2C_DATA(id) ->fd);
|
|
||||||
}
|
|
||||||
free(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Read a frame from the I2C device and copy data to \a pbtRx
|
|
||||||
*
|
|
||||||
* @param id I2C device.
|
|
||||||
* @param pbtRx pointer on buffer used to store data
|
|
||||||
* @param szRx length of the buffer
|
|
||||||
* @return length (in bytes) of read data, or driver error code (negative value)
|
|
||||||
*/
|
|
||||||
ssize_t
|
|
||||||
i2c_read(i2c_device id, uint8_t *pbtRx, const size_t szRx)
|
|
||||||
{
|
|
||||||
ssize_t res;
|
|
||||||
ssize_t recCount;
|
|
||||||
|
|
||||||
recCount = read(I2C_DATA(id) ->fd, pbtRx, szRx);
|
|
||||||
|
|
||||||
if (recCount < 0) {
|
|
||||||
res = NFC_EIO;
|
|
||||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR,
|
|
||||||
"Error: read only %d bytes (%d expected) (%s).", (int)recCount, (int) szRx, strerror(errno));
|
|
||||||
} else {
|
|
||||||
if (recCount < (ssize_t)szRx) {
|
|
||||||
res = NFC_EINVARG;
|
|
||||||
} else {
|
|
||||||
res = recCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Write a frame to I2C device containing \a pbtTx content
|
|
||||||
*
|
|
||||||
* @param id I2C device.
|
|
||||||
* @param pbtTx pointer on buffer containing data
|
|
||||||
* @param szTx length of the buffer
|
|
||||||
* @return NFC_SUCCESS on success, otherwise driver error code
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
i2c_write(i2c_device id, const uint8_t *pbtTx, const size_t szTx)
|
|
||||||
{
|
|
||||||
LOG_HEX(LOG_GROUP, "TX", pbtTx, szTx);
|
|
||||||
|
|
||||||
ssize_t writeCount;
|
|
||||||
writeCount = write(I2C_DATA(id) ->fd, pbtTx, szTx);
|
|
||||||
|
|
||||||
if ((const ssize_t) szTx == writeCount) {
|
|
||||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG,
|
|
||||||
"wrote %d bytes successfully.", (int)szTx);
|
|
||||||
return NFC_SUCCESS;
|
|
||||||
} else {
|
|
||||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR,
|
|
||||||
"Error: wrote only %d bytes (%d expected) (%s).", (int)writeCount, (int) szTx, strerror(errno));
|
|
||||||
return NFC_EIO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the path of all I2C bus devices.
|
|
||||||
*
|
|
||||||
* @return array of strings defining the names of all I2C buses available. This array, and each string, are allocated
|
|
||||||
* by this function and must be freed by caller.
|
|
||||||
*/
|
|
||||||
char **
|
|
||||||
i2c_list_ports(void)
|
|
||||||
{
|
|
||||||
char **res = malloc(sizeof(char *));
|
|
||||||
if (!res) {
|
|
||||||
perror("malloc");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
size_t szRes = 1;
|
|
||||||
|
|
||||||
res[0] = NULL;
|
|
||||||
DIR *pdDir;
|
|
||||||
if ((pdDir = opendir("/dev")) == NULL) {
|
|
||||||
perror("opendir error: /dev");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
struct dirent *pdDirEnt;
|
|
||||||
while ((pdDirEnt = readdir(pdDir)) != NULL) {
|
|
||||||
const char **p = i2c_ports_device_radix;
|
|
||||||
while (*p) {
|
|
||||||
if (!strncmp(pdDirEnt->d_name, *p, strlen(*p))) {
|
|
||||||
char **res2 = realloc(res, (szRes + 1) * sizeof(char *));
|
|
||||||
if (!res2) {
|
|
||||||
perror("malloc");
|
|
||||||
goto oom;
|
|
||||||
}
|
|
||||||
res = res2;
|
|
||||||
if (!(res[szRes - 1] = malloc(6 + strlen(pdDirEnt->d_name)))) {
|
|
||||||
perror("malloc");
|
|
||||||
goto oom;
|
|
||||||
}
|
|
||||||
sprintf(res[szRes - 1], "/dev/%s", pdDirEnt->d_name);
|
|
||||||
|
|
||||||
szRes++;
|
|
||||||
res[szRes - 1] = NULL;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
oom:
|
|
||||||
closedir(pdDir);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user