Book Image

Near Field Communication with Android Cookbook

By : Vitor Subtil
Book Image

Near Field Communication with Android Cookbook

By: Vitor Subtil

Overview of this book

Table of Contents (17 chapters)
Near Field Communication with Android Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Controlling hotel room access with Arduino and NFC – Part 1


Imagine you are at a hotel where each lock to the rooms is controlled by Arduino with an NFC shield. When you arrive at your room and place the NFC card against the reader, Arduino will validate if it is indeed the correct card before releasing the lock.

In this recipe, we will create an Android application to write the room number on an NFC card encrypted with an AES algorithm.

How to do it...

We will encrypt the room door (padded left with 0 to have 16 as the length) with a 32-bit key and save the result to the tag:

  1. Open Eclipse and create a new Android application project named NfcBookCh9Example5 and package named nfcbook.ch9.example5.

  2. Make sure the AndroidManifest.xml file is correctly configured. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.

  3. Add the following string to the res/values/strings.xml file:

    <string name="dialog_waiting_tag">Waiting tag...</string>
    <string name="label_aes_key...