pn532 | PN532 NFC/RFID Native Python API for your Raspberry Pi

 by   hoanhan101 Python Version: Current License: MIT

kandi X-RAY | pn532 Summary

kandi X-RAY | pn532 Summary

pn532 is a Python library typically used in Internet of Things (IoT), Raspberry Pi applications. pn532 has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can download it from GitHub.

PN532 NFC/RFID Native Python API for your Raspberry Pi.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pn532 has a highly active ecosystem.
              It has 11 star(s) with 4 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 1 open issues and 0 have been closed. There are no pull requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of pn532 is current.

            kandi-Quality Quality

              pn532 has 0 bugs and 3 code smells.

            kandi-Security Security

              pn532 has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pn532 code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pn532 is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              pn532 releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              pn532 saves you 262 person hours of effort in developing the same functionality from scratch.
              It has 635 lines of code, 61 functions and 13 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pn532 and discovered the below as its top functions. This is intended to give you an instant insight into pn532 implemented functionality, and help decide if they suit your requirements.
            • Block a device call .
            • Read a block of bytes from the device .
            • Write a message to an address .
            • Construct a frame structure .
            • Create i2c messages .
            • Read data from the device .
            • Read card data .
            • Find the version string in the given files .
            • Initialize the bus .
            • Return the next value .
            Get all kandi verified functions for this library.

            pn532 Key Features

            No Key Features are available at this moment for pn532.

            pn532 Examples and Code Snippets

            No Code Snippets are available at this moment for pn532.

            Community Discussions

            QUESTION

            Extract payload from NDEF message
            Asked 2022-Mar-01 at 18:32

            I am using Arduino UNO and a PN532 NFC module to receive P2P NDEF messages from an Android phone.

            I am sending a plaintext string "Hello". When the transfer is successful, I get this on my Arduino: image

            How can I extract the string "Hello" (I think the pairs of numbers before it is the "Hello" in hexadecimal, same for the "text/plain" type indication, type length and payload length) from the NDEF message payload into a regular variable?

            Here is my Arduino code:

            ...

            ANSWER

            Answered 2022-Mar-01 at 18:32

            A NdefMessage is made up of multiple NdefRecord items and you msg has 1 record

            so this should do it (not tested)

            Source https://stackoverflow.com/questions/71312574

            QUESTION

            Sending commands to ACR122U with Swift or Objective-C
            Asked 2022-Feb-21 at 17:57

            I’m in the process of writing a macOS application that will provide features to read and write data to nfc tags using the ACR122u usb reader. I’m having a difficult time finding examples of how to send commands to the device in this environment. I came across this question but can’t seem to adapt it to Swift or Objective C. Any help would be greatly appreciated.

            Here's what I have so far but I can't seem to wrap my head around how to send an array of bytes.

            ...

            ANSWER

            Answered 2022-Feb-21 at 17:57

            It turns out that using CryptoTokenKit was a better fit than what I had previously found. You init the reader as a TKSmartCardSlot and the card as a TKSmartCard. You then transmit the byte array to the TKSmartCard through the transmit function. Please send a dm if anyone needs additional information about this workflow.

            https://developer.apple.com/documentation/cryptotokenkit/tksmartcardslot

            Source https://stackoverflow.com/questions/71161758

            QUESTION

            ESP8266 (Nodemcu) + PN532 (RFID) + ST7735 (Display) in one setup possible?
            Asked 2021-Dec-12 at 20:27

            I am trying to get an RFID-Reader (PN532) to work with a display, so it is shown there, who has scanned his RFID-Card. The problem I ran into was, that 2 pins (D7 HMOSI) and (D5 HSLCK) are used by both devices. Thus I simply put both connections on those. (wrong?)

            Now when initializing either of both devices, the other one gets disabled.

            I use Adafruit to initialize both devices.

            In addition to this, the ESP8266 does not start when the RFID-Reader is connected. Removing the Pin from 3.3Volt VCC and waiting for init, then Adding the Pin, only then the RFID-Reader gets recognized and the ESP8266 runs. (bad case for crashes, as it would never reboot)

            This is my cable setup:

            Also here is my code:

            ...

            ANSWER

            Answered 2021-Dec-12 at 20:27

            QUESTION

            Emulate Mifare EV2 Card with HCE
            Asked 2021-Sep-06 at 21:15

            So the problem I'm having is the following: I'm trying to emulate the EV2 Card on Android devices using the HCE service by the Android. I have a PN532 (Adafruit) board and a firmware is already installed on it and it uses DESfire native command set. So, processApduCommand() is never called because the command received by the phone is not in APDU format (ISO 7816 - 4). So how much of the native DESfire command set can I implement using the APDU protocol? How can I proceed from here? Thank you all in advance.

            ...

            ANSWER

            Answered 2021-Sep-06 at 21:15

            You won't be able to emulate a Mifare DESfire native command set, you will only be able to emulate the ISO 7816 - 4 commands and ISO/IEC 7816-4 wrapped native command set.

            You need to change how the PN532 (Adafruit) board sends the commands by wrapping them in ISO 7816 - 4 commands first.

            Wrapping example https://ridrix.wordpress.com/2009/09/19/mifare-desfire-communication-example/

            Source https://stackoverflow.com/questions/69079741

            QUESTION

            NFC - Android device can't read Type 4 NDEF tag content emulated from ACR122U (PN532)
            Asked 2021-Jun-25 at 07:53

            I'm writing C# application to emulate NFC tag via ACR122U, which uses PN532 internally. I want Android to read simple URI NDEF Tag.

            I'm able to communicate with Android using NFC Forum Type 4 Tag protocol, Android detects the tag, but is not able to read the NDEF file - checked with NFC Tools app.

            The communication looks like this:

            ...

            ANSWER

            Answered 2021-Jun-24 at 19:42

            The problem is indeed in the last message. Just before that Android was asking for NDEF content from offset 02: < D5-87-00-00-B0-00-02-12-90-00

            Last message included the whole NDEF content including the size on first 2 bytes: 00-10. This must be removed:

            FF-00-00-00-14-D4-8E-D1-01-0C-55-01-67-6F-6F-67-6C-65-2E-63-6F-6D-2F-90-00

            This worked and Android open google.com.

            Source https://stackoverflow.com/questions/68089507

            QUESTION

            Revolut visa Debit card not detected by libnfc6
            Asked 2021-Apr-08 at 08:03

            Trying to read various payment cards using PN532 NFC RFID Module. libnfc6 sucessfully polls most of the nfc cards and even mobile payment method is detected, but none of my Revolut cards are detected by nfc-poll app.

            libnfc was compiled locally from libnfc-1.8.0 git tag.

            My current polling setup:

            ...

            ANSWER

            Answered 2021-Apr-08 at 08:03

            Buying new PN532 NFC RFID Module solved the issue.

            Source https://stackoverflow.com/questions/66868180

            QUESTION

            Passing RFID data from iPhone to a RC522
            Asked 2021-Jan-10 at 23:49

            I currently have a Mifare RC522 module that I can use to successfully read/write to tags and cards, but I cannot successfully get it to read data that I am writing through an NFC phone app. Simply trying to get the RC522 module to read the data on the iPhone by bringing it close just brings up the Apple Pay menu. Is there something I am doing wrong? Does the data need to be encoded in a certain way or would that module just be useless and I'd probably need something like a PN532? I basically just want a module that can read NFC data I broadcast from an iPhone/Android device

            ...

            ANSWER

            Answered 2021-Jan-10 at 23:49

            In NFC comms there 2 parts, an initiator (more general term as a reader) and a target (more general term of Tag/Card) and passive and active devices.

            The initiator start the communication and the target responds.

            An Active device has power and a passive device does not supply it's own power.

            Passive devices cannot be initiator's because they need power to start the communication and might need to supply power to the target device.

            So a normal NFC Tag like an NTAG 21x tag is a passive target.

            A device like the iPhone/Android at the hardware level capable of being initiator and target device and can supply power to passive devices.

            The RC522 Module is only an initiator device and can supply power to passive devices.

            Devices like the iPhone/Android when they act as a target device (Tag/Card) this is called Host Card Emulation or HCE (they are emulating the Card hardware in software).

            So as the RC522 is only an initiator (reader) the other device has to be the target.

            Unfortunately in iOS only Apple are allowed to do Host Card Emulation (be a target) for Apple Pay where they pretend to be contactless bank card to contactless bank terminals which are only initiator's.
            This is why Apple Pay appears because this is the only way it can respond to an initiator.

            On Android it is possible for normal developers to use Host Card Emulation.

            So basically what you are trying is not possible with the RC522 reader and iPhones.

            So yes it would be possible with a PN532 because that chip offers card emulation modes on chip or pass through mode where the Host Card is emulated on the attached micro controller. This is because the iPhone for a normal developer can only be a reader (initiator) device.

            Source https://stackoverflow.com/questions/65659037

            QUESTION

            How does the NDEF Header work when the Payload is bigger than 1 Byte?
            Asked 2020-Sep-17 at 05:24

            I am trying to understand how a Mifare Ultralight Chip, I've got, works. This page pretty much explains it for normal circumstances: https://learn.adafruit.com/adafruit-pn532-rfid-nfc/ndef (At the very end of the page)

            But now I have the problem that I want to write data on the chip that is bigger than 254 Byte. As an example, I am writing 493 'A's on it (With the 7 Byte Header, the Data will be 500 Byte overall). Here's what I get from reading the chip (the numbers are in decimal, not hex, so instead of '0xFF' it will say '255'):

            ...

            ANSWER

            Answered 2020-Sep-16 at 12:56

            This is difficult to answer without the exact chip type and then examining it's datasheet.

            But I think you are probably getting confused by reading the information from Adafruit as is not the full specification of all the possibilities and it is for a Mifare Classic 1K Card which is not a NFC Standard Type chip and not the same as an Ultralight . How a NDEF message is put on this chip is propitiatory for Classic cards and is fully detailed at https://www.nxp.com/docs/en/application-note/AN1304.pdf

            For an Utralight chip are compatible with NFC Type 2 specification, details how it is compatible is at https://www.nxp.com/docs/en/application-note/AN1303.pdf

            For the full NFC Type 2 Spec is available at http://apps4android.org/nfc-specifications/NFCForum-TS-Type-2-Tag_1.1.pdf

            The full NDEF spec is also available at https://github.com/haldean/ndef/blob/master/docs/NFCForum-TS-NDEF_1.0.pdf

            So there are number of factors that will affect the size calculation including Short of Standard Records, Chunking, etc.

            Hopefully if you read all the correct documentation you will be able get an answer as that Adafruit link is not right for your chip and a very simplified explanation.

            Also note that writing the numbers in Decimal not the standard Hex make it a very difficult read as most specs are detailed in Hex.

            Source https://stackoverflow.com/questions/63916741

            QUESTION

            NFC Mifare Desfire Memory block structure
            Asked 2020-Jun-15 at 21:16

            I'm trying to understand the Mifare EEPROM memory structure. I found out this guide which was quite helpful. In below it covers the Memory block structure:

            1K Cards - 16 sectors of 4 blocks each (sectors 0..15)

            4K Cards - 32 sectors of 4 blocks each (sectors 0..31) and 8 sectors of 16 blocks each (sectors 32..39)

            It covers only the classic series and I'm not sure if it is identical for the Desfire series Memory block structure.

            Also, I want to use Desfire 8K cards and don't know how many 4blocks and 16blocks sectors it has. I tried to read the official datasheet but I couldn't understand this part.

            ...

            ANSWER

            Answered 2020-Jun-15 at 18:41

            The Mifare Desfire series of products don't have any block structure you can access, they are type 4 NFC cards.

            Type 4 cards use Command application protocol data unit (C-APDU) and a file type structure to save data.

            See the NFC Type 4 spec at http://apps4android.org/nfc-specifications/NFCForum-TS-Type-4-Tag_2.0.pdf and the Datasheet for a Desfire (EV3) card https://www.nxp.com/docs/en/data-sheet/MF3DHx3_SDS.pdf

            That guide is specific to the Mifare Classic series of Cards

            Source https://stackoverflow.com/questions/62310805

            QUESTION

            "Time Out, the target has not answered" from ACR122U reader with Jewel/Topaz512 NFC tags
            Asked 2020-Apr-22 at 15:33

            I am building a Windows/Java program (using javax.smartcardio) to communicate with Jewel/Topaz512 tags (from Innovision/Broadcom) using an ACR122U device (with a PN532 NFC Controller chip inside).

            I implemented the Topaz512 protocol (from this data sheet) but only half of my commands are working.

            • Some commands that work: RID, RALL, READ, WRITE-NE, RSEG
            • Some commands that don't work: WRITE-E, READ8, WRITE-E8, WRITE-NE8
            Example with the WRITE-NO-ERASE command

            For instance, here is what I get when I send a WRITE-NO-ERASE command:

            Command: FF:00:00:00:0C:D4:40:01:1A:7F:42:38:01:9A:00:17:E8

            Where:

            • D4:40:01 is the InDataExchange command,
            • 1A:7F:42 is the WRITE-NO-ERASE command (value: 0x42, block 0x0F, byte 7),
            • 38:01:9A:00 is the 4-bytes tag UID,
            • 17:E8 is the CRC.

            Response: D5:41:00:42:90:00

            Here the response is correct: 0x42. The status byte (0x00) informs that everything went well.

            Example with the WRITE-WITH-ERASE command

            And here is what I get when I send a WRITE-WITH-ERASE command:

            Command: FF:00:00:00:0C:D4:40:01:53:7F:42:38:01:9A:00:28:6E

            Where:

            • D4:40:01 is the InDataExchange command,
            • 53:7F:42 is the WRITE-WITH-ERASE command (value: 0x42, block 0x0F, byte 7),
            • 38:01:9A:00 is the 4-bytes tag UID,
            • 28:6E is the CRC.

            Response: D5:41:01:90:00

            Here, the status byte (0x01) informs of a timeout detected by the PN532. (From the PN532 documentation (p67): "Time Out, the target has not answered - 0x01")

            Also when I remove the PN532 timeouts (with FF:00:00:00:06:D4:32:02:00:00:00) non-working commands do not respond D5:41:01:90:00, but wait longer, then I get no response.

            Edit 2020-04-20

            I just tried to execute the commands using gscriptor (from the pcsc-tools suite) and I got the same behavior. Here are my results:

            The script:

            ...

            ANSWER

            Answered 2020-Apr-22 at 15:33

            Some time ago I looked into this in detail and concluded that the PN532 NFC controller chip from NXP has an issue with its firmware that prevents it from successfully transceiving some commands with NFC Forum Type 1 tags (Topaz/Jewel brands). The ACR122U is based on this chip as noted.

            When I tried to write 8 byte blocks at a time using the WRITE-E8 (0x54) command, the response received is 0x01, a timeout waiting for the tag to respond.

            Things I tried that don't work:

            Including the UID echo in the InDataExchange, I even played with the endianness of the UID echo and still the same result.

            Using the inCommunicateThru command rather than InDataExchange and calculating the CRC1 and CRC2 values at the application level (same results)

            The final conclusion I reached is:

            The PN532 cannot write to pages 0x10 and greater on a Type 1 tag which makes it impossible to write to the full range of memory on popular models such as the Topaz 512.

            Recommendation:

            This issue was relevant in 2012 when the Topaz 512 was a great low cost yet high memory NFC tag. Now that there's the NAG215 and NTAG216 models, I recommend using those models that have high memory and universal compatibility with NFC readers.

            Source https://stackoverflow.com/questions/61275660

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pn532

            You can download it from GitHub.
            You can use pn532 like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/hoanhan101/pn532.git

          • CLI

            gh repo clone hoanhan101/pn532

          • sshUrl

            git@github.com:hoanhan101/pn532.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link