NDEF Message Processing

stuckwarmersΚινητά – Ασύρματες Τεχνολογίες

14 Δεκ 2013 (πριν από 3 χρόνια και 10 μήνες)

752 εμφανίσεις

NFC Communication Model

NFC Protocol Stack

NFC Forum Tag Types

NFC Forum Tags’ Use Case


NFC

태그

NFC Digital Protocols

(ISO 14443A/B, ISO 18092,

Felica)

LLC

NDEF

Parser

User

Applications



NDEF

Record

(Payload)

NDEF Message

Write NDEF Message

NDEF

Message

Payloads

LLCP

Send NDEF Msg.

With Headers

NDEF Message Processing

NDEF

Record

(Payload)

NDEF Message Structure

Record Handling Architecture


NFC

태그

센싱

Foreground

Dispatch

Activity?

YES

Create

Intent(Tag)

Tag ==

Intent & Data type

The Activity

Defines?

YES

Foreground

Dispatch Activity

(Handle the Tag)

Send the Intent

NO

NO

NO

Intent

(android.nfc.action.

NDEF_DISCOVERED
)

Intent & Data/Type

Filtered by any

Activity?

YES


The Activity

(Handle the Tag)

startActivity(Intent)

NO

Intent(android.nfc.action.
TECH_DISCOVERED
)

Intent & tech
-
list

Filtered by any

Activity?

YES


The Activity

(Handle the Tag)

startActivity(Intent)

NO

Intent(android.nfc.action.
TAG_DISCOVERED
)

Intent

Filtered by any

Activity?

YES


The Activity

(Handle the Tag)

startActivity(Intent)

Only One Activity?

YES

YES

YES

Only One Activity?

Only One Activity?

Activity Chooser

(User selects the

activity)

Activity Chooser

Activity Chooser

NO

NO

NO

Intent Dispatch System

Android NFC Tag Dispatch System

Inspect
First
record

Of first NDEF
message

First record

Of first NDEF message

URI, SmartPoster, or MIME?

Tag contains

NDEF Payload?

MIME?

(TNF:0x02)

URI or SmartPoster?

(TNF:0x01)

Data field of

Intent = URI

YES

YES

Type field of

Intent = MIME

Android

2.3.3 & above

Why?

Refer to (Note) of

Next page

NO

YES

Not NFC Forum Compatible Message Tags

R
1
(MB=1)



R
r



R
s

….

R
t
(ME=1)

R
1
(MB=1,ME=1)

Initial Record Chunk

R
1
(TNF=0xYY, CF=1)



Middle Record Chunk(0 or more)

R
2
(CF=1, TYPE_LENGTH=0, IL=0,
TNF=0x06)





Terminating
Record Chunk

R
n
(CF=0, TYPE_LENGTH=0,
IL=0, TNF=0x06)



NDEF Message with multiple records


7 6 5 4 3 2 1 0

Chunked Payload within an NDEF Message

NDEF Messages

MB

ME

CF

SR

IL

TNF

TYPE LENGTH

PAYLOAD LENGTH 3

PAYLOAD LENGTH 2

PAYLOAD LENGTH 1

PAYLOAD LENGTH 0

ID LENGTH

TYPE

(of Payload)

ID (of Payload in the form

of URI)

PAYLOAD

MB

ME

CF

1

IL

TNF

TYPE LENGTH

PAYLOAD LENGTH

ID LENGTH

TYPE

(of Payload)

ID (of Payload in the form of URI)

PAYLOAD

NDEF Message with a single record


7 6 5 4 3 2 1 0

NDEF Normal Record

NDEF Short Record

TNF
(Type Name Format)


0x00: Empty


0x01: NFC Forum Well
-
known Type


Value of
Type

Field


Text: ‘T’ (0x54)


URI: ‘U’ (0x55)


SmartPoster: ‘Sp’ (0x53 0x70)


Generic Control: ‘Gc’ (0x47 0x63)


0x02: Media Type(RFC2046)


0x03: URL Type(RFC3986)


0x04: NFC Forum External Type


0x05: Unknown


0x06: Unchanged


0x07: Reserved

IL
(ID Length field present flag)

SR
(Short Record)

CF
(Chunk Flag)

ME
(Message End)

MB
(Message Begin)

DEFINITION:
NDEF is a lightweight,
binary message format
that can be used to encapsulate
one or more application defined payloads


of arbitrary type

and size
into a single construct called NDEF message.
Transmitted in a
big
-
endian
manner with the most significant


octet transmitted first.


(Note)
The
type of the first record
, by convention, SHOULD
provide the processing context for the whole NDEF message
.

Text RTD Payload Syntax

Status Byte Encodings

Example: Hello world!

URI RTD Payload Syntax

URI Identifier Codes

Example: Proprietary URI

SmartPoster RTD Payload Syntax

URI Record

(URI RTD)

Only Mandatory &

Only one per

Smart Poster

Title Records

(Text

RTD)

Action Record

(Local Type Name:
‘act’(0x61 0x63
0x74))

Icon Records

(image NDEF MIME
Type)

Size Record

(Local

Type Name:
‘s’(0x73))

Size of the object
the URI refers to

Type Record

(Local Type Name:
‘t’(0x74))

MIME Type of the

object the URI
refers to

Action Record Values

Size Record Layout

Example: Smart Poster with Simple URI

Generic Control RTD Payload Syntax

Configuration Byte Encodings

Action Flag Byte Encodings

Action Numeric Code Encodings

Example: Setting a Device Property

Android Tag Technologies (1)

TagTechnology


Tag


제작한

기술에

따라

Tag


접근하기

위한

Interface

,


부류의

메소드들을

통해서



기술



Tag


접근할



있다
.


1) Cached getters:
Tag


속성을

반환해

주는

메소드들로
,
Tag
감지

시에

결정
된다
. (
일반적으로

get
또는

is


시작된다
.)

2) I/O Operations:
RF
신호교환이

필요하고
, block




있기

때문에

main application thread
에서

실행해서는



된다
.



반드시

connect()


먼저

호출되어야

한다
.



동작이

끝나면

반드시

close()


호출해야

한다
.





번에

하나의

TagTechnology
만이

연결될



있다
.



NFC Permission


필요로

한다
.


Mandatory Technologies for all Android NFC Devices:



NfcA (ISO 14443
-
3A)



NfcB (ISO 14443
-
3B)



NfcF (JIS 6319
-
4)



NfcV (ISO 15693)



IsoDep (build on top of NfcA or NfcB)



Ndef (NFC Forum Type 1, Type 2, Type 3, or Type 4 compliant Tags)


Optional Technologies for Android NFC Devices:



MifareClassic (NfcA)



MifareUltralight (NfcA)



NdefFormatable

Tag
기술

주요

특성



I/O
작업

기타

NfcA

ISO 14443
-
3A

transceive

NFC
-
A/B/F/V
명령을

Tag


전송



응답




어플리케이션은

관리용

명령을

보내서는





, Payload


대한

CRC


자동

추가되므로

?f?Á?± ?

않아도



NfcB

ISO 14443
-
3B

NfcF

JIS 6319
-
4

NfcV

ISO 15693

Ndef

Tag
상의

NdefMessage


추출하고

변경할



있는

수단

제공

NFC Forum Tag Type 1
-
4


Tag


대해서

반드시

나열

getNdefMessage

makeReadOnly

(one way)

writeNdefMessage

IsoDep

ISO 14443
-
4

transceive

기술목록에

NfcA
또는

NfcB


같이

있어야



MifareClassic

16
바이트의

block,

block
들로

이루어진

sector
들로

구성



Mini: 320
바이트
,

4 block
으로

구성된

5 sector



1k: 1024
바이트
,

4 block
으로

구성된

16 sector



2k: 2048
바이트
,

4 block
으로

구성된

32 sector



4k: 4096
바이트
,

4 block
으로

구성된

32 sector+16 block


으로

구성된

8 sector

Sector
단위의

인증이

필요

ACL
비트에

의해

허용되는

I/O
작업

결정

authenticateSectorWithKeyA

authenticateSectorWithKeyB

decrement

increment

readBlock

writeBlock

restore

transfer

transceive (NfcA)

기술목록에

NfcA





있어야



MifareUltralight

4
바이트의

page
들로

구성



original: 64
바이트

EEPROM, 4

pages OTP
영역
+12 pages


User read/write
영역




C: 192
바이트

EEPROM, 4 pages OTP
영역
+36 pages User


read/write
영역
+4 pages
인증


(not readable)

read


4 pages
단위로
,

write


1 page
단위로

동작

readPages

writePages

transceive (NfcA)

기술목록에

NfcA





있어야



NdefFormatable

NDEF
형태로

포맷이

가능한

Tag


대해서만



클래스를

나열

format (read
-
write state)

formatReadOnly (read
-
only state)

Multi
-
step process,


단계라도

실패하면

IOException

Android Tag Technologies (2)