NFC (Near Field Communication, near field communication) associated

tags: BSP

Excerpt from "in-depth understanding of Android: WiFi and GPS module NFC roll - dengfan level"

Previous study notes stickers, Android version of evolution, some of the content related to the source may vary widely.
 

NFC (Near Field Communication, near field communication) associated

  • NFC Forum
    • The development of NFC-related technical standards
    • NFC certification test
  • NFC Basics
    • NFC is from a variety of different technologies based on integrated evolved

      • RFID technology route, i.e. radio frequency identification (FIG left)
        (Barcodes => RFID => NFC Tag (tag) and NFC Reader)
      • Magnetic stripe cards (Magnetic Strip Cards) technology road (right panel)
        Proximity Coupling Smart Card technology (effective distance of 10cm, the corresponding specifications of ISO / IEC 14443
      • Mobile terminal line, the evolution of a terminal device carried NFC function (FIG intermediate)
        When NFC Connection Handover techniques, which describes how two intelligent terminal to select an appropriate data transmission via Wi-Fi Simple Configuration NFC related protocols (Section 6.1) have introduced an example that smart phones can be configured through the security NFC to exchange information and AP
    • Physical properties
      • Operating frequency is 13.56MHz
      • Effective distance of 4cm
      • Data transmission rate has 106kbps, 212kbps and 424kbps three kinds
    • NFC technology framework

      • Reader / Write Mode: Acronym R / W, and the NFC Tag / NFC Reader related.
      • Peer-to-Peer mode: referred to as P2P, which supports two NFC device interaction.
      • NFC Card Emulation mode: abbreviation CE, it can carry an NFC-enabled device modeled as Smart Card, so that we can implement functions such as a mobile payment, access control card.
      • NFC technology specification frame and the frame corresponding to the NFC Forum defined

        • NFC Forum specification defines three main
          • Analog Specifications: This specification describes the electrical characteristics of the RF layer NFC device
          • Digital Protocal Specification: The specification above ISO 18092, ISO 14443 and JIS X6319-4 defines a digital communication protocol between the NFC device, such that between the Type A or Type F NFC device or an NFC device based on different underlying protocols e.g. interaction can be used among other devices with standard ISO 18092 and the like
          • NFC Activities Specification: The specification for the operation mode corresponding to the protocol stack support, for example, a P2P mode how to link two NFC devices, the R / W mode NFC Device how NFC Tag.
        • Reference Applications represent some of the NFC Forum specifications defined at the application level. There are two standardized
          • Connection Handover: two NFC devices through which to negotiate with Bluetooth or Wi-Fi to conduct subsequent data transmission work.
          • Personal Health Device Communication: The specification defines how data using NFC technology exchange between personal health devices.
          • NFC has also developed a NCI (NFC Controller Interface) specification, which developed a set of interactive interface that enables the host device (Device Host, mobile phone, for example, NFC chip is integrated into a mobile phone, then the phone is Device Host) be able to use this interface and interact with NFC chips.
      •  
    • NFC three modes of operation
      • NFC R / W mode of operation

        • 1.NDEF and NFC Record
          • (1) NDEF and NFC Record [8] The relationship between [9], the R / W mode, every interaction between the NFC devices are encapsulated in a data in the NDEF Message, and may comprise a plurality of NFC NDEF Message Record, true data is encapsulated in the NFC Record


            is apparent from FIG, a NDEF Message may comprise one or more NFC Record. In one NDEF Message, the first NFC Record needs to set its bit MB (Message Begin) is 1, it indicates that the message is the first NFC Record, NFC Record last bit to be set ME (Message End) bit 1 , this message indicates that it is the last NFC Record.
            • NFC Record organization, NFC Record into NFC Record Header (header information) and Payload (payload data) of two parts


              Record Header is the most significant byte first. The 6-byte flag information, are as follows. · MB (Message Begin Flag) · ME (Message End flag) · CF (Chunk Flag flag indicating whether the Record is a slice Record) · SR (Short Record flag. If the flag is set, the FIG. 4 Payload only a length field, which indicates the data length of the Payload limited to 255 bytes) · IL (ID_LENGTH flag for indicating which ID is included in the Header length field is two and ID) · TNF (Type Name Format flag, Payload for indicating the type, NFC Forum defines some common Payload type, see below analysis)
        • Examples 2.NFC Record
          • (1) URI Record Type Example


            Since the NDEF message contains only a NFC Record, so that only the NFC Record Set MB and ME flag is set to 1. Further, since the amount of data less than 255 bytes, so the flag is set to SR 1. Finally, the data carried Record URI belongs to type it as a Well-Known Type, so the TNF value of 0x01. Type Length field value is 0x01, the Type field value of the corresponding "U", the representative URI Record Type. The Record This section describes the URI of the type comprising a Record ID Code Payload data and two portions. ID Code 1 byte value of 0x01 occupied (representing "http://www"), And the data is"nfc.com"Occupy 7 bytes, so the entire length of Payload is 8 bytes, so Payload length field value is 0x08. When the application program acquiring Payload information, the URI corresponding to the finally calculated according to the value of ID Code and Data"http://www.nfc.com"。
          • (2) Text Record Type Example


            carry "Hello World" NDEF message character string information where the value of each field.
    • NFC P2P mode of operation
      • Synopsis
        • The LLC layer and the portion

        • Picture NFC P2P protocol stack

          • SNEP (Simple NDEF Exchange Protocol) layer immediately LLC. Can directly exchange an NDEF message that the protocol between the two NFC Device
          • By Protocol Bindings, NFC support other high-level and more versatile protocol. According to what is shown in reference [3], NFC support for IP and OBEX (Object Exchange, Object Exchange) protocol, but after investigation the draft only LLCP-OBEX-Binding Agreement NFC Forum's official website has now been found, and how LLCP and IP protocol binding still studying.
          • Other Protocols currently more commonly used CHP (Connection Handover Protocol).
      • Introduction 1.LLCP
        • (1) LLCP packet format


          before LLCP packet 3 bytes LLCP Header. After that LLCP Header Payload, which is determined by the length PTYPE.
          • DSAP and SSAP represent the Destination and Source Service Access Point (destination and source service access point). DSAP and SSAP similar to the role of port number TCP / UDP in. Who in the end decided transceiver module Yes.


            using SNEP example: server-module is located in the SSAP NFC Device A is listening on the port 0x04. · NFC Device B is located in a client module selects a suitable SSAP, DSAP set to 0x04. The client module then sends packets, LLC responsible for packetizing data is transmitted to NFC Device B (assuming the two devices are within range of each other). After the LLC layer · NFC Device A receives the discovery packet DSAP is 0x04, and on which there is just a service module in 0x04 port, so that the LLC layer data packet will be passed to the listener in 0x04 port service modules.
          • LLCP PTYPE field indicates the type of packet. The NFC LLCP define various types of packages below with links to data transmission services for the learning-related LLCP packet.
          • Sequence number field specifies the LLCP packet, it can be divided and Receiver Send terminal end. Because some types of packages without LLCP Sequence field, the Sequence field lengths may be zero.
        • (2) link for data transmission services


          When · enter Link Activation, Device A and Device B respectively play the role of Initiator and Target, reference [13] can be used to determine who plays Initiator or Target. · Initiator PAX send data packets to Target. PAX called the Parameter Exchange, which is used to exchange each of the LLC layer configuration information between the two devices (e.g., protocol version, etc., see below). · Target requires a corresponding treatment after the Initiator PAX received packet, for example, determines whether the version of the protocol matching. Target dealt with, it needs to send its own LLC layer configuration information to the Initiator. · Initiator of inspection Target LLC layer configuration parameters, if all goes well, the two sides Logical Link successfully established, then enter the normal session.
          • PAX LLCP data packet belongs to the format shown in

          • After Link is activated, Device A and Device B will first establish a relationship for a link, and then to carry out data exchange, the process in FIG.

      • 2.SNEP Introduction
        SNEP (Simple NDEF Exchange Protocol) supports the NDEF message exchanged between two NFC Device. SNEP is a link-oriented data transmission protocol is based, as a Well-Known Service, the service port number is 0x04, service name "urn: nfc: sn: snep".
        • SNEP belonging Request / Response way, the working process is shown in which


          SNEP workflow is very simple, consists of two steps. 1) SNEP SENP Request message sent by the client to the server for processing. 2) SNEP SNEP Response server reply message to the client to inform the results.
        • SNEP Request / Response Message Format

          • Request type currently supported SNEP

            • SNEP Put Message Format

    • NFC CE operating mode


      NFC CE operating mode such that the device can act as an NFC chip carrying a smart card (e.g. a credit card) to use. The operating mode supported by attractive scenarios, for example to support this feature Android smartphone to complete the purchase, payment, or even act as access cards, car keys, bus cards. SE and NFC chip (mainly NFC Controller, referred to the NFCC) by SWP (Single Wire Protocol) or S2C (SignalIn / SignalOut Connection Interface, also called NFC Wired Interface, abbreviated NFC-WI) interact. Generally, SE runs above some special applications, NFC is responsible for passing data to the application through the SWP or the SE S2C processed.
      • SE plays a very important role in the CE mode, the current combination of SE and NFC three ways

        • · SE is an embedded security chip, the chip factory before the phone has been installed in its internal and can not be replaced.
        • · SE is a pay-type SD card that is actually embedded security module on the SD card, related applications can run on this card.
        • · SE for the UICC, which is often said that the mobile phone SIM card, this combination corresponding program is also known as NFC-SIM program, currently the main push by the operator.
        • NXP's pn65 NFC chip


          contains a Secure Element, i.e., in FIG SmartMX module that runs in an operating system called the Java Card OS. On the Java Card OS, users can install and run some applications (called Applets). In addition to the built-in SmartMX SE, pn65 also supports external SE, i.e., in FIG UICC.
        • CLF-UICC connection


          CLF (NFC Contactless Front-End abbreviations) and the UICC are connected by three lines. Ground Gnd, Vcc supply power. SWIO CLF and the UICC is connected to a data line, the data transfer rate between 212kbps ~ 1.6Mbps, each transmission data packet is less than 30 bytes.
    • NCI principle
      NCI (NFC Controller Interface) is a specification NFC Forum established in 2012, its main focus is the DH (Device Host, host device) how to control and (NFC Controller) to interact with the NFCC
      • NFCC, DH and the relationship between the three NCI


        NFCC DH and physical connections connected to the corresponding physical link Transport Layer (transfer layer), and DH in the NFCC transporting layer which supports a SPI, I2C, UART and USB
        • NCI modular structure

          • · NCI Core module is responsible for the interaction between the basic functions and the NFCC DH, including passing control messages (Control Message) message and data (Data Message), the DH initialization, configuration and resetting NFCC like.
          • · Transport Mapping between NFC Core for converting a data format and a transport layer, for example, to convert a control message and data used by NCI Core message into a corresponding data format used by the transport layer.
          • · NCI Module comprising a plurality of functional modules, for example modules for RF Discovery search around the other NFC Device, RF Interface and NFC Device for peer interaction.
          • NFC Device using the NCI, the working principle and NCI FIG DH


            NCI is a very important role is implemented uniformly in Android NFC HAL layer, i.e., to achieve control of the interaction and the data NFCC by a standard method. However, due to the NCI specification introduced relatively late (final version of the agreement for the period November 6, 2012), it has the largest market share of the company NXP has not been used in the NFC HAL layer NCI its Android platform.
            • · DH NFCC controlled by NCI specification defines the Control Message. The present specification defines the Commands Control Message comprising (request command, including the initialization NFCC, NFCC reset, set configuration parameters NFCC), Responses (reply) and Notifications (notification). These are encapsulated in the Message in NCI Control Packages. Which, Commands can only be sent by the DH to the NFCC.
            • · DH RF Interface and interaction by the peer NFC device (Remote NFC Endpoint drawing), may also be NFCEE interact NFCEE Interface and the equipment. Interactive data includes Control Message and Data Message.
    • NFC related specifications

      • NFC three operating modes and the associated data type definitions, and the protocol stack work
  • Android platform NFC implemented
    • Android platform module structure Nfc


      If pn series NXP's NFC chip, Nfc is a module structure as shown on the left, i.e., the final APK file named Nfc.apk, through which packages / apps / Nfc / nxp directory dhimpl module and libnfc_jni and libnfc these two dynamic libraries interaction. libnfc code located in external / libnfc-nxp directory provided by the company for operating NXP NXP's NFC chip. If Broadcom 2079x series NFC chip, Nfc is a module structure as shown at right, i.e., the final APK file named NfcNci.apk, by which it dhimpl module libnfc_nci_jni and libnfc_nci under packages / apps / Nfc / nci directory two dynamic library interaction. libnfc_nci code located in external / libnfc-nci directory provided for operation by the Broadcom Broadcom's NFC chip.
    • NFC client sample
      • 1.NFC R / W Mode Example
        • (1) NFC Tag distribution system

          • Tag distribution system looks complicated, in fact, its core content profiles into three steps.
          • Step 1 If the target system supports NFC Tag contains the NDEF message, the NFC system module directly to the NDEF messages to the Activity of interest. If there is objective Activity, then distributed directly to it, otherwise go to step 2. Criterion branch conversion is NFC Tag contains the NDEF message system support and at the same time whether there is objective Activity registered ACTION_NDEF_DISCOVERED notice.
            • 1) ACTION_NDEF_DISCOVERED: seen from above, NFC module system first attempts to map the data into the NFC Tag system directly supported data formats. Table 8-11 lists the Android system directly supports the NFC Forum data format.

          • Step 2 If the target contains the Tag NFC NDEF message system does not support or in step 1 no target Activity, the NFC module will try to distribute a system ACTION_TECH_DISCOVERED notification. NFC system modules when distributing this notice, will first analyze the target NFC Tag supported Tag Technology (which represents the target NFC Tag technology used, as detailed analysis below), then look for a registered support these objectives Activity of Tag Technology and Intent distribute it. If no suitable target Activity, the process proceeds to step 3.
            • 2) ACTION_TECH_DISCOVERED: If the system can not map data NFC Tag is, how do we deal with it? The answer is: their application to read and parse the Tag data

            • Android provides a Java package called "android.nfc.tech" to help application operation corresponding to the NFC Tag

              • Note that a Tag Table 8-12 may also support a variety of Technology. For example, when the test Beijing bus card I shown below Tag Technology obtained information.

          • Step 3 NFC system modules will be distributed to registered ACTION_TAG_DISCOVERED notify the target Activity of the notice of interest.
            • 3) ACTION_TAG_DISCOVERED: If the target NFC Tag not belonging to one table 8-12, the NFC system module transmits and carries ACTION_TAG_DISCOVERED Intent object to a Tag Activity of interest. Activity of (Tag of getId function calls) or the use of Tag technology (the call Tag getTechList) to create processed according to the appropriate Tag's ID.
      • 2.NFC P2P model example
        Android platform NFC P2P mode uses SNEP protocol described hereinbefore. SNEP on the basis of the agreement, Android design "Android Beam" technology architecture that client programs such NFC easily get NDEF message transmitted between two NFC devices.
      • 3.NFC CE Mode Example


        using NFC CE applications must <uses-permission> tags affirmed "android.permission.NFC" permission. Is also required by <uses-library> affirmed the use of a dynamic library "com.android.nfc_extras". Thus, when the application is running, the system will load com.android.nfc_extras.jar package for it. This package is located in the corresponding file / system / framework directory
    • NFC system module
      Android platform, NFC system module runs in com.android.nfc process, the process corresponding to the application file called core NfcService Nfc.apk · NFC system modules and some important members and the relationship between the role. · Processing NFC Tag in R / W mode. · Realization of Android Beam. · CE mode related processing.
      • Introduction 1.NfcService


        Nfc.apk class source code contains a NfcApplication. When the application starts, NfcApplication the onCreate function will be called. It is in this onCreate function, the core members of the NFC system module to create NfcService
        • NFC system module core members
          • (1) NfcService core members

          • NativeNfcManager and NfcService class family


            Android NFC system module via the interface class LlcpServerSocket interface class DeviceHost and its internal, DeviceHostListener, LlcpSocket, LlcpConnectionlessSocket, NfcDepEndpoint, TagEndpoint the NFC system module and processing logic NFC chip-independent, and, and related processing logic chip effectively decoupled. 8-36 to "Native" beginning classes are defined in the packages / app / Nfc / nxp directory, and they are related to NXP's NFC chip. DeviceHost interface, and bottom DeviceHost NFC chip classes for interaction, TagEndpoint for the Tag and NFC interaction, NfcDepEndpoint for interactive P2P client and the peer device are used LLCP LlcpServerSocket LlcpSocket and contains links to data transmission services, and servers end, LlcpConnectionlessSocket LLCP used in connectionless data transmission services. In addition, DeviceHostListener is also very important, which is used to deliver NFC NativeNfcManager to NfcService relevant notification event. For example where the onRemoteEndpointDiscovered representing the search to a NFC Tag, onLlcpActivited behalf of the NFC device and remote unit enters the Link Activation (link activation) stage. NativeNfcManager realized DeviceHost Interface to NXP's NativeNfcManager for example, by libnfc_jni and NFC chip will interact libnfc and NXP company. NativeNfcSecureElement to interact and Secure Element.
          • P2pLinkManager familial relationships


            P2pLinkManager complex family relationship, each member is described below in FIG. · P2pLinkManager contains three and transmission related Server, are SnepServer, NdefPushServer and HandoverServer. Each Server defines the relevant callback interface class (such as SnepServer.callback), to achieve these callback interface classes by internal class P2pLinkManager to achieve. · HandoverServer responsible for handling NFC Connection Handover protocol, and specific data transmission by HandoverManager to achieve. From the figure HandoverMangar of mBluetoothAdapter, Android default use Bluetooth to transfer data (Hint: this part the reader's own research After studying this chapter). · P2pEventManager for handling NFC P2P and user interaction associated logic. For example, when searching a P2P device, the phone will shake and a tone sounds. SendUi Figure 8-29 left to achieve a similar interface and user touch event handling. Android platform, when two devices LLCP link is activated, SendUi will be displayed. Its interface components include two parts, one is before SendUi interface displays screenshots of the phone, the other is the "Touch to send" text message. When the user touches SendUi interface, data will be sent out.
      • 2.NFC Tag processing flow analysis
        • (1) notifyNdefMessageListeners Process
          When a detection device NFC NFC Tag, NativeNfcManager notifyNdefMessageListeners the function is called (invoked by the layer libnfc_jni JNI)
        • (2) dispatchTagEndpoint Process
        • (3) NFC Tag process flow summarized

      • 3.Android Beam workflow analysis
        • (1) notifyLlcpLinkActivation flow

        • (2) Beam Transmit Procedure

        • (3) Beam data receiving process

        • 4.CE mode
          · INfcAdapterExtras functionality provided by NfcAdapterExtras client implementation · CE mode when the NFC device into the CE mode, and its interaction with the other end is a device such as NFC Reader. At this time of the end initiate some action, some of which NativeNfcManagement callback function will be triggered.
        • NFC summary of 5.Android
  • NFC HAL layer discuss
    Android Hardward directory defined in the header file to support a nfc.h NFC HAL operates as NFC, but the reader libnfc created or if the code will find libnfc-nci, libnfc and libnfc- nci do not have much use nfc.h defined interface, but a large number of references to each company defined a set of API. This approach is understandable, but it makes other more difficult to do with the upper module or the underlying hardware platform decoupled. Figure 8-26 has let readers believe intuitively feel the consequences of this practice to the
    • Several currently known NFC HAL layer implements

    • Future Linux system, NFC entire software architecture becomes as


      Daemon runs a process called neard NFC, which NFC communication subsystems and user space via Generic Netlink AF_NFC socket mechanism and kernel space. neard to support NFC protocol through different plug-ins, such as Handover, NPP, SNEP and so on. Kernel space, NFC subsystem includes a Control Command Handler, LLCP Handler, Raw Data Handler Core and other core modules.

Intelligent Recommendation

[Android 2.3 &amp; 2.3.3] Near Field Communication NFC API

Take a look at the api of android2.3, as shown below: As can be seen from the introduction here, Android 2.3 provides NFC access, allowing applications to read NDEF messages in NFC tags. As you can se...

Near Field Communication (NFC) Security Technology NEAU's International Standard Road

Near Field Communication (NFC) is a short-range wireless communication technology based on a frequency of 13.56 MHz with a communication distance of less than 20 cm. Nowadays, the application of NFC t...

Android Near Field Communication-BlueTooth

Bluetooth communication based on WeChat Add permissions Mnifest.xml In the file res/values/strings.xml, add state description text and color matching code during program operation Add a Toolbar contro...

Open source NFC module example (a): arduino NFC near field communication module simple tutorial and evaluation

Foreword NFC technology has been greatly applied in recent years, but there are few tutorials to be investigated. Dfrobot, a company that does open source hardware in China, has also produced one.NFC ...

Android development notes (one hundred and sixty-one) NFC near field communication

The full name of NFC is "Near Field Communication", which means near field communication and communication with neighboring areas. The application of NFC technology well-known to the public ...

More Recommendation

The characteristics of three kinds of near -field communication technology

Three kinds of near -field communication technology: (1)WIFI (2)BlueTooth (3)NFC Forecast for the future 1. With the continuous improvement of WIFI, the scope of application will also be wider, and th...

The characteristics of three kinds of near -field communication technology and the future development trend

Tip: After the article is written, the directory can be generated automatically. How to generate the help document on the right The characteristics of three kinds of near -field communication technolo...

Near field and far field of the antenna

The field surrounding the antenna can be divided into two main areas: the area close to the antenna is called the near field or the Fresnel area, and the far field away from the antenna is called the ...

The Ministry of Industry and Information Technology will test near field communication technology based on 13.56 megabytes

On January 12, Dai Xiaohui, deputy director of the Science and Technology Department of the Ministry of Industry and Information Technology, revealed at the "China Mobile Payment Annual Conferenc...

Near Field Communication vs. Bluetooth Low Energy: How to Choose | Linux China

  Introduction:Near Field Communication (NFC) and Bluetooth Low Energy (BLE) are low-power wireless technologies suitable for different purposes of enterprises.                Number of texts: 17...

Copyright  DMCA © 2018-2025 - All Rights Reserved - www.programmersought.com  User Notice

Top