diff --git a/pytikitag/nfc/ndef.py b/pytikitag/nfc/ndef.py index 870095a..aef0449 100644 --- a/pytikitag/nfc/ndef.py +++ b/pytikitag/nfc/ndef.py @@ -2,9 +2,6 @@ from smartcard.util import toASCIIString class NDEFReader(): - _records = [] - items = [] - _uri_lookup = { 0x00: "", 0x01: "http://www.", 0x02: "https://www.", 0x03: "http://", 0x04: "https://", 0x05: "tel:", 0x06: "mailto:", 0x07: "ftp://anonymous:anonymous@", @@ -36,6 +33,9 @@ class NDEFReader(): def __init__(self, ndef): + self._records = [] + self.items = [] + if not ndef: raise ValueError diff --git a/pytikitag/nfc/type2.py b/pytikitag/nfc/type2.py index 077010c..ef7387a 100644 --- a/pytikitag/nfc/type2.py +++ b/pytikitag/nfc/type2.py @@ -2,10 +2,10 @@ import ndef class NFCType2(): - tags = [] - ndefs = [] - def __init__(self, data): + + self.tags = [] + self.ndefs = [] if not data: raise ValueError diff --git a/pytikitag/tikitag.py b/pytikitag/tikitag.py index 1bb9d33..ea64112 100644 --- a/pytikitag/tikitag.py +++ b/pytikitag/tikitag.py @@ -5,7 +5,7 @@ from smartcard.util import toHexString, toASCIIString class TikiTag(mifareul.MiFareUltralight): _tag = None - _uid = None + _uid = "" def get_uid(self): @@ -15,27 +15,15 @@ class TikiTag(mifareul.MiFareUltralight): uid = toHexString(d).replace(" ", "")[:16] return uid - - def _check_uid(self): - uid = self.get_uid() - if (not self._uid == uid): - self._tag = None - self._uid = uid - return False - else: - return True - + def get_tag_url(self): """ Retreives the tag's URL stored in NDEF format """ # The tikitag usually has a single NDEF with a single URI record type # so assumptions can be made here. - - self._check_uid() - - if not self._tag: - d = self.read_tag() - self._tag = type2.NFCType2(d) + + d = self.read_tag() + self._tag = type2.NFCType2(d) return self._tag.ndefs[0].items[0][1]