Implementing NFC scanner

Currently NFC scanning is not possible using the Perspective app, there has been a ticket since 2020 and no timetable for this feature.
I have succesfully created a work around for android devices

Requirement:

NFC Tools: App is used for actively scanning NFC/RFID tags
NFC Tasks: App is used for executing tasks stored on the NFC/RFID tag
NFC Tools - Pro Edition: App needs to be purchased for creating HTTP REST tasks, only required on a single device and not all readers

The Tag required for my case is limited to 106 writeable bytes so i have to use some variables:

Define a HTTP Post task:

  • {VAR_INP} hold the API endpoint
  • {TAGID} holds the ID of the tag as "98:38:4e:94:50:01:04:e0"
  • {VAR_U} Hold the username of the device, the IMEI/SIM returns "UNKNONW" and since only 106 bytes are available i have to use a variable.
  • Optionally the result can be stored in a variable for debugging

Variables are stored in the app NFC Tasks and could be altered by the user,

def doPost(request, session):
	# NFC Tools HTTP POST
	# ContentType "application/x-www-form-urlencoded"
	# First key in the 'request["params"]" is the actual json value	
	# Looks like a bug but it works
	json = system.util.jsonDecode(str(request["params"].keys()[0]))
	
	if 'tag' in json:
		system.tag.writeBlocking(["[default]NfcTag"], [json['tag']])
	if 'user' in json:
		system.tag.writeBlocking(["[default]NfcUser"], [json['user']])
	
	return {
		'json': 'ok'
	}

After a succesfull scan the values are written in two Tags and can be used within Perspective.

2024-10-07_08-59-48

Note: some tags IDS are limited by their byte size and duplicates are already on the market.

2 Likes