Commit graph

177 commits

Author SHA1 Message Date
Romuald Conty
cd6946e751 Add ISO/IEC 14443 B' aka Type B' modulation partial support 2011-05-06 14:14:06 +00:00
Romuald Conty
5f890fedcc Remove obsolete callbacks 2011-05-05 09:45:39 +00:00
Romuald Conty
0265515a0c Abort mecanism is now implemented in driver layer:
iAbortFd file descriptor array have been removed from nfc_device_t;
nfc_abort_command() can now failed (return false);
nfc_abort_command() now call abort_command pointer from drivers;
pn532_uart and arygon drivers use a pipe-based mecanism (similar from previous one);
pn53x_usb driver use a boolean flag-based mecanism (the previous one does not work as expected);
pn53x_usb now print smarter messages on error at usb connection;
pn53x_usb now handle a strange case: sometimes, the first sent command is not ACKed by PN53x USB device, a dummy command is now sent.
2011-05-05 09:27:17 +00:00
Romuald Conty
ef92fc6a7b add C++ compatibility in include/nfc/nfc-emulation.h 2011-04-06 21:42:47 +00:00
Philippe Teuwen
fb398c387f pn53x: add timed versions of transceive_bytes/bits 2011-04-04 14:16:36 +00:00
Romuald Conty
5db8be908b Windows support contribution:
- Move CMake modules from cmake_modules/ to cmake/modules/
 - CMake now use cmake/config_windows.h.cmake to create config.h on Windows platform
 - contrib/windows.h header is automagically included by config.h
 - Put missing NFC_EXPORT macro on front of emulation API
 - nfc-mfclassic and nfc-mfcultralight examples are now compiled under Windows
Many thanks to Glenn Ergeerts which provide the initial patch.
2011-03-31 13:38:49 +00:00
Romain Tartiere
53960c4643 Split user_data and state_machine_data. 2011-03-13 14:40:36 +00:00
Romain Tartiere
0f0fa2b14f Move nfc_emulate_target() from examples to the library. 2011-03-13 14:31:06 +00:00
Romain Tartiere
ad530f6d02 Various cleanups.
- New functions nfc_device_new(), nfc_device_free();
- Add experimental abort mechanism for the PN53x USB driver;
- Move chip-specific variables from nfc_device_t to pn53x_data (Fixes Issue 124).
2011-03-09 13:37:16 +00:00
Romuald Conty
0efa47880b Hardware abstraction layer for libnfc:
Suppress any PN53x references in nfc.c
Improve nfc_driver_t struct to embedded HAL API
Merge macros from nfc-messages.h into nfc-internal.h
Remove useless files: nfc-messages.h, buses.h and chips.h
Implement HAL for ARYGON driver
Move send/receive callbacks from nfc_driver_t to internal chip io callbacks (since there are dedicated to pn53x framing)
2011-03-05 10:06:52 +00:00
Romuald Conty
9b202d1dbf prefer one-line protypes in API. 2011-03-05 09:09:13 +00:00
Romain Tartiere
4b6060aeeb Enable aborting blocking commands (e.g. TgInitAsTarget) and refactor
*_check_communication() as pn53x_check_communication().
2011-03-04 19:59:49 +00:00
Romuald Conty
5af845cdfc Broke whole the libnfc :-)
use a new way to handle drivers
use absolute include path instead of relative ones
move some nfc_device_t members in a better place
nfc_device_t now embeddeds driver data and chip data pointers (useful to be more generic)
use more readable variables instead of strange coding convention
move PRINT_HEX macro into nfc-internal.h
silent warnings with more strict CFLAGS
chips/pn53x: use the powerful C99 writing to construct PN53x commands
chips/pn53x: remove almost all memcpy()
chips/pn53x: WriteRegister, ReadRegister and SetParameters command wrappers are correctly named
chips/pn53x: introduce chip state (SLEEP, NORMAL or EXECUTE)
chips/pn53x: add SAMConfiguration command wrapper (need to be improved)
chips/pn53x: remove almost all const arrays
chips/pn53x: use human readable defines for commands instead of hex values
chips/pn53x: in debug mode, the PN53x command is shown in human-readable string, awesome isn't it? ;-)
drivers: split transceive() into send() and receive() to be able to handle more cases (differed replies, abort commands, etc) later
drivers: use a const structure of functions instead of -dirty- callbacks array
drivers/pn532_uart: major improvement of UART handling
drivers/pn532_uart: check PN53x frames when received
buses/uart: receive() is now based on expected bytes instead of calculated timeouts..
buses/uart: use a smart way to determine available ports on POSIX systems (tested on Linux and FreeBSD)
2011-03-02 15:00:44 +00:00
Romuald Conty
58ad2a5760 Add new supported device: ASK / LoGO. (Thanks to ASK for sending one sample of this device) 2011-02-01 21:20:48 +00:00
Romuald Conty
0f8c23bddd Inform user if target UID can be emulated
New error: ETGUIDNOTSUP raised when UID is not 4 bytes long or does not start with 0x08 (Security restriction present in the NXP PN53x chips)
2011-01-07 16:15:18 +00:00
Romuald Conty
6df612a364 Errors use #define instead of constant values.
Update Issue 84
Current 'ident' command breaks commit-concerned lines.
2010-11-15 18:50:53 +00:00
Romain Tartiere
4e5d0766e1 Rename append_iso14443a_crc() to iso14443a_crc_append(). 2010-10-29 10:59:26 +00:00
Romuald Conty
a214974684 Remove INFO macro: display was not clear enough and does not provide a big benefit.
New Issue
Summary: Remove nfc-message.h file from installed ones
nfc-message.h provide some usefull debugging macros but I am not sure that these macros have to be installed with other files.
2010-10-26 14:27:17 +00:00
Romuald Conty
5538fbd20f Add NBR_847 (used with ISO14443B) and update convert function. 2010-10-20 08:34:06 +00:00
Romuald Conty
ccbd2d83c6 Add NEWS file to summarize important changes (like API ^^) 2010-10-19 15:50:18 +00:00
Romuald Conty
f249af6266 Add ISO14443-4 modulation to hardware polling only when NDO_AUTO_ISO14443_4A have been enabled and document this features and known issues. 2010-10-19 09:34:18 +00:00
Romuald Conty
b5d85fc6e1 Decode supported modulation from PN53x 2010-10-18 14:26:49 +00:00
Romuald Conty
1f62e9e2f2 Improve API for target emulation, nfc_target_mode_t does not exist anymore (this mode is computed from nfc_target_t) 2010-10-15 14:32:10 +00:00
Philippe Teuwen
ffe50562dd Make use of the now available Tk info 2010-10-14 18:33:17 +00:00
Romuald Conty
41758ab63f pn53x_target_init() now takes care of Historical Bytes 2010-10-14 17:38:54 +00:00
Romuald Conty
7c76e1bf32 nfc_target_init() now update nfc_target_t baud rate 2010-10-14 16:27:50 +00:00
Romuald Conty
60c9da598a Support different baud rates for nfc_initiator_select_dep_target() 2010-10-14 13:03:23 +00:00
Romuald Conty
af88da1a9c Replace nfc_target_info_t with nfc_target_t in API function, we now have a coherent struct to handle nfc_target_t, use it! 2010-10-14 11:44:43 +00:00
Romuald Conty
6f3fbcb6bf Fix nfc_dep_mode_t usage in API, fix/improve documentation 2010-10-14 11:12:23 +00:00
Romuald Conty
9d9b5a629e Fix nfc-poll, improve pn53x_target_type_t decoding 2010-10-13 21:40:54 +00:00
Romuald Conty
adba90684d introduce nfc_dep_mode_t type instead of bool in nfc_initiator_select_dep_target() 2010-10-13 19:59:39 +00:00
Romuald Conty
979430ecd1 nfc_target_t have now nfc_modulation_t instead of nfc_modulatation_type_t 2010-10-13 19:17:51 +00:00
Romuald Conty
d289eabc36 Attempt to provide clean types for API 2010-10-13 17:43:23 +00:00
Romuald Conty
9020014160 Rename nfc_modulation_t as pn53x_modulation_t 2010-10-13 15:39:52 +00:00
Romuald Conty
695e5c2f37 Rename nfc_target_type_t as pn53x_target_type_t 2010-10-13 15:31:48 +00:00
Romuald Conty
c53c512831 Change some nfc_target_type_t to insist on the ISO/IEC 14443-4 compliance 2010-10-13 11:49:34 +00:00
Romuald Conty
0fe30e3db7 Change some nfc_target_mode_t to insist on the restrictions offer these mode 2010-10-13 11:35:28 +00:00
Romuald Conty
c34be50ef1 For the sake of consistency, rename all szRxLen to szRx and szTxLen to szTx 2010-10-12 14:56:42 +00:00
Romuald Conty
602787bd03 We can now use an nfc_dep_info_t to specify DEP info as initiator. 2010-10-11 14:49:08 +00:00
Romuald Conty
1e9c390dfa Improve DEP info struct: add more info, and InJumpDEP now fill fully this struct. 2010-10-08 20:25:34 +00:00
Romuald Conty
d9505bbbcc Better handling of SetParameters command, use a cache, prevent from double set, adjust comments, remove junk code. 2010-10-06 15:12:33 +00:00
Romuald Conty
da7a2bc4c6 Add ISO/IEC 14443B baud rates: 212, 424 and 847 kbps. Set a device error when using a not supported modulation baud rate in InListPassive(). 2010-10-06 10:06:12 +00:00
Romuald Conty
92cc9a5736 Add non restrictive mode for emulation (NTM_NORMAL), fix comments, rename NTM_PICC to insist on "ISO14443-4" PICC mode. 2010-10-04 13:26:47 +00:00
Romuald Conty
5233fceda7 Improve the target emulation functions (ATM, only ISO14443A), add an example (nfc-emulate-tag), update examples to use the new API. 2010-10-04 12:46:03 +00:00
Romuald Conty
4a3a185857 Fix bad indent
Update issue 84
Indent insert some blank lines.
2010-10-01 11:00:27 +00:00
Romuald Conty
4d880e6ce8 Enhance documentation and fix typo. 2010-09-29 14:26:06 +00:00
Roel Verdult
6dfe88113e Added new example, PN53x chips will now emulate NDEF tag! not in build-script yet 2010-09-28 16:15:59 +00:00
Romuald Conty
2f95fb254b Improve ATQB decoding: "PUPI", "Application Data", and "Protocol Info" is now available as separated fields. 2010-09-23 16:26:06 +00:00
Romuald Conty
ccfd24a682 nfc-anticol now works even after running another program that change the modulation (Fixes Issue 111) (Thanks to Phil for help). 2010-09-23 16:03:05 +00:00
Romuald Conty
7e2ddedfc1 Fix ISO14443-B ATTRIB_RES decoding. (Thanks to Phil) 2010-09-23 10:12:10 +00:00
Romuald Conty
e2a2557396 Replace wrong decoded ISO14443-B data by ATTRIB_RES field.
New issue
Summary: Improve ISO 14443-B data (ATTRIB_RES) decoding
Before this revision, pn53x_decode_target_data() wrongly decode ISO14443-B. Currently, whole ATTRIB_RES field is stored in nfc_target_info_t struct.
I do not find the correct documentation to fix it better than this, but at least it now retrieves a correct value.
2010-09-22 19:10:50 +00:00
Romuald Conty
0ea9467b56 Minor indentation fixes. 2010-09-20 14:41:41 +00:00
Romuald Conty
362dfb51db API documentation is more clean now: functions order have more sense. 2010-09-10 13:35:25 +00:00
Romuald Conty
18cc86a613 Indent whole code using make indent. (Fixes issue 84). 2010-09-07 17:51:03 +00:00
Romain Tartiere
c82e1ff30f Change NDO_EASY_FRAMING value form 0x02 to 0x41.
Update issue 106
Just changed NDO_EASY_FRAMING value as requested.
2010-09-03 16:47:17 +00:00
Romain Tartiere
cbbe559f94 Alse remove nfc_target_receive_dep_bytes() and nfc_target_send_dep_bytes().
Update issue 106
Implement what's described in comment 3, 7 and 8.
2010-09-03 16:45:24 +00:00
Romain Tartiere
a5676ecd94 Remove nfc_initiator_transceive_dep_bytes() and introduce NDO_EASY_FRAMING option.
Always use nfc_initiator_transceive_bytes(). If you where using advanced
features and already relying on nfc_initiator_transceive_bytes(), then your
code has to be updated to unset the NDO_EASY_FRAMING option.  See an example of
such a change in the libfreefare's repository:
http://code.google.com/p/nfc-tools/source/detail?r=566

Updates issue 106
Status: Feedback
Romuald: I am not sure about the option enum values.  I took 0x02 thinking it
would not hurt but am not really sure about that because I can see many 'holes'
in the sequence.
2010-09-03 16:13:36 +00:00
Romain Tartiere
5b0589c381 Merge r551-563 from trunk. 2010-08-20 10:41:30 +00:00
Romuald Conty
8f19b078ff Add configuration option to enable/disable auto iso14443-4 mode. 2010-08-19 10:58:15 +00:00
Romain Tartiere
08eb21aa9d Second part of error handling.
- Define two sets of DE<FOOBAR> macros: the first one for 'generic' errors
  which could be encountered regardless of the NFC device the library is acting
  with (0xX000), and ont set for device-dependant errors (0x0X00).
- Make some more functions accept a nfc_device_t* as first argument to have
  access to the iLastError;
- Reset errors when entering public API functions;
- Save errors when applicable;
- Distinguish system-level errors (e.g. I/O error) and operational errors (the
  PCD returns an unexpected value);
- Minor tweaks.

Update issue 65
Status: Feedback

New review:
Owner: rconty@il4p.fr
Cc: rtartiere@il4p.fr
Summary: Review the error-handling code.
Branch: /branches/libnfc-error-handling

For this development, a strong emphasis has been set on making changes that
will not go through our way on the way to libnfc-1.6+.  For this reason, some
constructs are not natural (e.g. error codes defined in two different places),
please keep this in mind when reviewing.
2010-08-15 14:08:29 +00:00
Romain Tartiere
f4bc39bf41 Mostly revert r521.
It was obviously an April joke: iErrorCode which was renamed iPICCError is
indeed a PCD Error, so I renamed it to iLastError since communications errors are
also to handle at the device driver level (read chip level), although I guess
that some errors would be common to distinct devices.
PICC error are irrelevant because they can either be transmission error
detection (in which case the libnfc should retry the transmission) or
application-level errors the libnfc cannot be aware of.
2010-08-13 09:02:20 +00:00
Romain Tartiere
0502401a29 Minor tweaks.
- Rename the nfc_device_t's struct iErrorCode member to iPICCError (We are
    likely to have both PICC and PCD errors fields to avoid unneeded complexity
    at some point);
  - Make the PN53x error descriptions static;
  - Enhance some comments here and there.
2010-08-13 08:31:16 +00:00
Romain Tartiere
79aeaa6287 Factorise code.
Avoid redundant code in PN53x usb and uart drivers.  Since it makes sense to
report errors at the nfc_device_t level, pass it directly to
pn53x_transceive().

Programs using the libnfc MAY use pn53x_transceive() to communicate with a NFC
device, and SHALL not use anymore pnd->pdc->transceive().  Code in the library
itself SHOULD avoid calling pnd->pdc->transceive(), so such construct have been
updated accordingly.
2010-07-31 14:20:15 +00:00
Romain Tartiere
fb6d9d2d20 Yes we can... remove all those pnd->pdc->transceive() from nfc.c.
Within the ongoing effort to improve the NFC devices abstraction, and now that
pn53x_transceive() does not fail when it reads a response that has no
status-code, do not call directly pnd->pdc->transceive() from nfc.c.  In a
mid-term future this will be changed again, and calling pn53x_transceive() from
nfc.c will be forbiden, in favor of colling some pnd->transceive() function,
but that's another part of the story.

Of course, it changes the API one more and it's not going to be the last time
in this branch.
2010-07-31 09:40:29 +00:00
Romain Tartiere
36ee32f81a Merge r478-485 from trunk. 2010-07-30 16:34:12 +00:00
Romuald Conty
0afaf656fa Attempt to provide target listing function (WARNING: this function is actually incomplete)
New issue
Summary: Provide a target listing function
Labels: Milestone-1.4.x
Libnfc lacks of target listing function. Actually, applications or libraries based on libnfc have to wrote their own listing function which can provide side effect if two or more of theses libraries are used together in the same application. Plus, some kind of problem could appears during listing multiples targets (i.e. collisions) and this problem should be solved in libnfc (i.e. using NFC chip capabilities), not in applications based on libnfc.
2010-07-30 13:27:03 +00:00
Romain Tartiere
daa178b18f Enhance error handeling.
- New API functions: nfc_strerror(), nfc_strerror_r() and nfc_perror();
  - Drivers now have a reference to chips callback methods;
  - Rename -pn53x_err2string to pn53x_strerror and add it to pn53x_callbacks_list.
2010-07-29 14:16:11 +00:00
Romain Tartiere
9984e1bdcb Start of work on error handling. 2010-07-26 12:41:46 +00:00
Romuald Conty
c4bb23631b Do not export nfc_parse_device_desc() in libnfc API. 2010-07-22 16:13:02 +00:00
Emanuele Bertoldi
4bc522cd1e First prototype of argument parsing for device description (issue #87). 2010-07-22 13:41:20 +00:00
Romuald Conty
2688de6500 API change: nfc_initiator_select_tag() is now nfc_initiator_select_passive_target() AND nfc_initiator_deselect_tag() is now nfc_initiator_deselect_target() 2010-07-21 10:37:37 +00:00
Romuald Conty
f7c31885f5 Move all Mifare related code from libnfc API to examples: NFC is capable of Mifare, but Mifare is not NFC. 2010-06-15 15:33:22 +00:00
Romain Tartiere
10baef235f (libnfc-less-bitutils-more-ponies) Get rid of bitutils.[hc] (part 1).
- New API function append_iso14443a_crc();
  - Add a PRINT_HEX macro for driver debugging (replaces print_hex function from bitutils.c);
  - Move bit-mirroring related functions to libnfc/mirror-subr.[hc];
  - Move iso14443 related functions to libnfc/iso14443-subr.c;
  - Move libnfc/bitutils.c hex-dumping code to examples/nfc-utils.c;
  - Replace calls to swap_endian32() and swap_endian64() functions with calls to bswap32() and bswap64 provided by endian.h.

And while I am here:
  - Fix the DBG macro so that it does not throw warning at compile time.
2010-04-16 16:38:57 +00:00
Romain Tartiere
5302930b09 Avoid using a 'comma pasting' GNU extension (non-portable, reported my clang).
This is not a 'complete' fix since the DBG macro is still using it; but more globally, this file should not be part of the libnfc installed files.  We should rely on error codes and maybe some logging mechanism (e.g. syslog() on POSIX compliant systems and RegisterEventSource() / ReportEvent() on Windows).
2010-04-16 14:50:48 +00:00
Romuald Conty
40f230d6f0 New API function (experimental): nfc_initiator_poll_targets() which allow to use hardware polling function. Warning: ATM, it only support ISO14443a targets. 2010-04-09 16:20:47 +00:00
Romuald Conty
bc4c34f851 Add two new types: nfc_target_type_t and nfc_target_t. 2010-04-09 16:16:17 +00:00
Romain Tartiere
c7d77d7664 Rearrange source code. 2010-04-07 14:37:19 +00:00