mirror of
https://github.com/nikdoof/pytikitag.git
synced 2025-12-13 05:02:17 +00:00
Fixed issues with tag not being re-read properly.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ import ndef
|
||||
|
||||
class NFCType2():
|
||||
|
||||
tags = []
|
||||
ndefs = []
|
||||
|
||||
def __init__(self, data):
|
||||
|
||||
self.tags = []
|
||||
self.ndefs = []
|
||||
|
||||
if not data:
|
||||
raise ValueError
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user