NFC: Difference between revisions

From iPhone Development Wiki
Line 26: Line 26:
NFDaemon - (void)XPCConnection:(id) didReceiveCommand:(id)  
NFDaemon - (void)XPCConnection:(id) didReceiveCommand:(id)  


the launchd plist is:
{
    EnablePressuredExit = 1;
    EnableTransactions = 1;
    ExitTimeOut = 45;
    Label = "com.apple.nfcd";
    MachServices =    {
        "com.apple.nfcd" = 1;
    };
    ProcessType = Interactive;
    Program = "/usr/libexec/nfcd";
    UserName = mobile;
}
where the XPC service is registered under the "com.apple.nfcd" name


Supported XPC Commands are:
'''Supported XPC Commands are:'''


;1:q_registerConnection:info:
;1:q_registerConnection:info:

Revision as of 03:12, 25 September 2015

NFC, or Near Field Communication, is a technology that was recently added to the iPhone 6 and 6 Plus in order to implement Apple Pay. The NFC chip included on these devices is the PN548 by NXP Semiconductors. It is similar to the chip used in the Galaxy Nexus[1], and possibly other Android devices.

Apple's implementation of NFC is split into a number of binaries, found only on iPhone7,1 and iPhone7,2 devices:

  • /usr/lib/PN548.dylib
  • /usr/lib/PN548_API.dylib
  • /usr/lib/PN548_HAL.dylib
  • /usr/lib/libnfshared.dylib
  • /usr/libexec/nfcd
  • /System/Library/PrivateFrameworks/NearField.framework

Passbook uses NearField.framework to communicate with nfcd, and nfcd uses the NFC library provided NXP to communicate with the PN548 device. PN548.dylb is NXP's libnfc-nxp, which is open source[2] as a part of Android. PN548_API.dylib is written on top of PN548.dylib, abstracting away the full functionality of libnfc into a CoreFoundation style API named NFDriver for the express purpose of card emulation.

NFCD

nfcd is a daemon running under the mobile user. It handles the communications between Passkit and the underlying hardware and libraries.

The core objects in it are:

  • NFDaemon
  • NFFieldDetectController
  • NFCoreTelephonyConnection
  • NFPowerManager
  • NFAbstractController
  • NFCardEmulationController
  • NFSecureElementController

NFDaemon - (void)XPCConnection:(id) didReceiveCommand:(id)

the launchd plist is: {

   EnablePressuredExit = 1;
   EnableTransactions = 1;
   ExitTimeOut = 45;
   Label = "com.apple.nfcd";
   MachServices =     {
       "com.apple.nfcd" = 1;
   };
   ProcessType = Interactive;
   Program = "/usr/libexec/nfcd";
   UserName = mobile;

} where the XPC service is registered under the "com.apple.nfcd" name

Supported XPC Commands are:

1
q_registerConnection:info:
2
q_unregisterConnection:
3-64
send command to SE controller
65
q_updateSecureElementPowerState
66
_seIsInRestrictedMode
67
restrictedModeChanged
68-239
callSEContoller
240
setDeviceString
241
q_getControllerInfo
242
q_getSecureElementInfo
243
q_getBoosterInfo
244
q_readBoosterRegister
245
q_sendBoosterCommand
246
q_triggerAssertion
>247
throw error

These are formatted into a JSON list i.e. { command = 1; }

References