Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ISO14443B support #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add ISO14443B support #43

wants to merge 1 commit into from

Conversation

zhongfu
Copy link

@zhongfu zhongfu commented Feb 10, 2018

These changes allows users to detect, inList and exchange data with ISO14443B cards.

This commit has only been tested with ISO14443B cards (e.g. Singapore CEPAS standard cards) and SPI with an ESP8266 -- more testing may be required to ensure it doesn't break anything with other cards or protocols.

(As a unrelated sidenote, in case you're planning to test this with a CEPAS card: on certain modules, the antennas may not be able to read CEPAS standard cards. I've had success with a larger module with a rectangular (not square) antenna though. YMMV.)

@ChristopheBelpaire
Copy link

ChristopheBelpaire commented Nov 2, 2018

Hello,
I tried your branch, as I need to read some type b tags (VaultIC 154).
But I always have "Timed out waiting for a card" in loop.
I use the adafruit PN532 in SPI mode.
Any idea ?

Thanks in advance!

@bontrono
Copy link

Hello,
I tried your branch, as I need to read some type b tags (VaultIC 154).
But I always have "Timed out waiting for a card" in loop.
I use the adafruit PN532 in SPI mode.
Any idea ?

Thanks in advance!

Hi
I am currently facing the same issue.
"Timed out ..."

My first check : the chip
Seems like pn532 does accept 14443B mode whereas pn522 does not.
Both readers have a pn532 chip, so this is not an issue with the chip.

Next check : library
Using libnfc.
Investigated through the libnfc c files and searched for the term "14443B". Mentioned so many times that it can be inferred 14443B is being supported.

Google
nfc-tools/libnfc#397
I quote neomilium
"Some hardware are not able to communicate with ISO14443B tags due to antenna or amplifier.
In this case, there is no way to fix it using software, sorry."
It turns out Neomilium is a libnfc author.

So, it looks like an antenna issue. I've just ordered another bunch of readers to be tested.
I'll share the results.

Olivier

@Davincible
Copy link

Would be really nice if this would get merged

@Davincible
Copy link

I am getting a bunch of error trying to compile with this;

Compiling .pio/build/esp32dev/libff8/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp.o
In file included from /home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:60:0:
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h: In constructor 'Adafruit_PN532::Adafruit_PN532(uint8_t, uint8_t, uint8_t, uint8_t)':
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:29: error: 'Adafruit_PN532::_miso' will be initialized after [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
                             ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:22: error:   'uint8_t Adafruit_PN532::_mosi' [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
                      ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:127:1: error:   when initialized here [-Werror=reorder]
 Adafruit_PN532::Adafruit_PN532(uint8_t clk, uint8_t miso, uint8_t mosi, uint8_t ss):
 ^
In file included from /home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:60:0:
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:22: error: 'Adafruit_PN532::_mosi' will be initialized after [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
                      ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:11: error:   'uint8_t Adafruit_PN532::_ss' [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
           ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:127:1: error:   when initialized here [-Werror=reorder]
 Adafruit_PN532::Adafruit_PN532(uint8_t clk, uint8_t miso, uint8_t mosi, uint8_t ss):
 ^
In file included from /home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:60:0:
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h: In constructor 'Adafruit_PN532::Adafruit_PN532(uint8_t, uint8_t)':
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:29: error: 'Adafruit_PN532::_miso' will be initialized after [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
                             ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:22: error:   'uint8_t Adafruit_PN532::_mosi' [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
                      ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:151:1: error:   when initialized here [-Werror=reorder]
 Adafruit_PN532::Adafruit_PN532(uint8_t irq, uint8_t reset):
 ^
In file included from /home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:60:0:
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:22: error: 'Adafruit_PN532::_mosi' will be initialized after [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
                      ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:11: error:   'uint8_t Adafruit_PN532::_ss' [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
           ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:151:1: error:   when initialized here [-Werror=reorder]
 Adafruit_PN532::Adafruit_PN532(uint8_t irq, uint8_t reset):
 ^
In file included from /home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:60:0:
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h: In constructor 'Adafruit_PN532::Adafruit_PN532(uint8_t)':
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:29: error: 'Adafruit_PN532::_miso' will be initialized after [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
                             ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:22: error:   'uint8_t Adafruit_PN532::_mosi' [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
                      ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:172:1: error:   when initialized here [-Werror=reorder]
 Adafruit_PN532::Adafruit_PN532(uint8_t ss):
 ^
In file included from /home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:60:0:
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:22: error: 'Adafruit_PN532::_mosi' will be initialized after [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
                      ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.h:201:11: error:   'uint8_t Adafruit_PN532::_ss' [-Werror=reorder]
   uint8_t _ss, _clk, _mosi, _miso;
           ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:172:1: error:   when initialized here [-Werror=reorder]
 Adafruit_PN532::Adafruit_PN532(uint8_t ss):
 ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp: In member function 'bool Adafruit_PN532::sendCommandCheckAck(uint8_t*, uint8_t, uint16_t)':
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:349:12: warning: unused variable 'timer' [-Wunused-variable]
   uint16_t timer = 0;
            ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp: In member function 'bool Adafruit_PN532::writeGPIO(uint8_t)':
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:406:11: warning: unused variable 'errorbit' [-Wunused-variable]
   uint8_t errorbit;
           ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp: In member function 'uint8_t Adafruit_PN532::mifareclassic_AuthenticateBlock(uint8_t*, uint8_t, uint32_t, uint8_t, uint8_t*)':
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:971:11: warning: unused variable 'len' [-Wunused-variable]
   uint8_t len;
           ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp: In member function 'uint8_t Adafruit_PN532::mifareclassic_WriteNDEFURI(uint8_t, uint8_t, const char*)':
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:1184:53: warning: narrowing conversion of '(((int)len) + 5)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t sectorbuffer1[16] = {0x00, 0x00, 0x03, len+5, 0xD1, 0x01, len+1, 0x55, uriIdentifier, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
                                                     ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:1184:72: warning: narrowing conversion of '(((int)len) + 1)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   uint8_t sectorbuffer1[16] = {0x00, 0x00, 0x03, len+5, 0xD1, 0x01, len+1, 0x55, uriIdentifier, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
                                                                        ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp: In member function 'uint8_t Adafruit_PN532::ntag2xx_WriteNDEFURI(uint8_t, char*, uint8_t)':
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:1552:8: warning: narrowing conversion of '(((int)len) + 5)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
     len+5,        /* Payload Length (not including 0xFE trailer) */
        ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:1555:8: warning: narrowing conversion of '(((int)len) + 1)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
     len+1,        /* Payload len */
        ^
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp: In member function 'void Adafruit_PN532::readdata(uint8_t*, uint8_t)':
/home/tyler/.platformio/lib/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp:1728:14: warning: unused variable 'timer' [-Wunused-variable]
     uint16_t timer = 0;
              ^
cc1plus: some warnings being treated as errors
*** [.pio/build/esp32dev/libff8/Adafruit-PN532-Zhongfu/Adafruit_PN532.cpp.o] Error 1

@gbetromero
Copy link

Hello gentlemen,

i am very interested in reading iso14443b cards, i have a box full of them the i purchased. I recently bought the PN532 cause according to the specification when i bought, that it can read iso14443b cards. i look everywhere and i came across this github link and it brought some hope after so much time searching.

Anyways I visited this nfc-tools/libnfc#397, and tried the code that is there, i played with it but i couldn't never find the nfc/nfc.h library anywhere.... any hopes or ideas?

@asdfjkl
Copy link

asdfjkl commented Jan 4, 2021

It did extensive testing with the shield and ISO 14443 B cards, and thorougly studied the NXP chip documentation of the PN532.
Some Type B cards worked, some didn't. I had success with some Japanese passports. Lot's of European ID cards and some non-NXP JavaCards did not work.

These cards simply didn't show up in the field at all. This means that either these cards require some obscure combination of RF settings (I could not find an RF setting of the PN532 that worked) or that the antenna design is not suited to reliably working with Type B cards.

In other words: If you rely on Type B cards working I recommend to look for other solutions than the Adafruit shield. Type A works fine (even though no extended length support). I therefore think this pull request should not be merged, as users might falsely think that they can get any Type B card working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants