xNT Implant and NDEF

I can’t seem to figure out how to get a website onto my xNT. I have a arduino nano with the PN532, but I cant find anything to format to NDEF. The PN532 Library has a thing that allows you to make a mifare tag into NDEF, which I was able to do with another tag that came with it. But it doesn’t work with the xNT implant.

By “website” I assume you mean a URL.

Any reason not to just use a phone to write to it?

NDEF is simply an “envelope” around data that you store on a tag. You don’t convert a tag to NDEF but you can write NDEF records to it. The NFC tools app can do this very easily.

Did you buy the PN532 from DT or from somewhere else? The reason I ask is because there are fake ones out there and they have VERY poor coupling performance to the xNT.

1 Like

So, I could just borrow a buddies phone for it simply because I have an iPhone that only reads. The PN532 that I have is from DT. I guess by the way I was interpreting some of the information online I assumed it was a conversion type deal. Not sure why, but then again I am pretty new to this stuff still. Would you mind recommending an app for this?

NFC Tools and NXP Tag Writer are the two main ones I know of, NXP Tag Info is good to have as well. I think it gives you more info about a tag than others, but doesn’t write.

2 Likes

I’m also trying to figure this out since I don’t have an android phone. I’m able to read my tag, and write 0x00s to the user space, but the adafruit libraries don’t have a code example that works for writing ndef tags to the xnt from what I can tell. This is the closest thing:

But the xnt doesn’t seem to be a mifare classic, so it doesn’t work. I imagine the code wouldn’t have to modified much to get it to work, but I don’t know anything about the architecture of the XNT. What’s different about it from a mifare classic?

If you grab the latest Adafruit PN532 library from Github, there’s examples in there for reading, writing, erasing NTAG 203 / 213 tags.

Use those libraries, but you’ll need to modify them for the NTAG 216 which is in the xNT. The primary difference is the 216 is just bigger, so you have more space to work with. The 203 / 213 has much smaller memory, but it’s the same family as the xNT.

The Mifare stuff is just totally different.

Yes that’s what I’m using… I’m able to read and write my xnt… but what I’m unsure of is how to write an ndef formatted tag to it. The updatendef example in that library for ntag2xxx it tells me my card isn’t formatted for ndef yet… but there’s no formatting example for ntag2xxx.The only example in that library of that is the one I linked above… but it’s for the mifare classic. Do you know how I might modify the example I linked above to work with the 216? Or otherwise do you know what I need to do to put ndef formatted data using those examples?

The NTAG 213 / 215 / 216 all have the same capabilities, but with different amounts of memory. But the differing memory sizes means that the bits for certain areas, such as the read/write protection and lock bits are located on different pages depending on the chip. Be very careful when using scripts written for a different 21x chip; especially if it is issuing WRITE commands. What is user data on one chip could write to the configuration or lock bits on a different chip.

I think you might mean that the Mifare Classic is totally different. Mifare is a general purpose name for many of the NFC NXP chips. They all have the same general capabilities. The Mifare Ultralight is a family of Mifare chips that don’t have any encryption key capabilities. The Mifare Ultralight EV1 is what the chip inside the xNT conforms too.

The Mifare Classic chips have basic cryptographic security in the form of one or two programmable keys that can be set. Most of the Mifare Ultralight commands will work on Mifare Classic chips, but the memory map is different.




If you don’t have access to an Android phone, there are a number of desktop apps and libraries that will work. I don’t have any experience with the Arduino boards or libraries, but setting up a desktop reader is simple. I’d recommend the ACR122U reader; specifically one manufactured by ACS (there are many third-party companies that sell re-branded ACR 122u’s but I’ve heard of reliability issues). You can pick one up from Amazon for $40. The one I use has good read range on my xNT.

As for software, SpringCard has a great PC/SC SDK available for free. The SDK includes a number of pre-built applications you can run, including one called NfcTool for reading/writing NDEF records. The binaries are Windows only though, but I’m sure there are similar tools for Apple. the ACR 122u should work out of the box on Windows 10 and OS X, Linux requires a little bit of setup but not hard.

I plan on releasing a cross-platform command line tool that will configure the NTAG 216 in a manner similar to what the DangerousThings Android app does, although I plan on having additional options. Before writing anything to the tag, I would strongly recommend using the DangerousThings Android app. Out-of-the-box there are memory areas on the NTAG 216 which can only be written to once (write-once blocks) and if the wrong ones are set, you can permentnly lock your tag into read-only mode.

2 Likes

I appreciate all that information, and setting up a usb reader could be interesting, but I already have this microcontroller based one which is more relevant to my general use-cases with this chip.

I’m assuming someone has formatted the xnt for ndef, really it’s just some technical information I’m in need of.

Hopefully @RealVioletWitch @amal or someone else on the forum has some example code. Or if not example code, the tech details on what bytes need to be written as what for ndef would probably be enough to get it done. If I get this working I’ll issue a pull request on the adafruit library so that hopefully others won’t run into this same issue!

Hi @jmej it’s been several years since I played with these libraries and my memory is bad, so I’m rereading the code and all. You are right about the library and example being not great.

Looking at this stuff I rememeber now that there was a lot of pouring over the datasheets for the NTAG and NDEF specifications to try and figure out how to write tags that would be properly readable.

The library let you basically write to all the accessable memory, including the pages that are required for the NDEF formatting. And if your tag hasn’t been ‘secured’ with the DT android app, then those libraries might let you write to the ‘dangerous’ areas too which could brick your tag. So do be careful.

As far as the xNT being ‘preformatted’, when brand-new it does not have any NDEF record in it. The CC should be set correctly but there probably isn’t an empty NDEF message in there.

Having said all that, I am pretty sure that the ntag2xx_updatendef example should work for you. The error it’s giving you about the tag not being an NDEF tag, is probably ‘wrong’. It’s reading page 3 (capability container) and finding something there it does not expect.

Both my xNTs have page 03 starting E1 12 and the arduino code seems to want E1 10, so that might be where it’s tripping up. Edited to add: Byte 1 is the ‘version number’ so where the adafruit library is looking for version ‘0x10’ the xNT is version ‘0x12’. This shouldn’t be a problem and is easily fixed by changing the example code.

You mentioned you can read the implant. Could you use the ntag2xx_read example and share with us pages 02 through 04, as well as E0 through E6? Or just the whole thing if it doesn’t contain anything sensitive I guess. So we can be sure of what state the tag is in right now, then we can work out the arduino code to get you where you want to be.

2 Likes

Yes, thank you! That was exactly the missing information I needed! I have now successfully written an ndef record to my implant! Here are the details for the curious and the next folks to come along. Also for those coming later, certainly before trying anything I did run the dangerous things protection app.

When initially tried to run the ntag2xx_updatendef example I was getting this error:

Seems to be an NTAG2xx tag (7 byte UID)
This doesn’t seem to be an NDEF formatted tag.
Page 3 should start with 0xE1 0x10

And @RealVioletWitch was right pg 3 starts with E1 12 on mine. All the pages after 3 are were 0s because I had successfully run thentag2xx_erase example.

There is a conditional in the ntag2xx_updatendef example that needs page 3 to be E1 10… so as per @RealVioletWitch’s recommendation I changed that to accept for byte 1 to be 12 which seems to be the xNT version number.

old code - was line 170 in mine:
if (!((data[0] == 0xE1) && (data[1] == 0x10)))
new code:
if (!((data[0] == 0xE1) && (data[1] == 0x12)))

That did the trick, and I got a url read with my iphone from my xnt.

Thanks so much!

3 Likes

Glad you got it working!

Also for future reference / anyone else looking into this stuff: I did some more reading and digging this morning and it looks like the Adafruit library was made to support the NTAG203s that they sell, which conform to the 0x10 version.

There are some other limitations with these libraries. The main one being, as they were written for an NTAG203 with like, 144 bytes of space or thereabouts, the library doesn’t really have access to the full size of the xNT’s memory. (Comments in the examples mention this, but the examples do not fully take into account these differences.)

Eg some values in the examples are using an 8-bit integer (for determining memory size) that’s ok for the smaller 203 tag but will overflow on the xNT. (eg. the ‘dataLength’ variable is only 8-bits, so when it tries to read the xNT’s CC for data size, 110, x 8 bytes, that overflows and I think you end up with 112 bytes instead of 880 bytes).

For a protected tag that shouldn’t be a problem, the worst it could do is limit you to only accessing part of the xNT’s memory.

The ntag_read and ntag_erase examples are both coded for a 203, so they assume the tag is 42 pages long and ignore everything else.

Not trying to scare people or dis some free tools Adafruit has provided, just saying, its best to know what you’re doing when using these tools.

Cheers!

2 Likes

That all makes a lot of sense. Thanks for the info!