Commit graph

177 commits

Author SHA1 Message Date
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