Share
Embed
NFC基礎の基礎
Takahiro Shimokawa
March 17, 2012
Transcript
37 slides
-
NFCͬͯԿʁ Near Field Communication ۙڑແઢ௨৴ Felica (SONY) Mifare (NXP)
ͷ্ҐʹҐஔ͢Δࠃ ࡍن֨ 123݄17༵ -
NFCͬͯԿʁ Α͘ฉ͘RFID (radio frequency identifier) ͱͷؔ ࣗಈೝٕࣝज़ͱσʔλऩूٕज़ ͷඪ४Խ RFID తɿͷཧ
ྫɿίΠϯͷத ɹɹճసण࢘ͷࡼ ɹɹຊͷแͷཪ Χʔυ͓Αͼݸਓࣝผʹؔ͢Δ ٕज़ͷඪ४Խ ඇ৮ICΧʔυ తɿਓͷཧ ྫɿަ௨ܥ ɹɹɹిࢠϚωʔɹ 123݄17༵ -
NFCͬͯԿʁ ඇ৮ICΧʔυͷن֨ NFCIP-2 ( ISO/IEC 21481 ) NFCIP-1 ( ISO/IEC
18092 ) ISO/IEC 14443 Type B ISO/IEC 18092 Type A ( MIFARE ) ISO/IEC 18092 Type F ( FeliCa ) ISO/IEC 15693 = ISO/IEC 18000-3 Model 1 RFID 123݄17༵ -
ۙʹ͋Δʁ NFC ( IC ) Χʔυ PASMO, Suica, ICOCA, TOICA,
ICa, IruCa, RapiCa, passca, Hareca, LuLuCa, monoca, nimoca, Kitaca, SAPICA, SUGOCA, Ecomyca, manaca, Ͱ͔͢, ͳͲ... 123݄17༵ -
ۙʹ͋Δʁ NFC ( IC ) Χʔυ WAON, nanaco, Edy ໔ڐূ
λεϙ ॅຽجຊாΧʔυ 123݄17༵ -
୭͕ܾΊͯΔ͔ʁ NFC Forum ઃཱ Sony, NXP ϝϯόʔاۀ Microsoft, Google, docomo,
KDDI, Samusung, NOKIA, etc 123݄17༵ -
NFCDemo TagಡΈऔΓॲཧ The Tag Dispatch System Android-powered devices are usually
looking for NFC tags when the screen is unlocked, unless NFC is disabled in the device's Settings menu. When an Android-powered device discovers an NFC tag, the desired behavior is to have the most appropriate activity handle the intent without asking the user what application to use. Because devices scan NFC tags at a very short range, it is likely that making users manually select an activity would force them to move the device away from the tag and break the connection. You should develop your activity to only handle the NFC tags that your activity cares about to prevent the Activity Chooser from appearing. To help you with this goal, Android provides a special tag dispatch system that analyzes scanned NFC tags, parses them, and tries to locate applications that are interested in the scanned data. It does this by: 1. Parsing the NFC tag and figuring out the MIME type or a URI that identifies the data payload in the tag. 2. Encapsulating the MIME type or URI and the payload into an intent. These first two steps are described in How NFC tags are mapped to MIME types and URIs. 3. Starts an activity based on the intent. This is described in How NFC Tags are Dispatched to Applications. Android DevelopersΑΓ 123݄17༵ -
NFCDemo TagಡΈऔΓॲཧ λά σΟεύον γεςϜ ௨ৗ Android ࡌσόΠεɺNFC ͕σόΠεͷઃఆϝχϡʔͰແޮʹͳ͍ͬͯͳ͍ݶΓɺը໘͕ϩοΫղআ͞Εͨ࣌ʹɺNFC λ
άΛݟ͚ͭΑ͏ͱ͠·͢ɻAndroid ࡌσόΠε͕ NFC λάΛൃݟ͢ΔͱɺͲͷΞϓϦέʔγϣϯΛ༻͢Δͷ͔ΛϢʔβʹਘͶΔ ͜ͱͳ͘ɺͬͱదͳΞΫςΟϏςΟʹͦͷΠϯςϯτΛϋϯυϧͤ͞Δ͜ͱ͕σόΠεʹظ͞ΕΔಈ࡞Ͱ͢ɻσόΠε NFC λάΛͱ͍ͯڑͰεΩϟϯ͢Δ͜ͱ͔ΒɺϢʔβ͕खಈͰΞΫςΟϏςΟΛબ͢ΔͱɺσόΠε͕λά͔ΒΕͯ͠·͍ɺ ଓ͕Εͯ͠·͏ͱ͍ͬͨ͜ͱʹͳΓ͔Ͷ·ͤΜɻ։ൃऀɺΞΫςΟϏςΟͷબμΠΞϩά͕දࣔ͞Εͳ͍Α͏ʹ͢ΔͨΊʹɺ ΞΫςΟϏςΟ͕έΞ͢Δ NFC λάΛϋϯυϧ͢Δ͚ͩʹ͢ΔΑ͏ʹઃܭ͖͢Ͱ͢ɻ ͜ͷతΛՌͨͨ͢ΊʹɺεΩϟϯ͞Εͨ NFC λάͷղੳɺλάͷύʔε͓ΑͼɺεΩϟϯ͞ΕͨσʔλΛظ͢ΔΞϓϦέʔγϣ ϯͷݕࡧͷࢼΈ͕ Android ʹΑΓఏڙ͞Ε͍ͯ·͢ɻ͜ΕҎԼͷΑ͏ʹ࣮ͯ͠ݱ͞Ε·͢ɻ 1. NFC λάͷύʔεͱλάʹ͋Δσʔλ ϖΠϩʔυΛࣝผ͢Δ MIME λΠϓ URI Λղಡ͠·͢ɻ 2. MIME λΠϓ URI ͱϖΠϩʔυΛΠϯςϯτʹΧϓηϧԽ͠·͢ɻ͜ΕΒͷ࠷ॳͷ 2 ͭͷεςοϓʹ͍ͭͯ NFC λάͷ MIME λΠϓͱ URI ͷϚοϐϯάํࣜ Ͱઆ໌͍ͯ͠·͢ɻ 3. ΠϯςϯτΛجຊͱͯ͠ΞΫςΟϏςΟΛ։࢝͠·͢ɻ͜Εʹ͍ͭͯ NFC λάͷ ΞϓϦέʔγϣϯͷσΟεύονํࣜ Ͱ આ໌͍ͯ͠·͢ɻ ιϑτΣΞٕज़υΩϡϝϯτΛউखʹ༁ ΑΓ 123݄17༵ -
NFCDemo “AndroidManifest.xml” <activity android:name="TagViewer" android:theme="@android:style/Theme.NoTitleBar" > <intent-filter> <action android:name="android.nfc.action.TAG_DISCOVERED"/> <category
android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> 123݄17༵ -
NFCDemo “TagView.java” @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tag_viewer);
mTagContent = (LinearLayout) findViewById(R.id.list); mTitle = (TextView) findViewById(R.id.title); resolveIntent(getIntent()); } 123݄17༵ -
NFCDemo “TagViewer.java” String action = intent.getAction(); if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(action)) { Parcelable[]
rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage[] msgs; if (rawMsgs != null) { msgs = new NdefMessage[rawMsgs.length]; for (int i = 0; i < rawMsgs.length; i++) { msgs[i] = (NdefMessage) rawMsgs[i]; } ... 123݄17༵