4 import nfc.tag.tt1_broadcom
8 import nfc.tag.tt3_sony
12 from nfc_ros.msg
import Tag
13 from nfc_ros.msg
import NDEFRecord
23 self.
pub_tag = rospy.Publisher(
'~tag', Tag, queue_size=1)
24 rospy.loginfo(
'Initialized')
28 rospy.loginfo(
'tag: {}'.format(tag))
31 if type(tag.identifier) == bytes:
32 msg.identifier = tag.identifier.hex()
34 msg.identifier = tag.identifier
36 if type(tag) == nfc.tag.tt1.Type1Tag:
37 msg.tag_type = Tag.NFC_TAG_TYPE1TAG
38 elif type(tag) == nfc.tag.tt2.Type2Tag:
39 msg.tag_type = Tag.NFC_TAG_TYPE2TAG
40 elif type(tag) == nfc.tag.tt2_nxp.NTAG215:
41 msg.tag_type = Tag.NFC_TAG_TYPE2NXPNTAG215
42 elif type(tag) == nfc.tag.tt3.Type3Tag:
43 msg.tag_type = Tag.NFC_TAG_TYPE3TAG
44 elif type(tag) == nfc.tag.tt3_sony.FelicaStandard:
45 msg.tag_type == Tag.NFC_TAG_FelicaStandard
46 elif type(tag) == nfc.tag.tt3_sony.FelicaMobile:
47 msg.tag_type == Tag.NFC_TAG_FelicaMobile
48 elif type(tag) == nfc.tag.tt3_sony.FelicaLite:
49 msg.tag_type == Tag.NFC_TAG_FelicaLite
50 elif type(tag) == nfc.tag.tt3_sony.FelicaLiteS:
51 msg.tag_type == Tag.NFC_TAG_FelicaLiteS
52 elif type(tag) == nfc.tag.tt3_sony.FelicaPlug:
53 msg.tag_type == Tag.NFC_TAG_FelicaPlug
54 elif type(tag) == nfc.tag.tt4.Type4Tag:
55 msg.tag_type = Tag.NFC_TAG_TYPE4TAG
56 elif type(tag) == nfc.tag.tt4.Type4ATag:
57 msg.tag_type = Tag.NFC_TAG_TYPE4ATAG
58 elif type(tag) == nfc.tag.tt4.Type4BTag:
59 msg.tag_type = Tag.NFC_TAG_TYPE4BTAG
61 rospy.logerr(
'Unknown tag type: {}'.format(type(tag)))
64 if tag.ndef
is not None:
65 for record
in tag.ndef.records:
66 ndef_record = NDEFRecord()
67 ndef_record.type = record.type
68 ndef_record.name = record.name
69 ndef_record.data = record.data.decode()
70 msg.ndef_records.append(ndef_record)
77 while not rospy.is_shutdown():
def publish_tag(self, tag)