Description
Hello! Long time listener, first time caller.
I'm looking to add support to CircuitPython for the NFC tag functionality of the nRF52 devices. I've been using the functionality for a short while now in a personal project so I feel like I've got a fairly good understanding of how to bring it over to CP, at least in the sense of type 2 tags. Before I started, I wanted to flesh out a few details and ask some questions so that I can contribute in the best way possible.
Before I get to my questions, I want to touch on the current state of NFCT in the nRF5/nrfx SDK:
Current NFCT State
It looks like it was discussed and somewhat proposed to add some NFCT functionality to micropython, but that effort seems to have stalled, due to the use of the closed-sourced (but permissively licenced) T2T/T4T libraries. It doesn't sound like Nordic/ (or Telit, as the license references) intends to open source them any time soon.
The closed source nature of a library like that certainly raises valid concerns, especially if you're going to be using it to transfer any sort of sensitive information. It's for this reason I wanted to bring it up and see what you all thought of it before starting. If that seems like a non or acceptable issue, then leveraging those libraries are certainly going to be the quickest and most efficient way to implement NFCT functionality.
My NFCT Experience
Since I was looking to implement out of band behavior for the NFCT peripheral, my personal project didn't make use of those libraries. I took a different approach, reading different datasheets of NFC tag devices, and implementing behavior based on how I read their behavior to present. As I was dealing with type 2 tags, in particular, I was using mostly the NXP NTAG213/215/216 and MIFARE Ultralight C datasheets. As I haven't ponied up the money (yet) for the NFC Forum Type 2 Tag Specification or the ISO 14443A Specification, the 14443-A and Type 2 Tag information I've used has been limited to what I was able to reverse engineer using physical NTAG215s, and googling around. The same goes for the NDEF and TLV, though lady ada helped out there too, from seemingly a time before the NFC Forum charged for that specification as well.
All of that is to say, I'm fairly confident I can implement at least a Type 2 Tag style emulation, forgoing the use of the Telit blob if need be, but it is mildly "blind", as I don't own the specifications themselves.
Implementation Questions
Moving on to the actual nuts and bolts of actually implementing this functionality: As I mentioned before, I've not yet contributed to CircuitPython, but am eager to go about this the correct way. I see several paths forward, and want to make sure I choose the one that is the most useful for the project as a whole, as well as those who may want to use the functionality. So please point me at the way you think I should move forward here.
My belief is that the NFCT functionality should theoretically exist in two parts: one part as the actual HAL to the peripheral, and should perhaps live in something like it's own driver in circuitpython/ports/nrf/common-hal/, at least for the nRF device.
In parallel to the HAL, the NFC Tag emulation itself should exist higher in CP (something along the lines of shared-module
or shared-bindings
(though I don't quite understand the difference between those). This would allow future, non-nRF devices to share the common API for interfacing as an NFC Tag. This would also prompt the question of where the actual NFC Tag emulation driver would exist: if we decided to make use of the Nordic provided blobs (at least for now), it's clear they are hardware specific, though they don't fit the definition (at least in my view) of something that would belong in the HAL. Which leads into my next thought:
Now it also seems reasonable that the NFC Tag functionality could exist as a standalone driver like the ones you include in the bundles. However with my quick browsing through some of those, they seem to be pure python implementations, so I'm not sure where a (C/C++ based) HAL would live there.
Closing Thoughts
The NFCT functionality of the nRF platform is something I've definitely seen folks ask for, and think the potential for it could be wonderful. Especially with devices like makerdiary's upcoming CircuitPython based M60 Keyboard, I think now is a fantastic time to add this soft of functionality to CircuitPython. I hope this starts a good discussion and we can get the ball rolling! Thanks for reading all of my drivel!