Documentation ¶
Overview ¶
Package swtag provides a CommandDriver implementation which acts as a binary interface to software-based NFC Type 4 Tags which implement the tags.Tag interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
Driver implements a CommandDriver to interface with a software tag (something that implements the Tag interface from the tags module).
This means that this driver provides the binary channel to those tags.
Among its applications, is the easily test that a software Tag conforms to the NFC Type 4 Tag specification, by attaching this driver to a `nfctype4.Device` with, and performing the Device operations on the Tag.
The second application is to simulate a NFC Type 4 with a hardware NFC reader. Libnfc, for example, allows to initialize NFC Readers in Target mode, where the Libnfc device behaves like a tag rather than a reader. This driver makes it trivial to provide a libnfc device in Target mode with full-fledged Type 4 Tag behaviour.
An example of how this is done can be seen visiting the following snippet: https://gitlab.com/snippets/18718
func (*Driver) Initialize ¶
Initialize does nothing because software Tags don't need initialization.
func (*Driver) TransceiveBytes ¶
TransceiveBytes parses the tx bytes to a Command APDU and uses the Tag to process the APDU and provide a Response APDU, which is in turn serialized and returned.
It returns an error if the Tag field has not been set, if the APDUs cannot be serialized or deserialized, or if the response size is bigger than the expected size.