0

I'm trying to manage value block with a Mifare Classic and PN532 reader. I'm using an open source library named "libnfc" but I do not see anything related to value blocks in this library.

Does anyone know how I could make increment, decrement and transfer calls with this reader & library?

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
crossmax
  • 346
  • 3
  • 20

1 Answers1

0

Have a look at the header utils/mifare.h (and its associated implementation utils/mifare.c). They contain an implementation of the MIFARE reader commands. For instance, for the increment command, you would use something like:

mp.mpv.abtValue[0] = 1;
mp.mpv.abtValue[1] = 0;
mp.mpv.abtValue[2] = 0;
mp.mpv.abtValue[3] = 0;

nfc_initiator_mifare_cmd(pnd, MC_INCREMENT, blockNumber, &mp);

Where pnd is a nfc_device *, mp is a mifare_param and you previously authenticated to that sector (see utils/nfc-mfclassic.c).

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • Thanks Michael! but I'm using a Python wrapper of the library (nfcpy library) and seems not to have avalilable the modules in the "utils" folder. – crossmax Aug 16 '16 at 10:38
  • I'm looking for a nfc library in Python but is difficult to find one with decrement and increment functions. I'm reading a little about how to use libraries written in C if my program is written in Python, but I prefer reuse some library ready to use, of course ;) – crossmax Aug 16 '16 at 10:46
  • @crossmax You should have explained that in your question. Note that [nfcpy](https://github.com/nfcpy/nfcpy) (or formerly [available here](https://launchpad.net/nfcpy)) is certainly **not** a wrapper for libnfc. nfcpy is a completely independent implementation. Hence asking for libnfc if you want nfcpy does not make sense at all. – Michael Roland Aug 16 '16 at 13:56
  • Btw. nfcpy does not implement *any* commands related to MIFARE Classic (not even authentication and block-oriented memory access). And according to this [bug report](https://github.com/nfcpy/nfcpy/issues/32) nfcpy won't include any support for MIFARE Classic in future versions. – Michael Roland Aug 16 '16 at 14:08
  • I was testing several libraries and mistook nfcpy with pynfc. With [`pynfc`](https://github.com/ikelos/pynfc) I can do increment, decrement and restore a value block. Thank you for taking your time – crossmax Aug 19 '16 at 10:34