NFC


In the Setup/Peripheral menu, after enabling SPI, NFC can be selected. Currently supported with MFRC522 reader for MIFARE Classic 1K card/keychain/sticker/bracelet (TAG). These TAGs have 1kB memory, divided into 15 sectors of 48 bytes each, NFC(1) - NFC(15).
Sectors can be protected with a PIN code against unauthorized access. It can be set up in the Setup/Peripheral menu, default: 000000. SEC is the default sector alongside. The PIN code must consist of exactly six digits. For newly purchased (~$0.5 - ~$3) TAGs, the PIN code is 000000. In this state, the TAG can be read and written with factory default settings, but it can be copied and modified using a simple mobile app. A sector protected by a PIN code is unusable without knowledge of the PIN. Each sector can contain a command and/or a string. Each TAG has a unique identifier (NUID) which can be queried even without knowledge of the PIN code.
Experience: NFC (13.56MHz), WiFi (2.4GHz) modules may cause interference, potentially destabilizing the WiFi connection. In such cases, the modules should be placed farther apart, in different positions, or shielded from each other.

NFC(1)
NFC(2)
The selected sector becomes active. Commands stored in this sector are executed when the TAG is read. Valid: 1-15 Default: Setup/Peripheral SEC
NFC(?)@
Sends the active sector number to STDOUT.

NFC:LED(TOGGLE);STR[0]@=BLOCK 1
Writes a command to the active sector to be executed when the TAG is read. Maximum length is 48 characters.
NFC(2):LED(FLASHI);STR[0]@=BLOCK 2
Writes the command to sector 2. The active sector remains unchanged.

STR[2]=Bob|
NUM[3]=28
NFC=Alice
NFC=STR[2]
NFC=NUM[3]
Writes a string to the active sector. Works only if the command stored in the sector has a maximum length of 32 characters. The string can be up to 15 characters long. The command in the sector can only write to its own sector! Example: NFC(1):NFC=STR[0].
NFC(2)=128
Writes the string to sector 2. NFC(1):NFC(2)=STR[0] is incorrect and does not work! The active sector remains unchanged.
NFC@
Sends the string stored in the last read sector to STDOUT.

NFC(2)OP000000NP123456
NFC(2)OP123456NP000000
NFC(sector)OPoldpinNPnewpin
Changes the PIN code of the sector. The active sector remains unchanged.

NFC(UID)@
Sends the last read TAG UID number to STDOUT.

NFC(DET):STR[0]@= DETECT %NUID
Executes the command when a TAG is detected.
NFC(ERR):STR[0]@=PIN ERROR!
Executes the command in case of an incorrect PIN code.

NFC(1)!
Clears the sector.



Examples

Writes on the card how many times it has been read.
NFC(1)=0|
NFC(1):NUM[1]=%NFC;NUM[1]@+1;NFC=NUM[1]