====== Collecting Data using RFID/NFC Tokens ====== This application note provides a more complete scenario of a personal visitor experience. This example is based solely on tokens such as RFID or NFC tags, bracelets or cards for visitor identification. The visitor receives such a token during check-in, possibly along with registering some basic information such as name and email. The token is then returned when the visitor leaves. :!: **NOTE:** While you can use this application note as-is without any programming knowledge, you will need programming knowledge in order to enhance it and adapt it to your own needs. ==== Stations ==== This is still a rather easy-to-follow example, based on a small number of stations: * **Reception** where visitors check in and receive their ID tokens. * **InfoStation** provides some information that will be useful at the next station. This information can only be viewed once. * **QuizStation** presents a simple quiz game where a game score is collected. In order to play the quiz, the visitor must first have been at the InfoStation. * **GoodByeStation** where visigors check out, and view some results of their visit, including a game high-score for the quiz. ==== Library Support ==== This example introduces the concept of library support classes, implementing much of the basic functionality that tends to be common, such as: * Keeping track of who's where, and responding when visitors arrive and leave stations. * Collection, presentation and persistence of aggregate data (here the high-score list of the game). * Integrating token and phone identification, allowing you to combine both if desired. ==== Data Collected ==== As usual, the data collected is defined as a //Record//: @record("Data we track for each visitor") class BasicTagOnlyData extends RecordBase implements VisitorRecordBase { @id() idCode: string; // RFID associated with this record @field() name: string; // Name provided by visitor @field() currentStation: string; // Curently (or last) visited station @field() whenJoined: number; // Timestamp when first connected @field() email: string; // Email address @field() briefed: boolean; // The visitor has been briefed at the info station @field() quizScore: number; // Score frmo Quiz game (except how tall speaker is) @field() speakerTall: number; // How tall the speaker is @field() totalScore: number; // Final score total } Note the following: * The data record declaration is decorated with //@record()//, which makes this known under its type name to Blocks. * The data record, here named BasicTagOnlyData is based on the //RecordBase// type, which all data records must extend. * It also implements some additional fields expected by the library support classes, defined by the //VisitorRecordBase// class. * Each custom field in the record is marked either by @id() – if it's a unique key by which the data can be retrieved – or by @field() if it's a plain data field. * Fields must be of a primitive type (string, number or boolean). If you open the project's code in a [[blocks:drivers:tools|code editor]] you can navigate to base classes and interfaces by Control- or Command-clicking the name in the editor. ===== Installation ===== You need a computer running the Blocks server software and a four display spots (preferably based on [[blocks:player-setup|PIXILAB Player]]) to use this application note. Your Blocks server must also have the additional Visitor Data Collection license (you can check this under Manage/Licenses). There's a complete PIXILAB-blocks-root folder containing everything you need to run this application note. Download this {{:blocks:app-note:visitor:basictagonly.zip|ZIP file}} and follow the in the [[blocks:app-note:start|general setup instructions]] to get up and running. ===== Running the Application ===== Then follow these steps to run this application. - Start Blocks. - Open the editor using the Admin button. - Log in using the name admin and the password pixi. - Connect four Display Spots, running on PIXILAB Player or equivalent, corresponding to each of the four stations mentioned above. - Connect an RFID or NFC reader to the USB port of each of those players. - Assign those players to each of the corresponding Display Spots in the Spot list. - Scan a suitable RFID or NFC token at the Reception station to start the visit. - Try out each of the stations, with the //GoodByeStation// last. - Other visitors can sign in using individual ID tokens. ==== The Script ==== The script defining the data record as well as how data is collected and used can be found at script/user/BasicTagOnly.ts. You need to have the recommended set of [[blocks:drivers:tools|development tools]] (or equivalent) to check out or modify this example.