Skip to content

Commit

Permalink
apply factory default format for completely blank NTAG tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nehpetsde committed Nov 10, 2016
1 parent 3d25340 commit 502ef94
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions nfc/tag/tt2_nxp.py
Expand Up @@ -294,6 +294,13 @@ def _protect(self, password, read_protect, protect_from):
except tt2.Type2TagCommandError: pass
return False

def _format(self, version, wipe):
if self.ndef is None:
log.debug("no management data, writing factory defaults")
self.write(4, b'\x01\x03\xA0\x10')
self.write(5, b'\x44\x03\x00\xFE')
return super(NTAG203, self)._format(version, wipe)

class NTAG21x(tt2.Type2Tag):
"""Base class for the NTAG21x family (210/212/213/215/216). The
methods and attributes documented here are supported for all
Expand Down Expand Up @@ -484,6 +491,13 @@ def __init__(self, clf, target):
self._product = "NXP NTAG210"
self._cfgpage = 16

def _format(self, version, wipe):
if self.ndef is None:
log.debug("no management data, writing factory defaults")
self.write(4, b'\x03\x00\xFE\x00')
self.write(5, b'\x00\x00\x00\x00')
return super(NTAG210, self)._format(version, wipe)

def dump(self):
footer = dict(zip(range(16, 20),
("MIRROR_BYTE, RFU, MIRROR_PAGE, AUTH0",
Expand All @@ -500,6 +514,13 @@ def __init__(self, clf, target):
self._product = "NXP NTAG212"
self._cfgpage = 37

def _format(self, version, wipe):
if self.ndef is None:
log.debug("no management data, writing factory defaults")
self.write(4, b'\x01\x03\x90\x0A')
self.write(5, b'\x34\x03\x00\xFE')
return super(NTAG212, self)._format(version, wipe)

def dump(self):
text = ("LOCK2-LOCK4", "MIRROR_BYTE, RFU, MIRROR_PAGE, AUTH0",
"ACCESS", "PWD0-PWD3", "PACK0-PACK1")
Expand All @@ -517,6 +538,13 @@ def __init__(self, clf, target):
self._product = "NXP NTAG213"
self._cfgpage = 41

def _format(self, version, wipe):
if self.ndef is None:
log.debug("no management data, writing factory defaults")
self.write(4, b'\x01\x03\xA0\x0C')
self.write(5, b'\x34\x03\x00\xFE')
return super(NTAG213, self)._format(version, wipe)

def dump(self):
text = ("LOCK2-LOCK4", "MIRROR, RFU, MIRROR_PAGE, AUTH0",
"ACCESS", "PWD0-PWD3", "PACK0-PACK1")
Expand All @@ -534,6 +562,13 @@ def __init__(self, clf, target):
self._product = "NXP NTAG215"
self._cfgpage = 131

def _format(self, version, wipe):
if self.ndef is None:
log.debug("no management data, writing factory defaults")
self.write(4, b'\x03\x00\xFE\x00')
self.write(5, b'\x00\x00\x00\x00')
return super(NTAG215, self)._format(version, wipe)

def dump(self):
text = ("LOCK2-LOCK4", "MIRROR, RFU, MIRROR_PAGE, AUTH0",
"ACCESS", "PWD0-PWD3", "PACK0-PACK1")
Expand All @@ -551,6 +586,13 @@ def __init__(self, clf, target):
self._product = "NXP NTAG216"
self._cfgpage = 227

def _format(self, version, wipe):
if self.ndef is None:
log.debug("no management data, writing factory defaults")
self.write(4, b'\x03\x00\xFE\x00')
self.write(5, b'\x00\x00\x00\x00')
return super(NTAG216, self)._format(version, wipe)

def dump(self):
text = ("LOCK2-LOCK4", "MIRROR, RFU, MIRROR_PAGE, AUTH0",
"ACCESS", "PWD0-PWD3", "PACK0-PACK1")
Expand Down

0 comments on commit 502ef94

Please sign in to comment.