= Come creare un totem NFC =
L'obiettivo è creare una macchina in grado di far scrivere agli utenti i propri dati all'interno delle tessere NFC del Fusolab. <<BR>>
L'utente quindi deve compilare un form, fare click su "Submit" ed avvicinare una carta Mifare bianca ad uno scrittore di card.

== Requisiti ==

=== Hardware ===
  * Computer con linux 
  * lettore/scrittore NFC tipo [[http://www.robot-italy.com/it/pn532-nfc-rfid-controller-breakout-board-v1-3.html|PN532 NFC/RFID controller breakout board]] che si attacca via interfaccia USB/FTDI
 
=== Software === 
  * [[libNFC|http://www.libnfc.org/documentation/introduction]] 
  * [[nfc-tools|http://code.google.com/p/nfc-tools/]] 
  * [[libNDEF|http://code.google.com/p/libndef/]] 

Le prime sono librerie per NFC (ma va'?) ed utility grezze. NFC-tools sono utility più evolute (tipo fai delle azioni quando ti si avvicina una carta) e sfruttano le libNFC. LibNDEF sono delle librerie per scrivere messaggi NDEF, leggibili ad esempio con i cellulari e tablet.

  * apache2
== Il programma ==
Questo è il CGI che viene chiamato quando si fa il submit

{{{
!#/bin/bash
nfc-events con questo file di configurazione
}}}


'''nfc-eventd.conf''
{{{
# Sample nfc-eventd configuration file
#
nfc-eventd {
	daemon = false;
	debug = true;
	polling_time = 1;
	expire_time = 30;
	
	device my_touchatag {
		driver = "ACR122";
		name = "ACS ACR 38U-CCID 01 00";
	}

	device my_pn532_uart {
		driver = "PN532_UART";
		port = "/dev/ttyS0";
		speed = 115200;
	}

	# which device to use ? note: if this part is commented out, nfc-eventd will try to pick up device automagically...
	#nfc_device = "my_touchatag";

	# list of events and actions
	module nem_execute {
		# Tag inserted
		event tag_insert {
			# what to do if an action fail?
			# ignore  : continue to next action
			# return  : end action sequence
			# quit    : end program
			on_error = ignore ;
	
			# You can enter several, comma-separated action entries
			# they will be executed in turn
			action = "(echo -n 'Tag (uid=$TAG_UID), inserted at: ' && date) >> /tmp/nfc-eventd.log";
		}
	
		# Tag has been removed
		event tag_remove { 
			on_error = ignore;
			action = "(echo -n 'Tag (uid=$TAG_UID) removed at: ' && date) >> /tmp/nfc-eventd.log";
		}
	
		# Too much time card removed
		event expire_time { 
			on_error = ignore;
			action = "exit";
		}
	}

}

}}}