Near Field Communication (NFC) Android München 21.3.2011 anselm@garbe.us



Similar documents
APPFORUM2014. Helping the developer community build next-generation, multi-platform apps. SCHAUMBURG, ILLINOIS SEPTEMBER 8-10

NFC in Android. Martijn Coenen

THE PRODUCT AUTHENTICATION APPLICATION DESIGN BASED ON NFC

Towards an Internet of Things: Android meets NFC. Dipartimento di Scienze dell Informazione Università di Bologna

DEVELOPING NFC APPS for BLACKBERRY

Mobile Payment using HCE and mpoint payment gateway based on NFC enabled phones. AUTHOR : GRZEGORZ MILCARZ S111040

NFC: Enabler for Innovative Mobility and Payment NFC: MOBILIDADE E MEIOS DE PAGAMENTO

AN How to build a NFC Application on Android. Application note COMPANY PUBLIC. Rev September Document information

NFC Test Challenges for Mobile Device Developers Presented by: Miguel Angel Guijarro

Using RFID/NFC and QR-Code in Mobile Phones to Link the Physical and the Digital World

Training MIFARE SDK. Public. MobileKnowledge June 2015

Touch'n'pay ein NFC Feldversuch. Dominik Gruntz Fachhochschule Nordwestschweiz Institut für Mobile und Verteilte Systeme

Using RFID Techniques for a Universal Identification Device

NFC TagWriter by NXP

Technical Article. NFiC: a new, economical way to make a device NFC-compliant. Prashant Dekate

Training. NFC in Android. Public. MobileKnowledge October 2015

Mobila applikationer och trådlösa nät

NFC Near Field Communication

Wireless IoT Technologies and Applications - Near Field Communication

Frequently Asked Questions

Mobile NFC 101. Presenter: Nick von Dadelszen Date: 31st August 2012 Company: Lateral Security (IT) Services Limited

Developing NFC Applications on the Android Platform. The Definitive Resource

NFC. Technical Overview. Release r05

}w!"#$%&'()+,-./012345<ya

AN1304. NFC Type MIFARE Classic Tag Operation. Application note PUBLIC. Rev October Document information

Android ( ) Frank Ducrest

AN1305. MIFARE Classic as NFC Type MIFARE Classic Tag. Application note COMPANY PUBLIC. Rev October Document information

NFC Tags & Solutions. Understanding Near Field Communication (NFC) Technology. Executive Summary

the future of mobile web by startech.ro

Store Logistics and Payment with Near Field Communication

NFC Hacking: The Easy Way

Application of Near Field Communication Technology for Mobile Airline Ticketing

Timo Müller NFC AND THE VEHICLE. TESTING THE LINUX NFC STACK. BMW Car IT GmbH

NFC, just a Payment Tool?

Relay Attacks in EMV Contactless Cards with Android OTS Devices

How to develop your own app

NFC Tags. A technical introduction, applications and products

NFC Momentum: Beyond the Killer App. Koichi Tagawa Sony Chairman, NFC Forum

Vulnerability Analysis and Attacks on NFC enabled Mobile Phones

An NFC Ticketing System with a new approach of an Inverse Reader Mode

Using an NFC-equipped mobile phone as a token in physical access control

Frameworks & Android. Programmeertechnieken, Tim Cocx

ECM (ELO-KIT-ECMG2-AND)

Android Basics. Xin Yang

Abracon PTM Introduction to ANFCA Series Flexible Peel & Stick NFC Antennas

@ME (About) Marcelo Cyreno. Skype: marcelocyreno Linkedin: marcelocyreno Mail:

Spring Design ScreenShare Service SDK Instructions

01. Introduction of Android

06 Team Project: Android Development Crash Course; Project Introduction

Contactless Payments with Mobile Wallets. Overview and Technology

NACCU Migrating to Contactless:

Training. MIFARE4Mobile. Public. MobileKnowledge April 2015

What Smartphones and Tablets are supported by Smart Measure PRO?

The Security Risks of Mobile Payment Applications Using Near-Field Communication

PN532 NFC RFID Module User Guide

SENSE: USER GUIDE. Read Me to Get the Most Out of Your Device...

An NFC Ticketing System with a new approach of an Inverse Reader Mode

How To Secure A Paypass Card From Being Hacked By A Hacker

Gemalto Mifare 1K Datasheet

Release Notes: Onsight Connect for Android Software Release Notes. Software Version Revision 1.0.0

ANDROID. Programming basics

Introduction to Android

Hacking the NFC credit cards for fun and debit ;) Renaud Lifchitz BT Hackito Ergo Sum 2012 April 12,13,14 Paris, France

Business through Mobile Phone initiated Near Field Communication

NEAR FIELD COMMUNICATION La rivoluzione dell RFID

NFC Based Equipment Management Inventory System

How to connect your D210 using Bluetooth. How to connect your D210 using GPRS (SIM Card)

NFC in Public Transport

CSE476 Mobile Application Development. Yard. Doç. Dr. Tacha Serif Department of Computer Engineering Yeditepe University

Mobile Application Marketplace 2015: Market Analysis and Assessment of Future Evolution and Opportunities

CHAPTER 7. Wireless Technologies and the Modern Organization

Nokia. udirect 2 Bluetooth pairing guide. Pairing and connecting udirect 2 with your Nokia cellular phone

Creating a List UI with Android. Michele Schimd

How to connect your D200 using Bluetooth. How to connect your D200 using GPRS (SIM Card)

Smartphone market share

Mobile Device Support Model

More information >>> HERE <<<

NFC Testing. Near Field Communication Research Lab Hagenberg. Gerald Madlmayr. NFC Research Lab, Hagenberg. E-Smart 2008, Sophia Antipolis

USING MIFARE CLASSIC TAGS VERSION

NFC Hacking: The Easy Way

The Impact of Emerging Payment Technologies on Retail and Hospitality Businesses. National Computer Corporation

Technical Manual Login for ios & Android

TUTORIAL FOR INITIALIZING BLUETOOTH COMMUNICATION BETWEEN ANDROID AND ARDUINO

Significance of Tokenization in Promoting Cloud Based Secure Elements

Near Field Communication in Cell Phones

Transcription:

Near Field Communication (NFC) Android München 21.3.2011 anselm@garbe.us

What is NFC? Short range (<4cm) wireless technology Operating rates: 108 kbit/s - 848 kibt/s Modes: Passive Communication: Initiator creates RF (radio frequency) field that powers target Active Communication: Initiator and target alter their own RF field depending on reading/writing Uses: Card emulation: device emulates contactless card Reader: device reads passive targets like RFIDs P2P: devices exchange information via a connection

RFID Tag reading.

RFID Tag writing Only some RFID tags are writable and/or killable

Card emulation Reading an emulated RFID Tag Bonding: Holding the devices close enough together

P2P Exchanging data through a P2P connection

Quick history Very first RFID (radio frequency identification) technology appeared during WW2 NFC developed by NXP (Philips), and Sony since 2002, ISO13157, ISO18092 NFC has been piloted back in 2007/2008 already, Nokia produced some NFC-enabled devices, some French operators and banks experimented with mobile payments in Carrefour supermarkets NFC has higher adoption rate in Asian countries like Japan, mainly for mobile payments and smart poster use

What happened recently? Nov 2010 Google announced android 2.3+ will have NFC support, and Nexus S features NFC device Dec 2010 Gingerbread SDK 2.3[{1,2}], contains basic API (almost all features usable through JNI though) Feb 2011 Gingerbread SDK 2.3.3 with extended API Feb 2011 OpenNFC announced android API (not usable) Upcoming NFC smartphones announced Samsung Galaxy S 2, Various HTC devices Apple iphone 5 (yes, no, maybe,???) Many RIM devices will feature NFC

What can we do with NFC? Mobile payments (rumors Google piloting this now) Electronic ticketing Electronic access control (doors, cars) Reading/Writing RFID Tags (URLs, Text, vcards, image data) Exchanging small data via P2P Establishing a Bluetooth connection or AdHoc WiFi connections through NFC bonding

Some application ideas Message in the bottle Geocaching tracker Speed dating app Make friends on the run (feed social networks) Social gaming (for example a Scoreloop challenge) bu.mp killer app IMHO: -> FUN and convenience apps for now... BUT will mobile payment apps succeed? Who knows...

android.nfc NfcManager: returns NfcAdapter NfcAdapter: controls NFC lifecycle of an activity enables/disables NDEF (NFC data exchange format) Tag pushing (for card emulation and P2P issuing) Current (2.3.3) limitations NDEF pushing can only be performed by foreground activities Rather low level NdefMessage/NdefRecord handling

android.nfc.tech TagTechnology: interface to Tag properties and I/O IsoDep: ISO 14443-4 MifareClassic: MIFARE Classic MifareUltralight: MIFARE Ultralight Ndef: NDEF content and operations on a Tag. NdefFormatable: NDEF format operations on a Tag. NfcA: NFC-A (ISO 14443-3A) NfcB: NFC-B (ISO 14443-3B) NfcF: NFC-F (JIS 6319-4) NfcV: NFC-V (ISO 15693)

android.nfc.tech (cont'd) Usual TagTechnology methods: Connection related: connect(), close(), isconnected() Properties related: gettag() Actual Tag (IdoDep, NfcA, etc) methods implement TagTechnology and also provide methods for: Data exchange: byte[] transceive(byte[] raw); Technology specific: getsak(), getatqa()

android.nfc where to look at first Getting started 1. Google's NFCDemo sample 2. Gingerbread source, Tag application 3. My examples perhaps ;) Advanced power users 1. Custom JNI code around libnfc-nxp 2. OpenNFC (if it works ;)) 3. http://rfidiot.org/ (tools, devices, non-android)

Using NFC/Receiving Tag intents Android.xml: <uses-permission android:name="android.permission.nfc" /> <uses-sdk android:minsdkversion="9" /> <uses-feature android:name="android.hardware.nfc" android:required="true" /> <activity android:name=".receiveractivity" > <intent-filter> <action android:name="android.nfc.action.tag_discovered" /> <!-- <data android:mimetype="text/plain" /> --> <category android:name="android.intent.category.default" /> </intent-filter> </activity>

ReceiverActivity (simplified) protected void oncreate(bundle savedinstancestate) { Intent intent = getintent(); if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { byte[] id = intent.getbytearrayextra(nfcadapter.extra_id); // tag id Parcelable[] raw; raw =intent.getparcelablearrayextra(nfcadapter.extra_ndef_messages); NdefMessage msg = (NdefMessage) rawmsgs[0]; NdefRecord[] records = msg.getrecords(); String text = NdefHelper.parse(records[j]); } }

SenderActivity (simplified) public void oncreate(bundle savedinstancestate) { manager = (NfcManager)getSystemService(NFC_SERVICE); adapter = manager.getdefaultadapter(); } protected void onresume() { NdefRecord records[] = new NdefRecord[] { NdefHelper.newTextRecord("Hallo Android München", Locale.getDefault(), true) }; adapter.enableforegroundndefpush(this, new NdefMessage(records)); } protected void onpause() { adapter.disableforegroundndefpush(this); }

NdefHelper.newTextRecord public static NdefRecord newtextrecord(string text, Locale locale, boolean inutf8) { byte[] langbytes = locale.getlanguage().getbytes(charset.forname("us-ascii")); Charset utfencoding = inutf8? Charset.forName("UTF-8") : Charset.forName("UTF-16"); byte[] textbytes = text.getbytes(utfencoding); int utfbit = encodeinutf8? 0 : (1 << 7); char status = (char) (utfbit + langbytes.length); byte[] statusbytes = new byte[] { (byte) status }; byte[] data = new byte[statusbytes.length + langbytes.length + textbytes.length]; System.arraycopy(statusBytes, 0, data, 0, statusbytes.length); System.arraycopy(langBytes, 0, data, statusbytes.length, langbytes.length); System.arraycopy(textBytes, 0, data, statusbytes.length + langbytes.length, textbytes.length); return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], data); }

NdefHelper.parse public static String parse(ndefrecord record) throws UnsupportedEncodingException { String result = null; if (record.gettnf() == NdefRecord.TNF_WELL_KNOWN && record.gettype() == NdefRecord.RTD_TEXT) { byte[] payload = record.getpayload(); /* * payload[0] contains the "Status Byte Encodings" field, per the * NFC Forum "Text Record Type Definition" section 3.2.1. * if (Bit_7 == 0): text UTF-8 encoded if (Bit_7 == 1): UTF-16 * Bit_6 is reserved for future use and must be set to zero. * Bits 5 to 0 are the length of the IANA language code. */ String textencoding = ((payload[0] & 0200) == 0)? "UTF-8" : "UTF-16"; int languagecodelength = payload[0] & 0077; result = new String(payload, languagecodelength + 1, payload.length - languagecodelength - 1, textencoding); } return result; }

Some recommendations Make receiver activity separate from UI activity that lists received tags, call finish() when receiver activity has read the tag (if no P2P is required) Filter for mime types that you actually support (annoying side effect android's Tag activity has wildcard intent filter) Limit foreground dispatching/ndef pushing time to the bare minimum (saves battery of course)

Demo time.

Question time Further questions? URL: http://garbe.us Email: anselm@garbe.us OR anselm@scoreloop.com Example code: http://hg.suckless.org/nfc-example

References http://www.businessinsider.com/nfc-chips-2011-3 http://www.businessinsider.com/iphone-5-may-havemobile-payments-after-all-2011-3 http://www.minyanville.com/dailyfeed/android-50- faster-than-iphone/ http://www.dialtosave.co. uk/mobile/news/2011/03/17/foursquare-testing-nfcfor-mobile-check-ins/ http://techcrunch.com/2011/03/16/mobile-wallet-nfcoverhyped/

References II "Google is rumoured to be planning NFC mobile payments trials in New York and San Francisco. Bloomberg has reported that sources familiar with the project say the trials will begin in the next four months and that Google will pay for the installation of thousands of custom-built NFC-enabled Verifone terminals at merchants across both cities." []http://www.telecoms.com/25502/connected-homegoogle-to-launch-nfc-payments-trial/

References III "The Independent reports that a source at a mobile network has told them: 'The new iphone will not have NFC, Apple told the operators it was concerned by the lack of a clear standard across the industry.'" []http://www.metro.co.uk/tech/858017-apple-iphone-5- won-t-have-nfc-mobile-wallet-feature