Home

UM10721 NXP Reader Library Peer to Peer User Manual based on

image

Contents

1. wValue value of the read parameter returnValues PH_ERR_UNSUPPORTED_PARAMETER unknown parameter wConfig or can not be modified PH_ERR_SUCCESS Operation successful 3 3 12 Set protocol parameter Developer may use this function to set parameter value of the IS018092 PAL component In addition validity check of parameter value is done internally The updated value shall be afterward used in the communication protocol phStatus_t phpal118092mPI_SetConfig void pDataParams In uintl6_t wConfig In uintl6_t wValue In pDataParams pointer to phpal1I18092mP1_Sw_DataParams_t parameter component wConfig identifier of the parameter to be set in phpal118092mPI_Sw_DataParams_t parameter component Parameters that can be set are listed in Table 6 wValue value to be written into parameter See value limits in Table 6 for each parameter returnValues PH_ERR_INVALID_PARAMETER illegal value of parameter wValue maximal values in Table 6 PH_ERR_UNSUPPORTED_PARAMETER unknown parameter wConfig or can not be modified PH_ERR_SUCCESS Operation successful 3 4 OSAL OSAL module provides basic OS services like dynamic memory allocation and handling hardware timers 3 4 1 Allocate memory This function allocates free memory from heap segment If desired amount of free memory found successfully pointer to allocated memory is returned In fact the build in C function malloc from stdlib h is called UM10721
2. User manual COMPANY PUBLIC Rev 1 1 24 July 2013 11 of 76 270111 NXP Semiconductors U M1 0721 NXP Reader Library Peer to Peer User Manual wTagsFound NO_TAGS_FOUND bTotalTagsFound_A 0 bTotalTagsFound_B 0 bTotalTagsFound_F 0 Switch on Active mode Pull amp Listen RF field ON Detection Tag A Activation or Anticollision Detection of Tag A 1S014443B respecting depending on number of allowed loop limit detection for type cards available in RF A field UIDs of available cards up to bDeviceLimit_A Written into Discovery Loop data parameter component Activation or Anticollision depending on number of cards available in RF field Detection 15014443B respecting loop limit detection for type B Detection of Tag B NO allowed UIDs of available cards up to bDeviceLimit_B Written into Discovery Loop data parameter component Detection ISO18092 Response from respecting loop limit detection REQ_C detection for type F Ox01FE 18018092 Attribute Request Detection of Tag F allowed Attributes copied to the Tag F type data paramater component WTagsFound 0 amp amp current discovery loop lt Loop limit YES Termination of the Discovery Loop 5 It does not describe all the states within the Discovery loop Fig 4 Discovery loop flow chart UM10721 All information provided in this document is subject to le
3. 10 Discovery LOOP routine eseese 11 Activate Card cccccccccsscccesssseeesesceeeessneeeeesneees 13 DOLE CHA eicere ne eae aena aE 14 Detect Beznea aii 14 Detect Ferero ern n ete 15 LLOP modul 0 cccccccceeeeceeeeseneeeeeeeeeeessneeeeeees 15 LLOP Library Structures c ceeeeeeeeeeeeeees 15 LLCP parameter component phinLlcp_Fri_DataParams_t c sssseccccsscssseeseeees 15 Link Parameters phFriNfc_Llcp_sLinkParameters t phlnLlcop_sLinkParameters_t cccecececeeeceeeeeeeeeteeeeees 16 Buffer structure phNfc_sData_t v cccessssssssessseeees 17 Initialization of the LLOP layer 17 PO NGING cs sicedietinsicectinsscgeestcccbaasbeseeeddneneeieties 18 07 1 0 0 18 SYMM ses cacti saeco deeee AEE 19 Medium access control MAC layer 19 LLCP Link APIS ccceccceeeesceeeeeeeeeeeseeeeeees 20 Reset LLOP link 220 sccesessecsersi eeceeerieshoeeesteeds 20 GINO GK critone inion eE eree EREDE E 20 Activate LLC INK nerina 21 Deactivate LLC link cccccccesceeeeesteeeeeeeees 22 Send PDU packet via LLOP link 22 Receive PDU packet on the LLC link 23 All information provided in this document is subject to legal disclaimers 3 2 8 3 2 8 1 3 2 8 2 3 2 8 3 3 2 8 4 3 2 9 3 2 9 1 3 2 9 2 3 2 9 3 3 2 9 4 3 2 9 5 3 2 9 6 3 2 9 7 3 2 9 8 3 2 9 9 3 2 9 10 3 2 9 114 3 2 9 12 3 2 9 13 3 2 9 14 3 2 10 3 2 10 1 3 2 10 2 3 2 10 3 3 2 10 4 3 2 10 5 3 2 10
4. Setting of send and receive rates are provided by phpal118092mP1_Ps1 function phStatus_t phpal118092mPI_Atr void pDataParams n uint8_t pNfcid3i n uint8_t bDid n uint8_t bLri n uint8_t bNadEnable n int8_t bNad n int8_t pGi n int8_t bGiLength n uint8_t pAtrRes Out int8_t pAtrResLength Out pDataParams pointer to phpal1I18092mPI_Sw_DataParams_t parameter component pNfcid3i NFCID3 randomly generated by application in case of 106kbit s initial data rate or NFCID2 from a target in case of 212 or 424kbit s data rate In the Discovery Loop there is UID from phacDiscLoop_Sw_Int_DetectA or ID PM from phacDiscLoop_Sw_Int_DetectF used as NFCID2 The P2P Library does not provide NFCID3 random generator bDid Device Identifier DID is used for multiple data transport protocol activation with more than one target Value must be in range from 0 to 14 Zero disables DID usage UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 39 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual bLri Length Reduction of the Transport Data on the Initiator side Put into this parameter one define from the third column of Table 4 If this LRI differs from one received from Target Attribute Response then smaller among them is used in the NFC communication
5. This handler is called as soon as the SNEP Success response from the SENP server received It indicates the reception of the entire SNEP message has been received on the SNEP server side At this moment the transmitted picture should be displayed on the mobile device screen The SNEP client shall be disconnected by HandleDisconnect handler see Fig 10 4 2 11 Disconnect from SNEP server phStatus_t HandleDisconnect SnepClientData_t pClientData This handler closes the LLC link connection between the SNEP client and server on the LLCP layer by calling the Nrc_LicpClose function see section 4 1 12 The SNEP client shall reach this handler in all circumstances either SNEP entire message successfully received on SNEP server side or transmission fail indicated by any SNEP non Continue or Success message as shown in Fig 10 DONE REJECT BaD_rEauesT UNSUPORTED_VERSION DISCONECT Fig 10 Direct flow from states of the client to disconnect HandleDisconnect always disconnects SnepClientDemo regardless the previous states as shown in Fig 11 _ _ _ _ _ _ _ DISCONECT T_nFctucecioset NOT OK Status print error Fig 11 Flowchart of the HandleDisconnect UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 67 of 76 COMPANY PUBLIC 270111
6. send_started create SNEP message E Tx_buff lt 1st fragment send_started YES send_finished NO NFC_LLCPSend NO send_finished YES NOT OK OK YES recy_started recv_started YES recv_finished NO NFC_LLCPRecv NFC_DummySend RECEIVE ERROR SEND_FIRST Fig 6 Flowchart of HandleSendFirst The HandleSendFirst is designed be implemented in loop so it is called repeatedly In the first run it passes only through the upper part of the diagram only which prepares the SNEP message and sends the first fragment containing the PUT request Since then the upperpart is locked shall not be executed when the handler called Then it can be called several times without executing the second part after send_finished decision As soon as the sending operation on the LLCP layer completed bSendFinish flag shall be set UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 62 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 4 2 8 NXP Reader Library Peer to Peer User Manual by send application callback Sendcb it is not in the picture and send_finished decision shall succeed Assuming no error occurred during the LLCP send API at recv_started the client shall run NO option in the first run immediately after send_finished YES The client shall get ready
7. function pHalDataParams pointer to the HAL component pOsal reference to the OS AL data parameters returnValues PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Discovery Loop routine NXP P2P Reader Library provides useful routine Discovery Loop which performs different NFC cards and tag types detection and also their activation The procedure implements detection of the NFC tags of types A B F and P2P whether there is any tag in the RF field or not If any it provides 15014443 Activation of tag A and tag B type and Anticollision for both the tag types and Attribute Request 1SO18092 for tags type F and P2P tags Discovery loop is clarified by flow chart on Fig 4 Since reader chips MFRC523 nor CLRC663 do not support listen nor pause mode passive active poll mode is switched on automatically If any NFC Tag type detected in case of type A and B also activated parameters of that tag are obtained and saved into new tag component Information about the detected tag is retained within the structured tag component but they are replaced by a new tag object as soon as that is activated If listen mode is not supported by the hardware or no RF field is detected then listen mode is automatically switched off and discovery procedure continues in polling mode All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved
8. NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual 4 2 12 PUT request Rejected phStatus_t HandleReject SnepClientData_t pClientData This handler manages situation when the SNEP Reject message from the SNEP server received In compliance with the SNEP specification 15 the SNEP Reject response informs the client about server s inability to receive the SNEP message declared in the SNEP header The SNEP client shall not send the rest of the SNEP message Afterward HandleDisconnect handler see section 4 2 11 closes the LLC link connection 4 2 13 Error on LLCP layer phStatus_t HandleError SnepClientData_t pClientData Error on LLCP layer has occurred client creation send or receive operation failed UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 68 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM10721 5 Abbreviations NXP Reader Library Peer to Peer User Manual Table 9 Abbreviations Acronym Description AL Application Layer ACK Acknowledgement ATQA Answer To Request type A BAL Bus Abstraction Layer CB Callback CC Connection Complete in LLCP CRC Cyclic Redundancy Check DEP Data Exchange Protocol DID Device Identifier DISC Disconnect in LLCP DM Disconnected Mode in LLCP EEPROM Electrically Erasable Programmable Read Only Memory FRMR Frame
9. Negotiated Length Reduction value retains as FSL in phpal118092mP1_Sw_DataParams_t parameter component Table 4 Table of Length Reduction values The first column refers to LRi bits how they are placed in the Protocol Parameter Initiator byte or FSL byte defined by 15018092 standard The second column refers number of bytes that he Initiator shall send in the Transport Data field within DEP In the third column there are identifiers from the P2P Library analogous to the previous columns E P2P Library identifier 00 64 bytes PHPAL_I18092MPI_FRAMESIZE_64 01 128 bytes PHPAL_I18092MPI_FRAMESIZE_128 10 192 bytes PHPAL_I18092MPI_FRAMESIZE_192 11 254 bytes PHPAL_I18092MPI_FRAMESIZE_254 bNadEnable Node Address enabler Zero or PH_oFF disables NAD usage PH_0N or any nonzero value enables NAD bNad Node Address used in DEP for logical addressing This parameter is ignored if bNadEnabled is equal to zero pGi optional General Information bytes sent by the Initiator bGiLength number of General Information bytes sent by the Initiator The upper limit is 48 bytes according 14 section 14 6 1 1 The value PHPAL_118092MPI_MAX_GI_LENGTH is defined in NxpRdLib_PublicRelease intfs in phpall18092mP1 h file pAtrRes pointer to Attribute Response from the Target pAtrResLength Attribute Response length returnValues PH_ERR_INVALID_PARAMETER bDid bLri Or bGiLength value out of valid range PH_ERR_PROTOCOL_ERROR Received response is
10. SN urn nfe sn snep NFC_LLCPCreateClient y x oO AA NS NOT Ox I a a am SEND_FIRST ERROR Fig 5 Flowchart of the HandleSnepStart See implementation of the LLCP API functions in section 4 1 7 HandleSnepStart converts the service name string urn nfc sh snep to the correct data type see input arguments of NFC_LLCP_CreateClient in section 4 1 7 4 2 7 Sending the first SNEP fragment phStatus_t HandleSendFirst SnepClientData_t pClientData The first SNEP fragment is little different from the rest of the SNEP message There is encapsulated SNEP header and at the beginning of the SNEP payload there is NDEF header of the NDEF message placed Both the headers must be assembled It is obvious that content of both the payloads depends on data intended to be transmitted see Choosing a file as NDEF message in section 4 1 9 Both the headers length attribute depend on size of the chosen file additionally the NDEF header carries the information about type of the file Therefore the first SNEP fragment is considered as special state of the SNEP client state machine UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 61 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual SEND_FIRST
11. This function performs ISO18092 defined either Deselect Request or Release Request then waits for either Deselect Response or Release Response phStatus_t phpal118092mPI_Deselect void pDataParams In uint8_t bDeselectCommand In pDataParams pointer to phpal118092mPI_Sw_DataParams_t parameter component bDeselectCommand Request to send either PHPAL_118092MP1_DESELECT_DSL for Deselect command or PHPAL_118092MPI1_DESELECT_RLS for Release command returnValues UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 42 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual PH_ERR_PROTOCOL_ERROR Received response is not ISO IEC 18092 compliant PH_ERR_IO_TIMEOUT Timeout for reply expired e g target removal PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component 3 3 8 Presence check This function performs presence check for current target whether it is still in the RF field range Firstly PCD sends ISO18092 defined Supervisory Attention PDU then listens to Supervisory Attention Response from the Target This function performs ISO18092 defined Data Exchange Request then waits for Data Exchange Response All the LLCP packets communicated between the initiator and the target are transmitt
12. 1 24 July 2013 26 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual NFCSTATUS_INSUFFICIENT_RESOURCES No free SAP available NFCSTATUS_NOT_ENOUGH_MEMORY Insufficient memory space to store the given service name NFCSTATUS_SUCCESS Operation successful 3 2 9 4 Connect This function tries to connect given socket to a given SAP on the remote peer Connection is performed only for connection oriented sockets that is not currently connected If the socket is not bound to a local SAP it is implicitly bound to a free unadvertised SAP 32 63 In accordance with the LLCP defined by NFC forum if MIUX RW and Service Name are different from default values then those are also sent to the remote phStatus_t phlnLlcp_Transport_Connect void pDataParams n phinLlcp_Transport_Socket_t pLlcpSocket n uint8_t nSap n phlinLlcp_TransportSocketConnectCb_t pConnect_RspCb n void pContext n pDataParams pointer to phFriNfc_Llcp_t parameter component pLicpSocket pointer to the LLCP transport socket nSap the destination SAP to connect to Must be in range from 2 to 63 pConnect_RspCb connect callback function to be called when the connection operation is completed CC frame from the remote received The connection callback type is more precisely described in section 3 2 10 3 pContext pointer to application layer data to be used in the callback returnValkues NFCSTATUS_INVALID_PAR
13. 1 5 gt sTypeATargetinfo bActivatedTagNumber_A number of activated Tags of type A returnValues PH_ERR_INVALID_PARAMETER invalid listen poll pause mode If the HAL component does not provide listen mode the Discovery loop is automatically run in poll mode with listen switched off and detection procedure runs in poll mode without termination the Discovery loop Unknown NFC Tag type other than A B F PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Activate Card Activates the given tag type with given index This function should follow previous successful tag detection passing the tag type as the input argument In case of tag type A according to detected SAK the tag is additionally activated as ISO14443p4A or ISO18092 for P2P This function is implemented within the Discovery loop phacDiscLoop_Start function See section 3 1 3 Note This function does not provide tags F activation since those are activated with the detection Activate card does not provide Anticollision resolution whilst both Anticollision resolution either Activation are implemented within the phacDiscLoop_Start phStatus_t phacDiscLoop_Sw_ActivateCard phacDiscLoop_Sw_DataParams_t pDataParams In uint8_t bTagType In uint8_t bTagIndex In UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 Ju
14. 6 3 2 10 7 3 2 10 8 3 2 10 9 3 3 3 3 1 3 3 2 3 3 3 3 3 4 3 3 5 3 3 6 3 3 7 3 3 8 3 3 9 3 3 10 3 3 11 3 3 12 3 4 3 4 1 LLOP link Callbacks n s 24 Link Check CB ccccccccccsssccceeseeeeessseeeessneee 24 Link Status CB unenee 24 Link Send CB ccccccccecececececeeeeeeeseeeseseeenerenenens 24 Link Receive CBr 24 LLCP Transport Socket APIs cceeee 25 Create LLCP Socket ccccccsssssccceesessssseees 25 Reset LLCP sSocket ccccssssceceesesssseeeeees 25 Bind a socket to a local source SAP 0 26 CONNEC arseno aon pi Connect by URI Listen to Connection Requests eeeeeee 28 Accept an incoming connection request 29 Reject a connection request 30 Disconnect socket cccccccesseeseeeeerereeeseeerens 30 Send data packed connection oriented 31 Receive data from SOCKEt cccccceeeseeeeeseeeeees 32 Send data connectionless cccccceeeeeeeee 33 Close one SOCKEt cccccccesessssseeeeeesesseeees 34 Close all the sockets ccccccccssssseeeeeseesseeee 34 LLCP Socket Callbacks cccccccccceseeesesererees 34 Ll 0 6 gt ee 34 EES 21 91k gt ae T 35 Connect CB aenieiai 35 Disconnect CB ccccccccecccececececeeeeeeeseeeseeenenenes 35 AcCept CB T 36 Reject G Bricis eieren 36 Send C B roie o en a ia 36 Receive CB connection oriented 0 36 Receive CB
15. All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 270111 74 of 76 NXP Semiconductors UM10721 10 Contents NXP Reader Library Peer to Peer User Manual 3 1 2 3 1 3 3 1 4 3 1 5 3 1 6 3 1 7 3 2 3 2 1 3 2 1 1 3 2 1 2 3 2 1 3 3 2 2 3 2 3 3 2 4 3 2 5 3 2 6 3 2 7 3 2 7 1 3 2 7 2 3 2 7 3 3 2 7 4 3 2 7 5 3 2 7 6 UM10721 NXP Reader Libraries comparison 0 008 3 NXP Reader Library Public ececeeeeeee 3 NXP Reader Library Export controlled 4 General information about NXP Reader Library POP E 5 Document StrUCtUre ee eeeeeseeeeeeneeeeeeeneeereeanees 5 Layer Structure of the NXP Reader Library 5 AP AY Oli sa ceecvcsnceetssctities csbeeeneeteccevedeae cnesassenineoseev 7 Card command Sets ccecceeeeeeeteeeeeeeeteeeeneees 7 NEC ACtivity cccccsceceeesceeeseeeeseeeeeeessneeeesenees 7 NFC P2P Package cccceeseeeeeeeeeeeeseeeesesees 7 Protocol Abstraction Layer eee 7 Hardware abstraction layer esee 8 Bus Abstraction Layer eeren 8 Common laYEL cceccccceeeeeeeeeesceeeesseeeeessneeeeeees 8 Explanation of the Library modules for P2P 10 Discovery LOOP ce ccceeesseeeseneeeteeeeeeteneeeeeeanees 10 Discovery Loop data parameter structure 10 Initialization of the parameter structure
16. Library identifier from the third column of Table 4 representing Length Reduction Initiator returnValues PH_ERR_INVALID_PARAMETER bDsi bDri or bFs1 value out of valid range PH_ERR_PROTOCOL_ERROR Received response is not ISO IEC 18092 compliant PH_ERR_IO_TIMEOUT Timeout for reply expired e g target removal PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Activate Card This function just integrates Attribute request and Parameter Selection respectively void pDataParams n uint8_t pNfcid3i n uint8_t bDid n uint8_t bNadEnable n uint8_t bNad n uint8_t bDsi n uint8_t bDri n uint8_t bFsl n uint8_t pGi n uint8_t bGiLength n uint8_t pAtrRes Out uint8_t pAtrResLength Out pDataParams pointer to phpalI18092mPI_Sw_DataParams_t parameter component pNfcid3i NFCID3 randomly generated in case of 106kbps initial data rate or NFCID2 in case of 212 424kbps data rate UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 41 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 3 7 NXP Reader Library Peer to Peer User Manual bDid Device Identifier DID is used for multiple data transport protocol activation with more than one target If zero then DID shall be Value must be in range from 0 to 14 bDsi D
17. Non connection oriented socket NFCSTATUS_INVALID_STATE Socket in other state than socket bound PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Disconnect socket This function disconnects currently previously connected connection oriented socket by sending DISC PDU on LLC link Local and the remote SAP shall both be cleared from the socket but the socket itself shall not not closed Firstly the socket state is changed to disconnecting lf the socket send or receive data pending then this pending are resolved before socket disconnected When the socket disconnected successfully DM PDU All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 30 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual received and handled internally then upper layer is notified by the socket disconnect callback and the socket is left in disconnected state Note As soon as the socket disconnected both socket connected and socket disconnected callbacks are set to NULL phStatus_t phlnLlcp_Transport_Disconnect void pDataParams In phlnLlcp_Transport_Socket_t pLlcpSocket In phinLlcp_SocketDisconnectCb_t pDisconnect_RspCb In void pContext In pDataParams pointer to phFriNfc_Llcp_t parameter component pLicpSocket po
18. Reject in LLCP GPIO General Purpose Input Output HAL Hardware Abstraction Layer Information in LLCP 12C Inter Interchanged Circuit IC Integrated Circuit LLC Logical Link Control LLCP Logical Link Control Protocol LTO Link Timeout in LLCP MAC Medium Access Control in LLCP MCU Microcontroller Unit MF MIFARE MIU Maximum Information Unit in LLCP MIUX Maximum Information Unit Extension in LLCP NAD Node Address NAK Negative Acknowledgement NDEF NFC Data Exchange Format NFC Near Field Communication NFCIP NFC Interface and Protocol OPT Option link parameter in LLCP PAL Protocol Abstraction Layer PAX Parameter Exchange in LLCP PCD Proximity Coupling Device Contactless Reader PICC Proximity Integrated Circuit Card Contactless Card PDU Protocol Data Unit in LLCP UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 69 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM10721 NXP Reader Library Peer to Peer User Manual Acronym PTYPE RNR RR SAM SAP DSAP SSAP SNEP SPI SYMM UID UID WKS Description PDU Type in LLCP Receive Not Ready in LLCP Receive Ready in LLCP Secure Access Module Service Access Point Destination Service Access Point Source Service Access Point Simple NDEF Exchange Protocol Serial Peripheral Interface Symmetry token in LLCP Unnumbered I
19. SNEP server Particularly after sending the first SNEP fragment receiving of Continue SNEP message from the SNEP server is expected After sending the last fragment the SNEP Success is expected Any SNEP message fragment in server client communication it is PDU from the LLCP layer s point of view Implementation of routine for receiving PDU frame via LLCP transport socket may look as one underneath phStatus_t NFC_LLCPRecv phFriNfc_LlcpTransport_Socket_t pSocket phNfc_sData_t psData uint8_t buf uint32_t len pphFriNfc_LlcpTransportSocketSendCb_t pRecvCb phStatus_t status set the call back function if pRecvCb NULL pRecvCb amp RecvCb psData gt buffer buf psData gt length len status phlnLlcp_Transport_Recv amp lnLlcpDataparams pSocket psData pRecvCb void psData CHECK_SUCCESS status return status In psData gt buffer there is a SNEP response from the SNEP server It can be compared with codes of defined SNEP responses UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 56 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 4 1 12 NXP Reader Library Peer to Peer User Manual Receiving of the LLCP frame is a little different from as one would expect according LLCP defined by the NFC forum There is a bug in November 2012
20. by return value NFCSTATUS_REJECTED of phlnllcp_Transport_Send See section 3 2 9 10 gt bRecvStart Receive start flag ensures the receive procedure see section 4 1 11 is not when one SNEP response is already expected to be received See All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 58 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual implementation of this flag in HandleSendFirts Fig 6 HandleSendNext Fig 9 and HandleRecv Fig 7 functions Legal values RECV_START indicates that the SNEP client is ready to receive a SNEP response RECV_NOT_START indicates that the application layer has not been set yet to listen to SNEP responses This value is set inside the application callbacks RecvCb Note This flag is implemented in the application layer SNEP client and it is not directly influenced by the LLCP layer Alternatively this could be implemented by return value NFCSTATUS_REJECTED of phlnllcp_Transport_Recv See section 3 2 9 11 gt bRecvFinish Receive finish flag indicated that the SNEP client has already received SNEP response from the SNEP server See implementation in HandleRecv Fig7 Legal values RECV_FINISHED indicates that the SNEP client has already received the response from the server This value is set inside the application
21. callbacks RecvCb RECV_NOT_FINISHED indicates that the SNEP client has not received the response from the server yet 4 2 3 Application callbacks 4 2 3 1 UM10721 As mentioned in the entire document the NXP P2P Library notifies upperlaying application via callback functions We define simple callback functions modifying binary flag within The flag shall indicate a state the application is currently in see flags of the implemented SNEP client in section 4 2 2 In send callback 4 2 3 1 and receive callback 4 2 3 2 and there are modified flags from dedicated SNEP client parameter structure 4 2 2 In connect callback and link status callback there are modified flags section 4 1 4 defined as global variables Application callback for send The socket send callback function shall be called after the Library completes the sending operation static void SendCb void pContext phStatus_t status sSnepClientData bSendStart SEND_NOT_START sSnepClientData bSendFinish SEND_FINISHED Once bSendStart flag cleared performing next send operation on the application layer see Fig 6 or Fig 9 Once bSendFinished flag is set on the application layer SNEP client there is one of two conditions fulfilled to perform listening to incoming SNEP responses see Fig 6 or Fig 9 The socket send callback function needs to be passed as parameter to ph_InLlcp_Transport_Send see section 3 2 9 10 All information provided in thi
22. connectionless cccccceeeee 37 Protocol layer SO18092 protocol commands 37 ISO18092 PAL parameter component 37 Protocol initialiZation cccececeeeeeeeeeeeeeeeeees 38 Reset Protocol ccccccccececessseseceeeeeneeeeseeeees 39 Attribute REQuest cc eeeceeeeesereeesseeeerenneeeees 39 Parameter Selection ccccscccecceesessssneeeeeee 40 Activate Card ccccscssssssssssssssssssssssssssssssserees 41 B1 e E EE E TET 42 Presence CHECK ccccececcessseeeceeeeeneeeneeeeens 43 eao E E E E 43 Get serial NUMDer ccccccccesssseeeeeeseeseeeee 44 Get protocol parametel cceceeeeeeteeeneees 44 Set protocol parameter ccceeceeesseeeeeeeee 45 1 Ly 1 Rees ea Pr I ee PE RP 45 Allocate MOMOTY 0 eeeeeeeeeseeeeeeeneeetenneeeeteneeeens 45 NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 270111 75 of 76 NXP Semiconductors UM10721 3 4 2 3 4 3 3 4 4 3 4 5 3 4 6 3 4 7 3 4 8 3 4 9 4 1 4 1 1 4 1 2 4 1 3 4 1 4 4 1 5 4 1 6 4 1 7 4 1 8 4 1 9 4 1 10 4 1 11 4 1 12 4 2 4 2 1 4 2 2 4 2 3 4 2 3 1 4 2 3 2 4 2 4 4 2 5 4 2 6 4 2 7 4 2 8 4 2 9 4 2 10 4 2 11 4 2 12 4 2 13 7 1 7 2 7 3 7 4 10 Fre MOMOly ionom oenn N 46 Timer SOIViCS 2 ccccceeeeeeeeeeeeeeeeeeeeesennaeeeees 46 THM SY MM eea 46 Timer Create ccccceceesecceeese
23. cp phinLlcp_Activate phinLicp_ChkL status phlnLlcp_Reset amp ln E amp LinkCB amp Dumn cpDataparams yContext CHECK_SUCCESS status This function resets the Transport layer base of all the socket related functions status phlnLlcp_Transport_Reset amp lnLlcpDataparams CHECK_SUCCESS status The OSAL component osal is necessary for usage of LLCP hardware timers which are used by delay function and SYMM LLCP timer The component must be assigned before phinLlcp_Activate function called Llcp osal amp osal status phlnLlcp_ChkLlcp amp lnLlcpDataparams amp CheckCb void amp DummyContext CHECK_SUCCESS status status phlnLlcp_Activate amp lnLlcpDataparams CHECK_SUCCESS status if status NFCSTATUS_SUCCESS UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 52 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual Link_Activated 1 return status 4 1 7 Establishing the LLCP connection All the data packets between the MCU and the mobile device are exchanged via LLCP transport sockets After the LLC link activation such LLCP socket needs to be created by phlnLlcp_Transport_Socket function for further LLCP communication Once the socket created i
24. essential purpose 7 3 Licenses Purchase of NXP ICs with NFC technology Purchase of an NXP Semiconductors IC that complies with one of the Near Field Communication NFC standards ISO IEC 18092 and ISO IEC 21481 does not convey an implied license under any patent right infringed by implementation of any of those standards All information provided in this document is subject to legal disclaimers Purchase of NXP ICs with ISO IEC 14443 type B functionality This NXP Semiconductors IC is ISO IEC 14443 Type B software enabled and is licensed under Innovatron s f Contactless Card patents license for ISO IEC 14443 B The license includes the right to use the IC in systems and or end user equipment RATP Innovatron Technology 7 4 Trademarks Notice All referenced brands product names service names and trademarks are property of their respective owners MIFARE is a trademark of NXP B V MIFARE Ultralight is a trademark of NXP B V NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 270111 72 of 76 NXP Semiconductors UM10721 8 List of figures NXP Reader Library Peer to Peer User Manual Fig 1 Fig 2 Fig 3 Fig 4 Fig 5 Fig 6 Fig 7 Fig 8 Fig 9 Fig 10 Fig 11 UM10721 NXP Reader Library Public ec eee 3 NXP Reader Library Export Controlled 4 NXP Reader Library P2P sossen 6 Discovery l
25. from the PHFRINFC_LLCP_ERR_FRAME_REJECTED the remote received an invalid packet and subsequently sent FRMR frame PHFRINFC_LLCP_ERR_DISCONNECTED disconnection request DISC PDU from the remote received Listen CB Called at event Incoming connection request CONNECT PDU from a client received Set by phinLicp_Transport_Listen Function prototype void pphFriNfc_LlcpTransportSocketListenCb_t void pContext phFriNfc_LlcpTransport_Socket_t IncomingSocket pContext pointer to user data passed to processed in the CB IncomingSocket pointer to socket that bound to the SAP or service name that the remote is requesting to connect with Connect CB Called at event The local has just sent data packet PDU to the remote Set by phinLlcp_Transport_Connect Function prototype typedef void pphFriNfc_LlcpTransportSocketConnectCb_t void pContext uint8_t nErrCode NFCSTATUS status pContext pointer to user data passed to processed in the CB nError error code defined by NFC forum LLCP Disconnect mode status refers to the status of connection procedure Following values may be passed in NFCSTATUS_SUCCESS Connection successful Once the connection established the data transmission may be performed NFCSTATUS_ABORTED Socket closed by phinLlcp_Transport_Close or as along with frame reject NECSTATUS_FAILED the connection not confirmed on the remote
26. is designated for According to service name to find the socket that the connection request is designated for All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 28 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual The callback function shall be called when an incoming connection request from a remote received and found out the socket requested for conenction Then an application layer may decide whether to accept phinLicp_Transport_Accept Section 3 2 9 7 or to reject phinLicp_Transport_Reject section 3 2 9 8 the incoming connection request for that particular LLCP socket Note This function should be called after socket bound by phinLlcp_Transport_Bind section 3 2 9 3 Without local SAP bound the socket is not LLCP addressable phStatus_t phlnLlcp_Transport_Listen void pDataParams In phlnLlcp_Transport_Socket_t pLlcpSocket In philnLlcp_TransportSocketListenCb_t pListen_Cb In void pContext In pDataParams pointer to phFriNfc_Llcp_t parameter component pLlcpSocket pointer to the transport socket pListen_Cb listen callback function to be called when the socket receives a connection request The second input argument refers to the socket requested to be connected see section 3 2 10 2 pContext pointer to application data
27. of the phinLlcp_Fri_DataParams_t parameter component pLicp LLCP data parameter component pLinkParams pointer to phlnLlcp_sLinkParameters_t data parameter component storing the link parameters pLlcpSocketTable pointer to phinLicp_Transport_t parameter component pRemoteDevicelnfo pointer to phal_sRemoteDevInformation_t parameter component This structure holds information about device detected in the RF field The P2P Library assumes there is stored information taken from the remote s Attribute Response But there is no P2P Library function to fill parameter component of this structure therefore must be done manually see section 4 1 5 Once parameter component of this structure passed to phinLlcp_Fri_Init contains relevant link parameters further link activation procedure takes link parameters from this parameter component otherwise PAX exchange performed pLicp pointer to the LLCP layer pLinkParams pointer to the Link parameters pLlcpSocketTable pointer to the Socket table pRemoteDevinfo pointer to the Remote device information pTxBuffer pointer to the transmit buffer wTxBufferLength length of the transmit buffer pRxBuffer pointer to the receive buffer wRxBufferLength length of the receive buffer pLowerDevice pointer to the underlaying pal118092mP1 PAL data parameter component Link Parameters phFriNfc_Llcp_sLinkParameters_t phlnLlcp_sLinkParameters_t This data parameter component holds information about
28. remote typedef struct phFriNfc_Llcp_sLinkParameters uintl6_t miu uintl6_t wks uint8_t lto UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 16 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 1 3 3 2 2 NXP Reader Library Peer to Peer User Manual uint8_t option phFriNfc_Llcp_sLinkParameters_t phlnLlcp_sLinkParameters_t miu remote Maximum Information Unit MIU wks remote Well Known Services Ito remote Link TimeOut in 1 100s option remote Options Buffer structure phNfc_sData_t This structure holds the Data in the Buffer of the specified size typedef struct phNfc_sData_t uint8_ buffer uint32_ length phNfc_sData_t buffer pointer to the buffer that stores the data length length of the buffer Number of valid bytes in the buffer Pointer to this structure is taken as input argument in many API functions so the developer needs to define some instances of it Initialization of the LLCP layer Initialize the LLCP FRI component All the input parameters are pointers to dedicated structures or buffers The first input parameter is pointer to data parameter component to be initialized This function assigns given input arguments pointers to members of parameter component phinLlcp_Fri_DataParams_t pointed by pDataParams apart the phStatus_t phlnLlcp_Fri_In
29. required if the socket is used as a listening socket since it cannot be directly used for communication phStatus_t phlnLlcp_Transport_Socket void pDataParams n phinLlcp_Transport_eSocketType_t eType n philnLlcp_Transport_sSocketOptions_t pOptions n phNfc_sData_t pWorkingBuffer n phinLlcp_Transport_Socket_t pLlcpSocket Out phlnLlcp_TransportSocketErrCb_t pErr_Cb n void pContext n pDataParams pointer to phFriNfc_Llcp_t parameter component eType type of the socket to be created connection oriented or connectionless pOptions options to be used with the socket pWorkingBuffer working buffer to be used by the library pLlepSocket pointer on the socket to be filled with a socket found on the socket table pErr_Cb error callback function from application that shall be called whenever an error on the socket occurs The cases when the error callback function is called and error callback type are described in section 3 2 10 1 pContext pointer to application layer data to be used in the callback PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component 3 2 9 2 Reset LLCP socket This function transport structure and all the LLCP transport sockets to default states or zero values LLCP link structure must exist and should be reset before Once reset function is done receiving of incoming LLCP packets from LLCP link is enabled phStatus_t phlnLlcp_Transport_Reset void pDat
30. three NXP Reader libraries Although altogether have some common functionalities specially for handling the most common MIFARE cards each of them includes special enhancement for advanced contactless communication This document is focused on description of the NXP Reader Library NFC Peer to Peer thus from section 2 deals with explanation of this Library In the section 4 there are parts of sample code performing SNEP client using the functions of the NXP P2P Library NXP Reader Library Public The basic NXP Reader Library 1 2 is dedicated for card readers It supports multiple RF protocols compliant to many contactless cards in addition several common RF cards are supported Those cards may be directly handled using library APIs Since there are many bus interfaces and contactless readers supported the Reader Library may be used either in desktop PC with Pegoda Reader or embedded MCU with reader chip board application This NXP Reader Library Public does not support SAM unit or the NFC Peer to Peer communication Hardware independent Platform independent Fig 1 NXP Reader Library Public UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 3 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual 1 1 2 NXP Reader Library Export controlle
31. to be used as input arguments in callback returnValues NFCSTATUS_REJECTED previously assigned callback most probably the internal library build in transport receive callback has not been executed yet NFCSTATUS_SUCCESS Operation successful All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 23 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual 3 2 8 LLCP link Callbacks 3 2 8 1 Link Check CB Called at event Incoming connection request CONNECT PDU from a client received Set by API phinklcp_chkLlcp section 3 2 7 2 Function prototype typedef void phFriNfc_Llcp_Check_CB_t void pContext NFCSTATUS status pContext pointer to user data passed to processed in the CB status refers to 3 2 8 2 Link Status CB Called at event Link status changed to activated or deactivated Set by API phinkicp_Reset section 3 2 7 1 typedef void phFriNfc_Llcp_LinkStatus_CB_t void pContext phFriNfc_Llcp_eLinkStatus_t eLinkStatus pContext pointer to user data passed to processed in the CB status enum type referring to updated LLCP link status Following enum values can occur phFriNfc_LlcpMac_eLinkActivated phFriNfc_LlcpMac_eLinkDeactivated 3 2 8 3 Link Send CB Called at event generic LLCP packet sent via LLCP link Set by API phinilcp_Send section 3 2 7 5 S
32. to send disconnect request but the link is currently performing receiving from the remote Thus the disconnect request is pending means placed into waiting queue The disconnect request shall be send as soon as the link will perform sending operations All the pending cases are managed internally thus the developer need not to care about it Callbacks In the P2P Library provides notification to the application layer via callbacks when an important event on LLCP layer occurs The developer may build his own function declare it and set it like a callback The developer s defined callback function must fulfill the function prototype for the particular callback type defined in the library All the socket related callbacks prototypes are in NxpRadLib_PublicRelease comps phinLicp srce Fri ohFriNfc_LicpTransport h But the developer is totally free in building the body of the callback function Except the callback function must be declared right it can be triggered at an event after set by the dedicated function In the sections 3 2 8 and 3 2 10 there are link and callback prototypes clarified through following pattern Called at event the event on LLCP that triggers the user CB function is called Set by the user defined CB function address need to be passed like the input argument to the certain function In fact the function address is assigned to internal library parameter structure From this time on the user defined CB can be called
33. 1 NXP Reader Library Peer to Peer User Manual Internal MAC Send and Receive are used for all the LLCP PDUs SYMM CONNECT etc transaction between the LLCP layer and the PAL layer This should be hidden for a developer who is expected to use APIs from section 3 2 9 LLCP Link APIs Reset LLCP link This function makes initial configuration steps necessary for later LLC link activation procedure This reset function is prerequisite for correct execution of phinLlcp_Activate and phinLlcp_Deactivate phStatus_t phlnLlcp_Reset void pDataParams In phinLlcp_LinkStatus_CB_t pfLink_CB In void pContext In pDataParams pointer to phFriNfc_Llcp_t parameter component pfLink_CB pointer to the user defined callback assigned to pfLinkCB in phFriNfc_Llcp_t component It is called from within phlnLlcp_Activate and phlnLlcp_Deactivate function and refers to the change of the link status when activated or deactivated Developer can pass own phinLlcp_LinkStatus_CB_t function here If none function to pass then this parameter must be NULL The second input argument of the callback is passed by lower layer caller and it refers about latest updated link status See section 3 2 8 2 pContext pointer to the content input argument for the callback function returnValues NFCSTATUS_BUFFER_TOO_SMALL Receive buffer is not large enough to support 131 bytes 128 2 1 MIU Header Sequence Transmit buffer too s
34. AMETER Non connection oriented socket nSap value out of valid range 2 63 NFCSTATUS_INVALID_STATE The socket already connected neither bound nor created Socket has already service name assigned NFCSTATUS_PENDING LLCP link send pending Connection operation is in progress pConnect_RspCb will be called upon completion PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component 3 2 9 5 Connect by URI This function tries to create connection between given socket and a remote service designated by a given URI If the socket is not bound to a local SAP it is implicitly bound to a free SAP UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 27 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 9 6 UM10721 NXP Reader Library Peer to Peer User Manual phStatus_t phlnLlcp_Transport_ConnectByUri void pDataParams n phinLlcp_Transport_Socket_t pLlcpSocket n phNfc_sData_t psUri n phinLlcp_TransportSocketConnectCb_t pConnect_RspCb n void pContext n pDataParams pointer to phFriNfc_Llcp_t parameter component pLicpSocket pointer to the transport socket to be connected to the remote designated by the given URI address psuUri the URI corresponding to the destination SAP on remote to connect to Length of URI is limited to 255
35. All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 45 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 4 2 3 4 3 3 4 4 NXP Reader Library Peer to Peer User Manual phStatus_t phOsal_GetMemory void pDataParams In uint32_t dwLength In void pMem Out pDataParams pointer to phOsal_Lpcl2xx_DataParams_t parameter component dwLength pMem pointer to memory allocated returnValues PH_ERR_SUCCESS Operation successful PH_ERR_RESOURCE_ERROR Requested memory space allocation failed Free memory This function frees previously allocated memory In fact the build in C function free is called phStatus_t phOsal_FreeMemory void pDataParams In void ptr In pDataParams pointer to phOsal_Lpcl2xx_DataParams_t parameter component ptr pointer to memory to be freed returnValues PH_ERR_SUCCESS Operation successful Timer services There are two 32 bit hardware timers in the LPC1227 microcontroller The OSAL module provides utilization of HW timers in two ways SW time delay and general timer usage General Timer usade The P2P Library uses 32 bit hardware timers of LCP1227 to cause forced time delay in thread and one timer interrupt events The Discovery Loop performs time delay after setting the reader chip for particular NFC protocol or for guard interval between detectio
36. Buffer sizeof bLLCP_WorkingBuffer LLCP basic uppermost parameter component see section phlnLlcp_Fri_DataParams_t InLlcpDataparams Component of the socket Shall be used for socket client phFriNfc_LlcpTransport_Socket_t pSocket_Client ISO18092 parameter component see section phpal118092mPI_Sw_DataParams_t pal118092mP1 lt PAL MPI component OSAL component necessary for usage of the SYMM timer phOsal_Lpcl2xx_DataParams_t osal lt OSAL component holder phacDiscLoop_Sw_DataParams_t discLoop lt Discovery loop component Buffers SNEP buffers are not mentioned in this section but they are used in the SNEP client application uint8_t bSnepRx 8 lt SNEP RX buffer uint8_t bSnepTx 128 lt SNEP TX buffer uint8_t bRxBuffer 256 lt LLCP TX buffer uint8_t bTxBuffer 256 lt LLCP RX buffer Working buffer is shall be assigned to socket communicating with the SNEP server via It is dedicated for temporary storage of incoming data Pointer to the working buffer structure needs to be passed as the fourth input parameter into ph_InLlcp_Transport_Socket see section 3 2 9 1 uint8_t bLLCP_WorkingBuffer 800 lt LLCP working buffer phNfc_sData_t sWorkingBuffer bLLCP_WorkingBuffer sizeof bLLCP_WorkingBuffer 4 1 4 Application layer LLCP flags Application layer LLCP flags are used indicate a state that the LLCP layer is currently in This f
37. C_DISCLOOP_ERR_TYPEA_NO_TAG_FOUND Answer to Request A not detected PH_ERR_COLLISION_ERROR more tags type A in the RF field detected PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Detect B This function broadcasts Request B of IS014443p3B by NFC If there is present any tag type B in a range of the RF field then answer to request 8 bytes ID and 8 byte PM are received phStatus_t phacDiscLoop_Sw_Int_DetectB phacDiscLoop_Sw_DataParams_t pDataParams In pDataParams pointer to phacDiscLoop_Sw_DataParams_t data parameter component If a tag type B is detected then received Answer to Request type A ATQ_B is copied to pDataParams gt sTypeBTargetInfo al3P3B aPupi returnValues PHAC_DISCLOOP_ERR_TYPEA_NO_TAG_FOUND Answer to Request B not detected UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 14 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 3 2 1 3 2 1 1 NXP Reader Library Peer to Peer User Manual PH_ERR_INTEGRITY_ERROR more tags B in the RF field detected PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Detect F This function broadcasts Felica Request C If there is present any tag type F in a range of the RF field then answer to request ATQ_B is received Detects if the
38. D_STATE LLCP not in state PHFRINFC_LLCP_STATE_CHECKED PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Deactivate LLC link This function deactivates MAC interface and disconnects LLCP link LLCP link connection is canceled by sending DISC PDU via LLCP link DSAP 0x00 SSAP 0x00 as soon as local is ready for sending operation If the send operation is pending then disconnect procedure is terminated After deactivated successfully the notification about change of the link status toward service layer is done via user defined callback function Llcp gt pfLink_cB which is passed like an input argument to phinLlcp_Reset phStatus_t phlnLlcp_Deactivate void pDataParams In pDataParams pointer to phFriNfc_Llc_t component returnValues NFECSTATUS_INVALID_STATE LLCP link state other than PHFRINFC_LLCP_STATE_OPERATION_RECV Or PHFRINFC_LLCP_STATE_OPERATION_SEND NFCSTATUS_PENDING DISC PDU not sent due to link send pending PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Send PDU packet via LLCP link This function is used to send a given PDU via LLCP Arguments need to be passed in form header sequence field information field The function can only be called on a connection oriented socket which is already in the connected state Note In fact this function this function is implemented by some another fun
39. EXT To be defined To be defined BAD_REQUEST UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 COMPANY PUBLIC 270111 64 of 76 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual PF ae NOT_IMPLEMENTED Ro be defined OxE0 eth PIRI N UNSUPORTED VERSION UNSUPORTED VERSION OxE1 Pa ai REJECT OxFF REJECT DISCONECT default 1 The rest of the flowchart from 1 Fig 8 Flowchart of the HandleRecv part 2 4 2 9 Sending the rest of the SNEP message phStatus_t HandleSendNext SnepClientData_t pClientData Once the Continue response from the SNEP server has been received the SNEP client can send the rest of the SNEP message in sequence of 128 byte long SNEP fragments the last one may be shorter This handler shall be called repeatedly in loop until the last SNEP fragment sent During sending the SNEP client does not expect any response from the SNEP server thus the sending sequence shall not be interrupted As soon as the last fragment of the SNEP message has been transmitted reception of the SNEP Success response from the SNEP server is expected Reception procedure of SNEP response is the same as in HandleSendFirst See section 4 2 7 UM10721 All information provided in this document is subject to
40. IC Rev 1 1 24 July 2013 71 of 76 270111 NXP Semiconductors UM10721 7 Legal information NXP Reader Library Peer to Peer User Manual 7 1 Definitions Draft The document is a draft version only The content is still under internal review and subject to formal approval which may result in modifications or additions NXP Semiconductors does not give any representations or warranties as to the accuracy or completeness of information included herein and shall have no liability for the consequences of use of such information 7 2 Disclaimers Limited warranty and liability Information in this document is believed to be accurate and reliable However NXP Semiconductors does not give any representations or warranties expressed or implied as to the accuracy or completeness of such information and shall have no liability for the consequences of use of such information In no event shall NXP Semiconductors be liable for any indirect incidental punitive special or consequential damages including without limitation lost profits lost savings business interruption costs related to the removal or replacement of any products or rework charges whether or not such damages are based on tort including negligence warranty breach of contract or any other legal theory Notwithstanding any damages that customer might incur for any reason whatsoever NXP Semiconductors aggregate and cumulative liability towards cu
41. LLCP state other than PHFRINFC_LLCP_STATE_OPERATION_RECV OF PHFRINFC_LLCP_STATE_OPERATION_SEND PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Receive PDU packet on the LLC link This function sets a given callback in the internal link structure resulting in the callback shall be called if any transport reception on LLCP link occurs Setting the callback by the function is rejected until the previously set link reception callback called This receive occurs even before parsing the header of the packet Note The link reception callback is mostly dominantly utilized for the library internal purposes receiving the transport packets and further parsed Thus there is a high probability it is occupied by this internal receive callback function at any time after reset sockets by phlnLlcp_Transport_Reset function phStatus_t phlnLlcp_Recv void pDataParams In phinLlcp_Recv_CB_t pfRecv_CB In void pContext In pDataParams pointer to phlnLlcp_Fri_DataParams_t parameter component pfRecv_CB the receive callback to be called when any transport data on the LLCP link received Within the phinLicp_Transport_Reset function the internal library build in transport receive callback is assigned to this callback and is reassigned repeatedly internally and the link callback keeps being captured by it unless manually set to another callback pContext upper layer context
42. P Library structures LLCP parameter component phlnLlcp_Fri_DataParams_t The LLCP basic and uppermost parameter component that holds pointers to buffers and other LLCP related structures and underlaying parameter components Since this parameter component holds pointers to several different components those data of those parameter components are accessible via phlnLlcp_Fri_DataParams_t Therefore there is one common input parameter for all the LLCP API functions Within a particular API there are handled only required data parameter components typedef struct uintl6_t wld phinblcp_t pLlcp phlnLlcp_sLinkParameters_t pLinkParams UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 15 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 1 2 NXP Reader Library Peer to Peer User Manual phlnLlicp_Transport_t pLicpSocketTable void pTxBuffer uintl6_t wIxBufferLength void pRxBuffer uintl6_t wRxBufferLength phHal_sRemoteDevInformation_t pRemoteDevInfo void pLowerDevice phinLlcp_Fri_DataParams_t See section 4 1 5 and 4 1 6 that only content of pRemoteDevInfo and pLinkParams is needed for direct access Other data parameter components pointed by members of parameter component do not need to be initialized to any particular values They must be only declared before initialization
43. P that is compliant with P2P defined by the NFC Forum The compatibility with NFC P2P is due to the P2P Library structure which designed in accordance with P2P part of Protocol Stack defined by NFC forum An embedded application implementing the P2P Library is capable to communicate with another NFC P2P device compliant to NFC Forum P2P concept including connection establishment and maintenance data exchange in NDEF up to the correct connection cancelation Apart from the P2P functionality it provides tools to create applications for handling some MIFARE cards The Library is designed for the particular hardware platform NXP LPC1227 board either connected to PNEV512 Blueboard v1 4 or CLRC663 Blueboard v2 1 The Library enables the hardware to be in a role of NFC P2P Passive Initiator See section 2 2 3 for further hardware restrictions Document structure First of all we introduce general structure of the P2P Library dividing it vertically into layers and further dividing particular layer into modules horizontally see Fig 3 Particular modules imply compatibility of the Library with reader chips compliance with protocols and ability to communicate with various PICCs The document provides overview of implementation Logical Link Control Protocol and ISO18092 protocol which in accordance with NFC Forum are responsible for performance of NFC P2P The LLCP module description is emphasized in section 3 2 due to it is the uppermost layer an
44. Release NXP Reader Library P2P which causes the receiving need to be subsequently followed by the Dummy send The bug is fixed in July 2013 release Receiving works in the normal way just calling phinLlcp_Transport_Recv shall be sufficient for receiving PDU Entire receive routine looks like following Setting the receive busy status flags before reception itself status NFC_LLCPRecv pSocket_Client amp sData bSnepRx sizeof bSnepRx NULL status NFC_LLCPSend pSocket_Client NULL NULL amp SendNULLCb Closing the connection After data transmission complete the LLCP socket connection with SNEP server service on the remote is no more needed for this purpose The LLCP socket should be disconnected in the correct way and then closed socket component cleared This function shall be also when the any other than SNEP Continue or Success response from the SENP server received phStatus_t NFC_LlcpClose void phStatus_t status PH_ERR_SUCCESS uint32_t DummyContext status phlnLlcp_Transport_Disconnect amp lnLlcpDataparams pSocket_Client DisconnectCb void amp DummyContext status phlnLlcp_Transport_Close amp lnLlcpDataparams pSocket_Client CHECK_SUCCESS status return status 4 2 SNEP client 4 2 1 How it works Briefly SNEP client sends initial fragment of length 128 bytes Then it is waiting for a SNEP response from the server Because in SNEP header it is declared lo
45. SNEP client pre step initialization First of all at the beginning of the SNEPClientDemo there iS NFC_LLCPInitialize void called which performs initialization of the LLCP layer and the LLC link activation see section 4 1 6 Afterward the first function of SNEP client state machine HandleSnepStart see section 4 2 6 can be run 4 2 5 Generic state handler phStatus_t SnepClientHandle SnepClientData_t pClientData The generic handler function that integrates all the particular handlers according to a current SNEP state it runs a particular handler 4 2 6 Start the SNEP client phStatus_t HandleSnepStart SnepClientData_t pClientData This function connects the local to the remote on LLCP layer and concurrently the local requests from the remote to provide SNEP server service specified by the string urn nfc sh snep If the request accepted the connection on LLCP layer is established and on the application layer the local becomes the SNEP client connected to the SNEP server From this point the client is ready to send the PUT request the first fragment of SNEP message see section 4 2 7 UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 60 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual _ A t SNEP_START Set the Service Name
46. UM10721 NXP Reader Library Peer to Peer User Manual based on CLRC663 and PN512 Blueboard Reader projects Rev 1 1 24 July 2013 User manual 270111 COMPANY PUBLIC Document information Info Content Keywords NXP Reader Library NFC P2P NFC tag S018092 communication protocol LLCP PN 512 RC663 ISO 18092 Passive Initiator Absiract This document informs the reader about the architecture functionalities of the NXP Reader Library Peer to Peer with stress on LLCP API layer UM10721 NXP Semiconductors UM10721 Revision history NXP Reader Library Peer to Peer User Manual Rev Date Description 1 1 20130724 Change of descriptive title 1 0 20130613 First release Contact information For more information please visit http www nxp com For sales office addresses please send an email to salesaddresses nxp com All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 2 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual 1 NXP Reader Libraries comparison NXP Reader Libraries are C written software packages aimed to used in either embedded or desktop applications for MCUs or PCs both enhanced by a contactless reader Depending on particular library the MCU or PC gets capability to handle various RF cards NFC tags and NFC Peers There are
47. _INVALID_TIMER Attempt to stop non existing timer PH_ERR_SUCCESS Operation successful Timer Delete This function returns the timer with given ID to the free timer pool Content of the timer component is completely forgotten erased In addition if the timer is running this function stops it also therefore it does not need to be stopped by phosal_Timer_Stop This function is counterpart to ph0sal_Timer_Create Section 3 4 5 phStatus_t phOsal_Timer_Delete void pDataParams In uint32_t dwTimerId In pDataParams pointer to phOsal_Lpcl2xx_DataParams_t parameter component timerld ID of the timer to be released to free timer pool returnValues PH_OSAL_ERR_INVALID_TIMER attempt to delete non existing timer PH_ERR_SUCCESS Operation successful Timer Wait This function freezes the thread for a given amount of time determined by both the value and time unit While the thread is being frozen nothing else is being executed within the thread This runs function differs from phosal_Timer_Start The timer triggered by UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 48 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual ph0sal_Timer_Start function runs concurrently with the thread without affecting execution of the thread unless tim
48. a connection oriented socket When the data received successfully RR frame is sent subsequently to the sender of the received PDU frame Note Calling this function from API does make the remote to send data phStatus_t phlnLlcp_Iransport_Recv void pDataParams n phlnLlcp_Transport_Socket_t pLlcpSocket n phNfc_sData_t pBuffer out phlnLlcp_TransportSocketRecvCb_t pRecv_RspCb n void pContext n pDataParams pointer to phFriNfc_Llcp_t parameter component pLicpSocket pointer to the LLCP transport socket which the received data to be read from pRecv_RspCb callback to be called as soon as receive operation is completed pBuffer buffer prepared for received data Data are in the format of the phNfc_sData_t structure where n 1 bytes represents the data itself and one byte refers to the length of the data pRecv_RspCb callback function to be called when received data copied from socket buffer to output pBuffer If socket is in pending receive this callback is stored to socket component receive callback pllcpSocket gt pfSocketRecv_Cb pContext pointer to application data to be used in the callback UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 32 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 9 12 NXP Reader Library Peer to Peer User Manual returnValues NFCSTATUS_SUCCESS Operation succes
49. aParams In pDataParams pointer to phlnLlcp_Fri_DataParams_t parameter component returnValues UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 25 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 9 3 UM10721 NXP Reader Library Peer to Peer User Manual NFCSTATUS_SUCCESS Operation successful Other Depending on implementation and underlaying component Bind a socket to a local source SAP This function binds a given LLCP transport socket with a SAP and service name altogether Only the LLCP socket mandatory must have been already created and passed like nonzero input argument Binding is performed only if the socket is created after phlnLlcp_Transport_Socket Of phlnLlcp_Transport_Disconnect function SAP and Service name are optional parameters but must be passed as NULL at least The function provides custom SAP assignment and dynamic SAP assignment as well Depending on whether an existing service name is given or not SAP value is assigned among either advertised or unadvertised free SAPs Thus the SAP assignment rules are implemented in full compliance with LLCP 1 1 3 by NFC Forum see Table 2 Table 2 _ DSAP SSAP values DSAP SSAP NFC Forum description 0 Link management 1 Designate well known service access point for the Service Discovery Protocol 2 15 Well Known Service Acce
50. ack function from application that shall be called whenever an error on the socket occurs The cases when the error callback function is called and error callback type are described in section 3 2 10 1 pAccept_RspCb accept connection callback function that shall be called when the connection request from a remote accepted CC PDU sent The accept callback type is more precisely described in section 3 2 10 3 pContext pointer to application data to be used in the callback returnValues NFECSTATUS_INVALID_PARAMETER Non connection oriented socket NFCSTATUS_INVALID_STATE Socket in other state than socket bound PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Reject a connection request This function allows the client to reject an incoming connection request It must be used with the socket provided within the listen callback The socket is implicitly closed when the function is called phStatus_t phlnLlcp_Transport_Reject void pDataParams In phinLlcp_Transport_Socket_t pLlcpSocket In phinLlcp_TransportSocketRejectCb_t pReject_RspCb In void pContext In pDataParams pointer to phFriNfc_Llcp_t parameter component pLlcpSocket pointer to the transport socket pReject_RspCb the callback to be called when reject operation is completed pContext pointer to application data to be used in the callback returnValues NFECSTATUS_INVALID_PARAMETER
51. allBck_t pApplication_callback n void pContext n pDataParams pointer to ph0sal_Lpcl2xx_DataParams_t parameter component timerld valid timer ID as returned by phosal_Timer_Create dwRegTimeCnt required amount of time in MS after which the timer expires UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 47 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 4 7 3 4 8 3 4 9 NXP Reader Library Peer to Peer User Manual pApplication_callback pointer to the callback function that will be called once timer expires The user defined function must satisfy the prototype of callback function void ppCallBck_t uint32_t TimerId void pContext pContext argument with which the call back function will be called returnValues PH_OSAL_ERR_INVALID_TIMER requesting non existing timer or the timer has not been created before PH_ERR_SUCCESS Operation successful Timer Stop Stop the given timer This function does not free the timer It only disables the timer Use phOsal_Timer_Delete to free the timer The timer may be restarted by phOsal_Timer_Start phStatus_t phOsal_Timer_Stop void pDataParams In uint32_t dwTimerlId In pDataParams pointer to phOsal_Lpcl2xx_DataParams_t parameter component timerld ID of the timer to be stopped returnValues PH_OSAL_ERR
52. ameter pHalDataParams description Pointer to the HAL parameter component of the underlaying HAL layer default init value input parameter Init section 3 3 2 input parameter NFC ID3 BPC ID TEDES Rg ATR_REQ section 3 3 4 DID Device identifier NULL NAD enabled NAD enabler PH_OFF NAD Node Address NULL WT Waiting timeout for a target 14 FSL Frame length 0 means 64 bytes PNI Packet number NULL DSi E ive ie Parameter Select Request NULL 106kbit s DRi Divisor Receive initiator NULL 106kbit s Number of attempts to send a Request bMaxRetryCount despite no Response from a Target The limit 2 is common for all the types of Requests 3 3 2 Protocol initialization This function is used to initialize phpalI18092mPI_Sw_DataParams_t parameter component Thus it should be called as the first among the ISO18092 related functions section 3 3 It calls phpal118092mP1I_ResetProtocol function and registers a pointer to a component of the undelaying HAL layer phStatus_t phpalI18092mPI_Sw_Init phpal118092mPI_Sw_DataParams_t pDataParams In uintl6_t wSizeOfDataParams In void pHalDataParams In pDataParams pointer to phpal118092mP1_Sw_DataParams_t parameter component wSizeOfDataParams size of the parameter component It is highly recommended to use built in C function sizeof wSizeOfDataParams pHalDataParams pointer to the component of the underlaying hardware layer This component is bound to th
53. bytes characters pConnect_RspCb connect callback function to be called when the connection operation is completed CC frame from the remote received The connection callback type is more precisely described in section 3 2 10 3 pContext pointer to application layer data to be used in the callback returnValkues NFCSTATUS_INVALID_PARAMETER Non connection oriented socket The given socket already connected or pending connect URI address longer than 255 characters NFCSTATUS_PENDING LLCP link send pending Connection operation is in progress pConnect_RspCb will be called upon completion PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Listen to Connection Requests This function makes a given socket listen to any incoming connection request from a remote This is prerequisite for establishing the LLCP connection initialized from a remote Listening is only allowed for connection oriented sockets which are currently not connected The listening itself does not load a thread execution because it is based on callback In fact this function just sets a given callback The P2P library parses the incoming connection request and further ensures resolving of following situations that may occur Immediate respond with FRMR to a sender of the connection request when invalid TLV data received According to remote s DSAP to find the socket that the connection request
54. ce that implements 1SO18092 defined Attribute Request The remote device sends Attribute Response containing LLCP Magic Number specified by NFC forum together with link parameters in TLV format After parsing first of all the version agreement is performed then the LTO timer is triggered However if there is not LLCP Magic Number within Attribute Response and the local is NFC P2P Initiator type then in the activation procedure PAX PDU with local link parameters is sent to the remote After LLC activated successfully the notification about change of the link status toward service layer is done via user defined callback function Llcp gt pfLink_cB which is passed like an input argument to phinLlcp_Reset The function does not create LLCP socket It should be created by phlnLlcp_Transport_Socket Note If deactivation callback is called it indicates that activation procedure failed thus deactivation procedure has been automatically executed to revert steps done by unsuccessful activation phStatus_t phlnLlcp_Activate void pDataParams In UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 21 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 7 4 3 2 7 5 UM10721 NXP Reader Library Peer to Peer User Manual pDataParams pointer to phFriNfc_Llc_t component returnValues NFCSTATUS_INVALI
55. cepts no liability for any assistance with applications or customer product design It is customer s sole responsibility to determine whether the NXP Semiconductors product is suitable and fit for the customer s applications and products planned as well as for the planned application and use of customer s third party customer s Customers should provide appropriate design and operating safeguards to minimize the risks associated with their applications and products NXP Semiconductors does not accept any liability related to any default damage costs or problem which is based on any weakness or default in the customer s applications or products or the application or use by customer s third party customer s Customer is responsible for doing all necessary testing for the customer s applications and products using NXP UM10721 Semiconductors products in order to avoid a default of the applications and the products or of the application or use by customer s third party customer s NXP does not accept any liability in this respect Export control This document as well as the item s described herein may be subject to export control regulations Export might require a prior authorization from competent authorities Evaluation products This product is provided on an as is and with all faults basis for evaluation purposes only NXP Semiconductors its affiliates and their suppliers expressly disclaim all warranties w
56. correct communication interface between the MCU and the reader chip The MCU sends to the reader chip commands and other command related data like addresses and data bytes The card reader can possibly to send some register values or received data like the response to requests from the MCU The NXP Reader Library supports following communication interfaces Stub Originally it was intended like component without functionality to ease implementation of additional busses Currently it supports SPI 12C and RS232 interfaces enabling connection to the Bluebord 13 or Xpresso board The reader chip can possibly send replies mostly when MCU requests value of particular register Common layer The NXP Reader Library also includes utilities independent of any card and hardware card reader meaning they can be implemented regardless of reader chip All of them are encapsulated into the Common Layer phTools this part of common layer is able to perform binary operations related to CRC and bit parity both for various lengths CRC and parity check are used very rarely in communication between MCU and the card reader Note This has nothing to do with the communication between the reader chip and the PICC or another NFC device All the CRC checksum is done by both the sides participating on NFC communication automatically All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved Us
57. ctions using sending any PDU via LLCP link To send data packed within via LLCP it is recommended rather to use phlnLlcp_Transport_Send see section 3 2 9 10 which sends data within the Information PDU frame and assembles Header and Sequence automatically from given LLCP socket component parameters phStatus_t phlnLlcp_Send void pDataParams n phlnLlcp_sPacketHeader_t pHeader n phlnLlcp_sPacketSequence_t pSequence n phNfc_sData_t pInfo n phinLlcp_Send_CB_t pfSend_CB n void pContext n pDataParams pointer to phFriNfc_Llcp_t parameter component All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 22 of 76 270111 NXP Semiconductors UM1 0721 3 2 7 6 UM10721 NXP Reader Library Peer to Peer User Manual pHeader pointer to the PDU packet header composed from SSAP PTYPE and DSAP pSequence pointer to the PDU packet sequence field pInfo pointer to the PDU information field pfSend_CB pointer to the callback of LLCP link structure that shall be called when sending via LLCP link executed successfully pContext pointer to the content input argument for the callback function returnValues NFCSTATUS_REJECTED previous sending operation has not been finished yet NFCSTATUS_PENDING Previous receive operation has not been finished yet NFCSTATUS_INVALID_STATE
58. cular device depends on layer point of view s presented in Table 7 Table 7 Two peers and their names as called in this section point of view peer s name hardware device mobile device with Android LPC1227 MCU SNEP client server LLCP layer local remote 1ISO18092 initiator Target 4 1 Implementation of the LLCP API 4 1 1 Global variables Firstly there will be introduced global variables that shall be used by the SNEP client and underlaying LLCP layer All the global variables from this section are declared in src SnepClient c UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 49 of 76 COMPANY PUBLIC 70111 NXP Semiconductors UM1 0721 4 1 2 4 1 3 NXP Reader Library Peer to Peer User Manual Data structures used by the P2P library Components instances of the data structures used by the P2P Library need to be declared phNfc_sData_t sData phFriNfc_LlcpTransport_t LlcpTransport lt LLCP transport layer component phFriNfc_Llcp_sLinkParameters_t LinkParam lt LLCP link parameter phFriNfc_Llcp_t Llcp lt LLCP pointer phHal_sRemoteDevInformation_t RemotelInfo lt Remote Info component phLibNfc_Llcp_sSocketOptions_t sOptions 128 1 lt LLCP options Working buffer shall be assigned to a socket phNfc_sData_t sWorkingBuffer bLLCP_Working
59. d Comprehensive software API enables the customer to create their own software stack for their contactless reader The library includes software representing cards which may be export controlled or common criteria certified Therefore the whole software is export controlled and subject to NDA with NXP Library enables usage of SAM module which enables encrypted communication between the host and reader chip PCD There must be hardware support from SAM unit of course Virtual Card MIFARE ISO IEC15693 ICODE SLI Part of Felica ICODE ILT Architecture DESFire EV1 compliant Commandset Hardware independent Platform independent ISO IEC 14443 Tools 4 CID Man CRC Parity Sw Ror Note Crypto Rng 1 SW Random Number Generator and Crypto Sym 2 modules in Common layer performing security operations on MCU Note SamAV2 modul 3 in HAL layer Driver for the SAM module Backward compatibility with SamAV1 Fig 2 NXP Reader Library Export Controlled UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 4 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual 2 General information about NXP Reader Library P2P 2 1 1 2 2 UM10721 The main purpose and difference from the other NXP Reader Libraries is software extension performing NFC P2
60. d its APIs are designed for usage in developers embedded application The IS018092 modul is described more sketchily just to get a complete image of NFC P2P Protocol Stack within the P2P Library After those layers described in the section 4 there is a simple SNEP client application which performs sending NDEF message to a SNEP server NFC mobile device with android platform The SNEP client implements functions of the LLCP layer described in the section 3 2 to present usage of the library API functions The SNEP client simply sends NDEF message to android SNEP server Layer Structure of the NXP Reader Library The MCU implementing the Library is able to utilize several types of reader chips to handle any of few types of MIFARE cards and NFC peer to peer communication To satisfy such versatile usage architecture of the Library was designed with multi layered structure see Fig 3 Each layer is independent from the other layers All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 5 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual Sample P2P application ISO Tools 1EC14443 4 CRC Parity CID Man Sw Card command sets enabling handling with MIFARE cards NFC activity Discovery Loop polling NFC tag detection 3 NFC P2P package Logical Link Control Pro
61. ds ISO18092 request commands subsequently waits for a response coming from Target But the MCU is not able to listen to requests from another Initiator Wake Up Request and Response are not implemented in the P2P Library For a developer implementing the LLCP APIs there is no way how to influence this layer The 1SO18092 standard protocol parameters and values are mostly taken from NFC Forum TS Digital Protocol 1 0 14 All the defines representing those parameter values are defined in the library folder NxpRdLib_PublicRelease comps phpall18092mPI src Sw in file phpall18092mPI_Sw_Int 1S018092 PAL parameter component PAL layer component uses phpal118092mP1I_Sw_DataParams_t parameter structure to store important 1SO18092 protocol attributes The structure is defined in NxpRadLib_PublicRelease intfs phpall18092mPI h Important members of the structure are listed in Table 3 An instance of this structure is called 15018092 PAL component All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 37 of 76 270111 NXP Semiconductors UM10721 Table 3 NXP Reader Library Peer to Peer User Manual Some parameters from ISO18092 Pal component In the right column there are default values given by Initialization function see section 3 3 2 Apart from these parameters there are few others for internal management par
62. e used PCD returnValues PH_ERR_SUCCESS Operation successful UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 38 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual 3 3 3 Reset Protocol This function reset values of given 1S018092mPI PAL parameter component to zero or default values Frame length FSL is set to 64 bytes phStatus_t phpal118092mPI_ResetProtocol void pDataParams In pDataParams pointer to phpal1I18092mPI_Sw_DataParams_t parameter component returnValues PH_ERR_SUCCESS Operation successful 3 3 4 Attribute Request This function performs ISO18092 Attribute Request command then listens to Attribute Response from the Target DID and NAD parameters from Targets Attribute Response are verified whether they agree with Initiator side Initiator timeout value is set according to TO parameter from Attribute Response After this function finishes successfully in the 1SO18092 PAL parameter component there are stored parameters of NFC communication In the P2P Library this function is implemented in the Discovery Loop to detect any of NFC P2P tags either of types F or types A Note This function does not allow to set either BSi or BRI attributes of the IS018092 communication protocol since those are not supported by passive communication mode
63. ed by this function phStatus_t phpal118092mPI_PresCheck void pDataParams In pDataParams pointer to phpalI18092mPI_Sw_DataParams_t parameter component returnValues PH_ERR_SUCCESS Operation successful PH_ERR_PROTOCOL_ERROR Received response is not ISO IEC 18092 compliant PH_ERR_IO0_TIMEOUT Timeout for reply expired e g target removal PHPAL_118092MPI_ERR_RECOVERY_FAILED Recovery failed target does not respond any more PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component 3 3 9 Exchange This function performs ISO18092 defined Data Exchange Request then waits for Data Exchange Response All the LLCP packets communicated between the initiator and the target are transmitted by this function phStatus_t phpal118092mP1_Exchange void pDataParams In uintl6_t wOption In uint8_t pTxBuffer In uintl6_t wTxLength In uint8_t ppRxBuffer Out uintl6_t pRxLength Out pDataParams pointer to phpalI18092mPI_Sw_DataParams_t parameter component wOption option parameter for internal method how to send DEP frame sequence OR wOption parameter with any of above defines PH_EXCHANGE_BUFFERED_BIT PH_EXCHANGE_LEAVE_BUFFER_BIT are advanced buffer methods related to HAL buffer UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 43 of 76 COMPANY PUBLIC 270111 NXP Se
64. eeeeneeeessneeeessnnees 47 Timer Start aieiaiee eanan aa rantaan 47 Timer Stopiran e Eai ais 48 Timer Delete ccccceeceeeseeceeeeeeeeeeeeneneeenees 48 Mimet WV All secceccheespacaeeheeencenhesqaeeehs ceagunuaneaeeeeaeis 48 Sample Code cssccsseessseessseeseseesseesseeeesseeseeees 49 Implementation of the LLCP API 49 Global variables ecceeseeeeeeeeeeeeeeeeeeeeenees 49 Data structures used by the P2P library 50 Baters craie e eaae 50 Application layer LLCP flags eeeeeeeeeeeeeee 50 LLC link pre step actions eee eeeeeeeeees 51 Initializing the LLC link sassen 51 Establishing the LLCP connection 53 Preparation of NDEF message ceee 54 Choosing a file as NDEF message 0 54 Sending a fragment of SNEP message 55 Receiving of SNEP response n 56 Closing the CONNECTION cceeeeeeetteeeteeeeteee 57 SNEP Clients 57 HOW it WOKS iseinean eena aaan aE 57 SNEP client parameter structure 06 58 Application callbacks 59 Application callback for Send ee 59 Application callback for receive eee 60 SNEP client pre step initialization 60 Generic state handler ceceeeseeeeeeeeeeeeeee 60 Start the SNEP Client eee eeeeeeseeeeseeeenees 60 Sending the first SNEP fragment 00 61 Handling of the SENP response eee 63 Sending the rest of the SNEP mes
65. er expiration Note The NXP P2P Library uses always uses hardware timer 1 for thread wait delay performed by this function The hardware timer is not even checked whether free or currently used for any other purpose phStatus_t phOsal_Timer_Wait void pDataParams In uint8_t bTimerDelayUnit In uintl6_t wDelay In pDataParams pointer to phOsal_Lpcl2xx_DataParams_t parameter component bTimerDelayUnit time units Identifier PH_OSAL_TIMER_UNIT_MS for milliseconds and PH_OSAL_TIMER_UNIT_US for microseconds wDelay amount of time This parameter together with bTimerDelayUnit determines the length of delay returnValues PH_ERR_SUCCESS Operation successful 4 Sample code The section 4 1 shows how the P2P Library APIs described in sections 3 2 7 and 3 2 9 can be implemented into functions of an application layer There fragments of C code taken from SnepClient c Functions from section 4 1 are implemented into the SNEP client application The SNEP client performs only Put request 15 It is fully described in section 4 1 The SENP server may be performed by any NFC mobile device with Android platform 4 0 and later In result after application runs a picture should be received and displayed on mobile devices screen In the entire section 4 we will use several terms representing only two devices One device is board with LPC 1227 with reader chip extension Blueboard 2 1 Name we use to point parti
66. er manual COMPANY PUBLIC Rev 1 1 24 July 2013 8 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual phKeyStore is key handling software storage changing key format etc But the NXP Reader Library P2P supports only key storage utility Only the NXP Reader Library Export Controlled version supports full key storage functionalities phLog software module enabling log files creation OSAL Utils This module provides some basic utilities like dynamic memory allocation and handles functions for LPC1227 timers This module is described in section 3 4 UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 9 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual 3 Explanation of the Library modules for P2P 3 1 3 1 1 3 1 2 Discovery Loop Discovery loop is tool for detecting activating various NFC tags and NFC peer devices Due to OSAL layer does not provide any thread creation Discovery loop can run only in single thread called from upper application without any possibility of interruption during running therefore the upper application caller is blocked till the Discovery Loop exits The Discovery loop can include ability to detect more tag types in the future Discovery Loop data parameter structure Discovery lo
67. et by API phinLicp_Send typedef void phFriNfc_Llcp_Send_CB_t void pContext NFCSTATUS stats pContext pointer to user data passed to processed in the CB status 3 2 8 4 Link Receive CB Called at event generic LLCP packet received via LLCP link Note This CB is occupied by internal library function Set by API phinLicp_Receive section 0 typedef void phFriNfc_Llcp_Recv_CB_t void pContext phNfc_sData_t psData NFCSTATUS status pContext pointer to user data passed to processed in the CB psData pointer received data UM10721 Al information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 24 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual status 3 2 9 LLCP Transport Socket APIs 3 2 9 1 Create LLCP socket This function creates a socket for a given LLCP link Sockets can be of two types connection oriented and connectionless If the socket is connection oriented the caller must provide a working buffer to the socket in order to handle incoming data This buffer must be large enough to fit the receive window RW MIU the remaining space being used as a linear buffer to store incoming data as a stream Data will be readable later using the phLibNfc_LlcpTransport_Recv function section 3 2 9 11 Note The options and working buffer are not
68. f the link nSap out of range 2 63 NFCSTATUS_INVALID_STATE Socket not in connectionless state NFCSTATUS_REJECTED Socket is in send pending state Socket is in error status NFCSTATUS_FAILED Operation failed UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 33 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 9 13 3 2 9 14 NXP Reader Library Peer to Peer User Manual Close one socket This function closes a given LLCP transport connection oriented or connectionless socket previously created by phFriNfc_LlcpTransport_Socket function If the socket was connected it is first disconnected and then closed This function manages closing of given previously created socket whether connection oriented or connectionless If a socket has been already connected then disconnect from LLC link by sending DICS PDU is performed automatically If connection oriented socked has not been connected yet it is closed by abort Accept Connect CBs are executed then set to NULL phStatus_t phlnLlcp_Transport_Close void pDataParams In phlnLlcp_Transport_Socket_t pLlcpSocket In pDataParams pointer to phlnLlcp_Fri_DataParams_t parameter component pLlcpSocket pointer to the transport socket returnValues NFCSTATUS_SUCCESS Operation successful Other Depending on implementation and under
69. f the phNfc_sData_t structure where n 1 bytes represents the data itself and one byte is length of the data UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 31 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual pSend_RspCb callback to be called when the send operation is completed see section 3 2 10 7 pContext pointer to application data to be used in the callback returnValues NFCSTATUS_INVALID_PARAMETER Socket is another than connection oriented type Socket is not in connected state Data in psBuffer to be sent are longer than remote MIU of the receiver NFCSTATUS_INVALID_STATE The socket is not in a valid state or not of a valid type to perform the requested operation NFCSTATUS_REJECTED Socket is in send pending state NFCSTATUS_FAILED Operation failed NFCSTATUS_SUCCESS Operation successful Other Depending on implementation and underlaying component 3 2 9 11 Receive data from socket This function is used to read received data from a given socket It reads at most the size of the reception buffer but can also return less bytes if less bytes are available If no data is available the function will be pending until more data comes and the response will be sent by the callback This function can only be called on
70. gal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 12 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 1 4 NXP Reader Library Peer to Peer User Manual phStatus_t phacDiscLoop_Start void pDataParams In pDataParams pointer to phacDiscLoop_Sw_DataParams_t parameter component Execution of the function is influenced by parameters of this component especially following ones gt bNumPollLoops number of times the Discovery loop should loop looking for tags before Discovery loop gives up gt bDetectionConfiguration or this parameter with desired combination of PHAC_DISCLOOP_CON_POLL_A PHAC_DISCLOOP_CON_POLL_B PHAC_DISCLOOP_CON_POLL_F to allow detection of a particular tag type gt wTagsFound sets bit masks indicating tags that were detected Whenever the function is called this flag is cleared and particular bits are set according to which tag types are currently detected in the range of the RF field gt sTypeATargetinfo bTotalTagsFound_A this parameter is refers to the number of the tags A detected in the field It is set to zero with each function call Discovery loop NOT the partial loop detection within the Discovery loop increased by one when any tag is detected in the range of RF field gt sTypeATargetinfo bLoopLimit_A this is upper limit for attempts to detect Tag A type inside the phacDiscLoop_Sw_Int_DetectA function see section 3
71. gister and activate particular cards This procedure is called Discovery loop and it is deeper described in section 3 1 NFC P2P Package This module 3 in Fig 3 provides complete software support for Logical link management The goal of the Link layer is to create manage maintain and correctly disconnect the connection among peers In result multiple logical connections between two or more peers can exist in the same time but still using the 13 54MHz RF link The NFC forum specified Logical Link Control Protocol LLCP 3 as standard for the NFC peer to peer communication Thus LLCP is implemented in NXP Reader Library P2P to process traffic on Logical Link LLCP ensures sending and reception of separate packets while being not aware the upper NDEF message entirety Since LLCP module is the most upper among P2P related LLCP APIs are expected to be the most used from the Library at all Those APIs are described in section 3 2 There is a hidden part of the LLCP layer called MAC layer According to LLCP specification 3 from the NFC forum activation and deactivation procedures are related to the MAC layer Protocol Abstraction Layer The Protocol Abstraction Layer implements the activation and control and data exchange and other operations regarding the protocol of the contactless communication Each protocol is placed in separate own folder in the library folder structure NxpRadbLib comps phpal lt protocolName gt Since th
72. hether express implied or statutory including but not limited to the implied warranties of non infringement merchantability and fitness for a particular purpose The entire risk as to the quality or arising out of the use or performance of this product remains with customer In no event shall NXP Semiconductors its affiliates or their suppliers be liable to customer for any special indirect consequential punitive or incidental damages including without limitation damages for loss of business business interruption loss of use loss of data or information and the like arising out the use of or inability to use the product whether or not based on tort including negligence strict liability breach of contract breach of warranty or any other theory even if advised of the possibility of such damages Notwithstanding any damages that customer might incur for any reason whatsoever including without limitation all damages referenced above and all direct or general damages the entire liability of NXP Semiconductors its affiliates and their suppliers and customer s exclusive remedy for all of the foregoing shall be limited to actual damages incurred by customer based on reasonable reliance up to the greater of the amount actually paid by customer for the product or five dollars US 5 00 The foregoing limitations exclusions and disclaimers shall apply to the maximum extent permitted by applicable law even if any remedy fails of its
73. ication Furthermore just in case P2P initiator or target two bottom lines the MAC layer interface can be fully activated consequently send and receive functionalities are fully provided Table 1 Device and tag type for MAC layer In NXP Reader Library P2P the MAC layer functionality is legal for following remote devices tags Tag device type Identifier in the P2P Library 15014443 type A tag phHal_eI 014443_A_PICC 15014443 type B tag phHal_eI 014443_B_PICC ISO18092 type F P2P initiator phHal_eNfcIP1_Initiator ISO18092 type F P2P target phial_eNfcIP1_Target The LLC link layer activation procedure needs three functions to be called in following order 1 Reset phlnblcp_Reset section 3 2 7 1 2 Check phlnbicp_ChkLicp section 3 2 7 2 3 Activation phlnbicp_Activate section 3 2 7 3 4 Send Receive LLCP packets upper layer communication 5 Deactivation phinLlcp_Deactivate section 3 2 7 4 Once the Activate successes the LLC link is fully connected with undelaying PAL layer represented by 1SO18092 Initiator This needs to be done to send any Afterward the functions from section 3 2 9 can be called socket creation connect listen etc All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 19 of 76 270111 NXP Semiconductors UM1 0721 3 2 7 3 2 7 1 3 2 7 2 UM1072
74. igned this way is limited to 2 If both the timers are currently in use then no timer is assigned Once the timer created it can be used for counting by phOsal_Timer_Start and phOsal_Timer_Stop Counterpart to this function is phOsal_Timer_Delete section 3 4 8 which releases the timer as free Internally an array is maintained which stores timers along with information as to whether the timer is available or not This function searches a free timer that is available and returns the timer ID Note Timer 0 is used by the NXP P2P library as LLCP LTO timer phStatus_t phOsal_Timer_Create void pDataParams In uint32_t timerld Out pDataParams pointer to phOsal_Lpcl2xx_DataParams_t parameter component timerld ID of assigned timer If no free timer has been found then this parameter is returned with value PH_OSALNFC_INVALID_TIMER_ID equal to OxFFFF returnValues PH_OSAL_ERR_NO_FREE_TIMER Both the timers are currently in use PH_ERR_SUCCESS Operation successful Timer Start Timer starts counting When the timer expires after given time amount then given application callback function is executed The counterpart to this function is phOsal_Timer_Stop function section 3 4 7 The timer must be created by phOsal_Timer_Create section 3 4 5 before started or stopped timer may be restarted phStatus_t phOsal_Timer_Start void pDataParams n uint32_t dwTimerId n uint32_t dwRegTimeCnt n ppC
75. ines LTO to avoid infinite waiting for activity from a remote while the remote is off without letting know Therefore the P2P Library implements SYMM timer to perform LTO The SYMM timer is adjusted according to LTO of the remote received during link activation phase The LTO in P2P Library is implemented in compliance with the NFC Forum LLCP All the SYMM timer and SYMM exchange is managed internally thus the developer does not need to care about at all The SYMM timer is reset with each sent packet regardless link or transport If the SYMM timer expires during local link receive state then link is deactivated consequently disconnected If the SYMM timer expires while the local is something to send then it local sends SYMM PDU Medium access control MAC layer The MAC layer is necessary for nearly all the LLCP layer link related functionalities based on receiving sending and LLC link activation deactivation as well Functions from the section 3 2 7 providing LLC link activation must be run before the first LLCP PDU sent received The MAC layer parameter component LicpMac needs to be fulfilled with information of the NFC device or tag type detected in the RF field But there is no function providing passing of detected tag device type to RemDevType in phNfc_sRemoteDevInformation_t component thus must be done manually MAC layer can be initiated only for those devices and tag types listed in Table 1 because they are capable of NFC P2P commun
76. inter to the transport socket to be disconnected pDisconnect_RspCb the callback to be called when the disconnection operation is completed phinLlcp_Transport_Disconnect function just puts address of this callback to disconnectCB in socket Actually the callback is called by phinLlcp_Transport_Close function see section 3 2 9 13 pContext pointer to application data to be used in the callback returnValues NFECSTATUS_INVALID_PARAMETER Non connection oriented socket NFCSTATUS_INVALID_STATE Socket in not connected state NFCSTATUS_PENDING LLC link status in send pending state Try later PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component 3 2 9 10 Send data packed connection oriented This function provides sending data via connection oriented LLCP transport socket which must be already in the connected state To transmit the data the function performs on LLCP layer sending the PDU frame with header created according to DSAP and SSAP from the socket phStatus_t phlnLlcp_Transport_Send void pDataParams n phlnLlcp_Transport_Socket_t pLlcpSocket n phNfc_sData_t pBuffer n phinLlcp_TransportSocketSendCb_t pSend_RspCb n void pContext n pDataParams pointer to phFriNfc_Llcp_t parameter component pLlcpSocket pointer to the LLCP transport socket which the data to be sent via pBuffer buffer containing the data to send Data are in the format o
77. is document is focused on NFC peer to peer communication which is compliant to 15018092 protocol this one is deeper described in section 3 3 The NXP Reader Library supports following ISO standard protocols 1 014443 3A 7 air interface communication at 13 56MHz for the cards of type A MIFARE Classic and Ultralight EV1 are based on this protocol 1S014443 3B 7 air interface communication at 13 56MHz for the cards of type B 1S014443 4 7 specifies a half duplex block transmission protocol featuring the special needs of acontactless environment and defines the activation and deactivation sequence of the protocol MIFARE DESFire EV1 card is based on this protocol 1S014443 4A 7 previous protocol for the cards of type A MIFARE needs to be included for any MIFARE card Contains support for MIFARE authentication proximity check and data exchange between the PCD and PICC according to protocols ISO IEC 14443 3A and ISO IEC14443 4 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 7 of 76 270111 NXP Semiconductors UM1 0721 2 2 3 2 2 4 2 2 5 UM10721 NXP Reader Library Peer to Peer User Manual Felicia compliant protocol 10 parts of it are also part of ISO 18092 9 1S018092 9 enables the NFC Data Exchange Protocol 1SO18092 protocol is Request amp Response based NFC communication protoc
78. it phinLlcp_Fri_DataParams_t pDataParams n uintl6_t wSizeOfDataParams n phinLlcp_t pLlcp n phlnLlcp_sLinkParameters_t pLinkParams n phinLlcp_Transport_t pLlcpSocketTable n phHal_sRemoteDevInformation_t pRemoteDevInfo n void pTxBuffer n uint16_t wTxBufferLength n void pRxBuffer n uint16_t wRxBufferLength n void pLowerDevice n pDataParams pointer to phlnLlcp_Fri_DataParams_t parameter component to be initiated wSizeOfDataParams size of the parameter component sizeof wSizeOfDataParams Other input parameters are members of phlnLlcp_Fri_DataParams_t see section 3 2 1 1 UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 17 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 3 3 2 4 UM10721 NXP Reader Library Peer to Peer User Manual See section 4 1 5 and 4 1 6 that only content of pRemoteDevInfo and pLinkParams is needed for direct access Other data parameter components pointed by members of parameter component do not need to be initialized to any particular values They must be only declared before initialization of the phinLlcp_Fri_DataParams_t parameter component returnValues PH_ERR_SUCCESS Operation successful Pending Sometimes the current request cannot be performed in time due to another operation is running For example the local intends
79. ivisor Send target to initiator Only values from are allowed PHPAL_118092MPI_DATARATE_106 PHPAL_118092MPI_DATARATE_212 PHPAL_118092MPI_DATARATE_424 where last three number refers to data rate in kbit s bDri Divisor Receive initiator to target Only values from are allowed PHPAL_118092MPI_DATARATE_106 PHPAL_118092MPI_DATARATE_212 PHPAL_118092MPI_DATARATE_424 where last three number refers to data rate in kbit s bFsl Frame Length of the Transport Data Put into this parameter one define from the third column of Table 4 Frame Length table of values bNadEnable enable usage of Node Address If equal to zero then NAD is disabled bNad Node Address used in DEP for logical addressing This parameter is ignored if bNadEnabled is equal to zero pGi optional General Information bytes sent by the Initiator bGiLength number of General Information bytes sent by the Initiator Must be less or equal to PHPAL_118092MPI_MAX_GI_LENGTH defined in NxpRdLib_PublicRelease inttfs in phpall18092mP1h file pAtrRes pointer to Attribute Response from the Target pAtrResLength Attribute Response length PH PH_ERR_INVALID_PARAMETER bDid bDsi bDri or bFs1 value out of valid range PH_ERR_PROTOCOL_ERROR Received response is not ISO IEC 18092 compliant PH_ERR_10_TIMEOUT Timeout for reply expired e g target removal PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Deselect
80. lag shall be modified at the beginning of the link initialization UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 50 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 4 1 5 4 1 6 NXP Reader Library Peer to Peer User Manual uint8_t Llcp_running lt Flag indicating whether LLCP is running OR not This flag is shall be modified by application connect CB function uint8_t SocketConnected lt Flag indicating socket connection This flag shall be modified immediately after LLC link activation uint8_t Link_Activated 0 lt Flag indicating link activation LLC link pre step actions After initial hardware configurations the Discovery loop needs to detect whether there is any NFC P2P device in the RF field To perform detection it transmits Attribute Request then listens for any Attribute Response In target s Attribute Response there is information about link parameters mentioned in 3 in section 6 2 3 1 During link activation procedure the NXP P2P Library looks for this data in special structure RemoteInfo If there are some parameters the Library activates the LLC link with those parameters rather than doing PAX exchange RemoteInfo SessionOpened 1 RemoteInfo RemDevType phNfc_eNfcIPl_Target RemoteInfo RemoteDevinfo NfcIP_Info ATRInfo_Length discLoop sTypeFTargetInfo sTy
81. laying component Close all the sockets This function closes all the created sockets independently of their current states In addition information from the pCachedServiceName is entirely cleared phStatus_t phlnLlcp_Transport_CloseAll void pDataParams In pDataParams pointer to phlnLlcp_Fri_DataParams_t parameter component returnValues NFCSTATUS_SUCCESS Operation successful Other Depending on implementation and underlaying component 3 2 10 LLCP Socket Callbacks 3 2 10 1 Error CB Called at event Error on LLCP link occured Origin of the error is passed like the second input argument by the caller from within the library Set by phinLicp_Transport_Socket Or phlnLlcp_Transport_Accept Function prototype typedef void pphFriNfc_LlcpTransportSocketErrCb_t void pContext uint8_t nErrCode pContext pointer to user data passed to processed in the CB nErrCode value tells what is the error caused by UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 34 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 10 2 3 2 10 3 3 2 10 4 NXP Reader Library Peer to Peer User Manual ERR_NOT_BUSY_CONDITION RR acknowledgement received from the remote after negative acknowledgement RNR received before PHFRINFC_LLCP_ERR_BUSY_CONDITION negative acknowledgement RNR PDU
82. legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 65 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual SEND_NEXT NO send_finished YES Tx_buff lt next fragment send_started YES send_finished NO NFC_LLCPSend ast fragment transmitted ves recv_started YES recv_finished NO NFC_LLCPRecv NFC_DummySend RECEIVE SEND_NEXT Fig 9 Flowchart of the HandleSendNext The first decision send_finished NO option avoids sending the same SNEP fragment multiple times YES option is run when sending of the SNEP fragment completed The second decision status goes OK when sending on the LLCP layer succeeded otherwise the sending canceled moreover the SNEP client disconnected and the program escapes from SNEPClientDemo The decision point last fragment transmitted goes always over NO branch but when the last fragment transmitted the client shall be set for listening to SNEP response same as in HandleSendFirst 4 2 7 UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 66 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM10721 NXP Reader Library Peer to Peer User Manual 4 2 10 SNEP transmission successful phStatus_t HandleDone SnepClientData_t pClientData
83. like text messages URI links and JPEG or PNG images For example to choose picture of PNG uncomment the line include lt c_tablepng h gt and comment all the other lines referring to c_table include lt c_tablepng h gt include lt c_tableQR h gt include lt c_tablenxp h gt include lt c_tabletxt h gt Then choose the correct file type and format in ndef_message c Get this information from Table 8 from the same row as the PNG image file Uncomment the line with NDEF_TYPE_IMAGE and NDEF_IMAGE_PGN and let other lines commented Thanks to this option correct NDEF head is built so an Android application can recognize type of the incoming NDEF message NDEF_messages n_mess UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 54 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 4 1 10 1 ii ii ii hi NXP Reader Library Peer to Peer User Manual type parameter string NDEF_TYPE_IMAGE NDEF_IMAGE_JPEG c_table sizeof c_table NDEF_TYPE_IMAGE NDEF_IMAGE_PNG c_table sizeof c_table T LANG_NO textl sizeof textl T LANG_EN c_table sizeof c_table T LANG_EN text6 sizeof text T LANG_GR text3 sizeof text3 T LANG_FR text4 sizeof text4 U NDEF_URI_WWW i_11 size
84. ly 2013 13 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 1 5 3 1 6 NXP Reader Library Peer to Peer User Manual pDataParams pointer to phacDiscLoop_Sw_DataParams_t parameter component If the tag type is activated successfully the tag component is fulfilled with parameters of the activated tag bTagType PHAC_DISCLOOP_TYPEA_ACTIVATE activate of the tag type A PHAC_DISCLOOP_TYPEB_ACTIVATE activate f the tag type B bTagIndex The tag which has to be activated Only I3P3 of tag type A and B can have three references tag indexes while all the others have just one component to be stored within the to phacDiscLoop_Sw_DataParams_t structure returnValues PH_ERR_INVALID_PARAMETER invalid value of bTagType PH_ERR_INVALID_DATA_PARAMS bTagIndex is greater than number of previously found detected tags A PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Detect A This function broadcasts Request A of 1SO14443p3A by NFC If there is present any tag type A in a range of the RF field then answer to request ARQ_A is received phStatus_t phacDiscLoop_Sw_Int_DetectA phacDiscLoop_Sw_DataParams_t pDataParams In pDataParams pointer to phacDiscLoop_Sw_DataParams_t data parameter component If a tag type A is detected then received Answer to Request type A ATQ_A is copied to pDataParams gt sTypeATargetInfo aTypeA_I3P3 0 aAtga returnValues PHA
85. mall to support maximal LLCP frame size Header Sequence MIU NFCSTATUS_INVALID_PARAMETER MlU in psLinkParams lower than 128 bytes PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Check This function checks some Attribute Response from remote device then decides if the MAC layer can be enabled for that device The device should have been previously detected in the Discovery loop If the remote device type is NCF P2P Initiator or Target type then it enables the internal connection between LLCP layer and MAC layer necessary for Activation Deactivation Sending Reception and Checking itself In case 1IS014443A or ISO14443B no internal MAC connection provided In addition General Bytes from the Attribute Response matched to that remote device received in Discovery loop are tested whether they equal to LLC Magic Number 3 byte array 0x46 0x66 Ox6D If it equals then the rest of data of the Attribute Response is later assigned as remote link parameters rather than doing PAX exchange Note This function requires the LLC link to be in correct state which is ensured by previous run of phlnLicp_Reset function All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 20 of 76 270111 NXP Semiconductors UM1 0721 3 2 7 3 NXP Reader Library Peer to Peer U
86. miconductors UM1 0721 NXP Reader Library Peer to Peer User Manual PH_EXCHANGE_TXCHAINING PH_EXCHANGE_RXCHAINING PH_EXCHANGE_RXCHAINING_BUFSIZE mean ISO18092 frame chaining But this does not need to be set If the data to be exchanged is more than Frame Size configured by phpal118092mP1_Atr Length Reduction or phpal118092mPI_Ps1 this function performs the chaining automatically In result frame of any size is transmitted correctly PH_EXCHANGE_DEFAULT is sufficient to perform NFC P2P correctly For better explanation see NxpRdLib_PublicRelease types ph_ Status h pTxBuffer data to transmit from the initiator to target wTxLength length of data to transmit ppRxBuffer pointer to received data pRxLength number of received data bytes returnValues PH_ERR_INVALID_PARAMETER invalid flag bit in xOption used PH_ERR_PROTOCOL_ERROR Received response is not ISO IEC 18092 compliant PH_ERR_1O_TIMEOUT Timeout for reply expired e g target removal PHPAL_118092MPI_ERR_RECOVERY_FAILED Recovery failed target does not respond any more PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component 3 3 10 Get serial Number This function retrieves the serial number NFCID3 from the PAL component The serial number must have been previously retrieved by phpal118092mPI_Atr function phStatus_t phpalI18092mPI_GetSerialNo void pDataParams In uint8_t
87. n of B and F tag type Before the LLCP link activation section 3 2 7 3 there must be at least one hardware timer free for the purpose of LLCP SYMM timer The timer is released by link deactivation phinLlcp_Deactivate section 3 2 7 4 Note On the PAL and HAL layer while the initiator waits for the response from the Target instead of MCU timers there are internal hardware timers of attached reader chip used for measuring the timeouts defined by particular NFC protocol Timer Init This function is necessary prerequisite for any timer usage Firstly it makes software configurations It initiates timer parameter component ph0sal_Lpcl2xx_DataParams_t and internal software timer structures aimed for storage of important information of particular UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 46 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 4 5 3 4 6 NXP Reader Library Peer to Peer User Manual hardware timers Once this function executed all the timers related can be run After all the software issues initiated timer interrupts are enabled phStatus_t phOsal_Lpcl2xx_Timer_Init phOsal_Lpcl2xx_DataParams_t pDataParams In returnValues PH_ERR_SUCCESS Operation successful Timer Create This function assigns an unused hardware timer of MCU LPC1227 Number of hardware timers that can be ass
88. ndard ISO IEC 14443 Identification cards Contactless integrated circuit cards Proximity cards Data Sheet ISO IEC Standard ISO 18092 Information technology Telecommunications and information exchange between systems Near Field Communication Interface and Protocol NFCIP 1 Standard ECMA Near Field Communication Interface and Protocol NFCIP 1 www nxp com redirect ecma international org publications files ECMA ST Ecma 340 pdf Data Sheet JIS Standard JIS X 6319 Specification of implementation for integrated circuit s cards Part 4 High Speed proximity cards Data sheet CLRC663 Contactless reader IC BU ID Doc No 1711 available on http www nxp com documents data_sheet CLRC663 pdf Data sheet PN512 Transmission module BU ID Doc No 1112 available on http Awww nxp com documents data_sheet PN512 pdf Application note Quick Start Up GuideRC663 Blueboard available on http www nxp com demoboard CLEV663B html Technical Specification NFC Digital Protocol NFC Forum TS DigitalProtocol 1 0 available on www nxp com redirect nfc forum org specs spec_ license Technical Specification Simple NDEF Exchange Protocol NFCForum TS SNEP_1 0 available on www nxp com redirect nfc forum org specs spec license 1 UM10721 BU ID document version number All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBL
89. nformation in LLCP Unique Identifier Well Known Services UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 70 of 76 270111 NXP Semiconductors UM1 0721 6 References NXP Reader Library Peer to Peer User Manual 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Direct link to the NXP Reader Library Public Release http Awww nxp com documents software 200310 zip User Manual NXP Reader Library User Manual based on CLRC663 BU ID Doc No 2574 available on http www nxp com demoboard CLEV663B html documentation Technical Specification Logical Link Control Protocol NFCForum TS LLCP_1 1 available on www nxp com redirect nfc forum org specs spec_ license Data Sheet MF1S503X MIFARE Classic 1K Mainstream contactless smart card IC for fast and easy solution development available on http www nxp com documents data_sheet MF1S503x pdf Data Sheet MIFARE Ultralight MFOICU1 MIFARE Ultralight contactless single ticket IC BU ID Doc No 0286 available on http www nxp com documents data_sheet MFOICU1 pdf Data Sheet MIFARE DESFire MF3ICDx21_41_81 MIFARE DESFire EV1 contactless multi application IC BU ID Doc No 1340 available on http www nxp com documents short_data_sheet MF3ICDX21_ 41 81 SDS pdf ISO IEC Sta
90. nger SNEP message than one fragment the server should response with Continue SNEP message The SNEP client MCU can go on with sending rest of the SNEP message without UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 57 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual getting any acknowledgements form the mobile device As soon as entire SNEP message transmitted the SNEP client shall receive SNEP Success from the mobile device Or first sending shall be started only after socket connected The SNEP client is represented by the uppermost function sNEPClientDemo The entire SNEP client source code is in SnepClient c SNEP client is implemented like state machine with several states defined in SnepClient h header file For each state of the SNEP client there is the specific function handler managing the particular state The handlers are described in sections 4 2 6 4 2 13 4 2 2 SNEP client parameter structure UM10721 The SNEP client uses one parameter structure SnepClientData_t defined in SnepClient h that holds state of the SNEP client and four flags The flags should avoid the overlapping of sending and receiving of SNEP fragments and responses SnepClientData_t consists of 6 members gt Hstate states of the SNEP client valid values are defined by the HandleSta
91. nk activation while SocketConnected amp amp Llcp_running return status 4 1 8 Preparation of NDEF message The sample application builds SNEP message and its header as well It also encapsulates NDEF message and header into a SNEP message All the user needs to do is to choose particular NDEF message before compilation as described in the next section 4 1 9 The chosen NDEF message shall be transmitted to Android SNEP server 4 1 9 Choosing a file as NDEF message By default the software sends the picture of NXP loge in JPEG format In the source code of SNEP client project there are few files prepared tables in separate header files Table 8 Table of files that are part of sample application written as C headers Information from the last two columns is necessary for choosing the right line from n_mess array see bellow Content Header name Sae ape PNG image c_tablepng h NDEF_TYPE_IMAGE NDEF_IMAGE_PNG QR code of NXP logo c_tableQR h NDEF_TYPE_IMAGE NDEF_IMAGE_PNG Image of NXP logo c_tablenxp h NDEF_TYPE_IMAGE NDEF_IMAGE_JPEG Long text message c_tabletxt h g LANG_EN Because of lack of flash memory space in LPC1227 the developer is allowed to choose just one file here otherwise the compiler returns error redefinition of c_table due to multiple declarations of the c_table By doing some easy modifications in ndef_message c file explained below the user can choose among several predefined NDEF messages
92. not ISO IEC 18092 compliant PH_ERR_10_TIMEOUT Timeout for reply expired e g target removal PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component 3 3 5 Parameter Selection This function provides ISO18092 initiator defined Parameter Selection Request then listens to the Parameter Selection Response from the Target phStatus_t phpal118092mPI_Ps1l void pDataParams In uint8_t bDsi In uint8_t bDri In uint8_t bFsl In UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 40 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 3 6 NXP Reader Library Peer to Peer User Manual pDataParams pointer to phpal1I18092mPI_Sw_DataParams_t parameter component bDsi Divisor Send data rate Send by Target to Initiator Only values from Table 5 column P2P Library identifier are legal Table 5 Table of Divisor Send Receive Chats Bit rate 1S018092 A 3 a 1S018092 bit duration kbit s Divisor D P2P Library identifier Divisor D 0 1 106 1 PHPAL _118092MPI_DATARATE_106 1 2 212 2 PHPAL _118092MPI_DATARATE_212 2 4 424 4 PHPAL_118092MPI_DATARATE_424 bDri Divisor Receive data Received by Initiator from Target Only values from Table 5 column P2P Library identifier are legal bFsl Frame Size of the Transport Data Put into this parameter one P2P
93. nsport_Reject Function prototype typedef void pphFriNfc_LlcpTransportSocketRejectCb_t void pContext NFCSTATUS status pContext pointer to user data passed to processed in the CB status refers the status of rejection procedure of disconnection request If the DM has been sent successfully status is O or NFCSTATUS_SUCCESS Send CB Called at event The local has just sent data the packet PDU to the remote Set by phlnLlcp_Transport_Send or phinLlcp_Transport_SendTo Function prototype typedef void pphFriNfc_LlcpTransportSocketSendCb_t void pContext NFCSTATUS status pContext pointer to user data passed to processed in the CB status refers the status of acceptance procedure of connection request If the data PDU frame has been sent successfully via the socket status is O or NFCSTATUS_SUCCESS Receive CB connection oriented Called at event The local has just received a data packet I PDU from the remote in connection oriented mode Set by phlnLlcp_Transport_Send Function prototype All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 36 of 76 270111 NXP Semiconductors UM1 0721 3 2 10 9 3 3 3 3 1 UM10721 NXP Reader Library Peer to Peer User Manual typedef void pphFriNfc_LlcpTransportSocketRecvCb_t void pContext NFCSTATUS status pConte
94. nt1l6_t wTlagsFound Sets bit masks indicating tags that were found int8_t bLoopMode Holds the combination of poll listen and pause mode for discover loop pErrHandlerCallback pErrHandler Pointer to the user error handler function uintl6_t wPausePeriod The delay to be used in pause mode j Initialization of the parameter structure This function initiates phacDiscLoop_Sw_DataParams_t parameter component see section 3 1 1 to zeros or default values All the components that are passed as input arguments to this function should be initialized before the call is made to start the Discovery loop phStatus_t phacDiscLoop_Sw_Init phacDiscLoop_Sw_DataParams_t pDataParams In UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 10 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 UM10721 NXP Reader Library Peer to Peer User Manual uintl6_t wSizeOfDataParams In void pHalDataParams In void pOsal In pDataParams pointer to phacDiscLoop_Sw_DataParams_t parameter component Pointers to PAL components are initialized to zero by this function Only way is to set them manually due to SetConfig function does not provide this initialization neither wSizeOfDataParams size of phacDiscLoop_Sw_DataParams_t data parameter component It is highly recommended to use standard C sifeof
95. of uri_l1 U NDEF_URI_WWW i112 sizeof uri_12 U NDEF_URI_WWW 1 13 sizeof uri_13 U NDEF_URI_HTTP uri_13 sizeof uri_13 U NDEF_URI_TEL i152 sizeof uri_52 Each time you intend to send another NDEF message than previously the source code must be recompiled Sending a fragment of SNEP message SNEP client uses LLCP Send API phinLicp_Transport_Send function which performs sending a SENP fragment as PDU frame to the SNEP server Routine for sending an PDU frame via LLCP transport socket phStatus_t NFC_LLCPSend phFriNfc_LlcpTransport_Socket_t pSocket uint8_t buf uint32_t len pphFriNfc_LlcpTransportSocketSendCb_t pSndCb static phNfc_sData_t sData phStatus_t status set the call back function if pSndCb NULL pSndCb amp SendCb sData buffer buf sData length len Using the LLCP API for sending via LLCP transport socket see section 3 2 9 10 status phlnLlcp_Transport_Send amp lnLlcpDataparams pSocket amp sData pSndCb pSocket CHECK_SUCCESS status UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 55 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual return status 4 1 11 Receiving of SNEP response The SNEP client needs to receive SNEP messages from the
96. ol which is in accordance with the LLCP acknowledgement based approach This library version supports only Passive Initiator mode Hardware abstraction layer The master devices which have no peripherals to perform any RF communication at all a reader chip needs to be connected to them The main goal of the reader chip is to convert digital signal to analog which is transmitted and carries information via RF field Apart from modulator and demodulator the PCD includes many digital registers for temporarily storing sent received data and registers for PCD configuration for key storage for cards etc In addition the reader chip is able to execute just specified commands There are several different card readers which may differ one from another in command set peripheral modules internal register addresses etc Software of HAL layer is kind of driver which enables the master device to exploit the utilities of the connected reader chip HAL layer is responsible for encapsulating and buffering raw data coming from PAL layer to the form to be processed by particular reader chip correctly It also ensures reading of received data from the reader chip in correct order There are many different reader chips but the P2P Library supports only PN512 12 and RC663 11 reader chips Only PN512 is able to perform NFC P2P Target mode but this option is not supported by this version of the P2P library Bus Abstraction Layer The Bus Abstraction Layer ensures
97. oop flow Chart ceeeeseeeeeeee 12 Flowchart of the HandleSnepStart ssseceeeeeee 61 Flowchart of HandleSendFirst esseeseeseeeeeseees 62 Flowchart of the HandleRecv part 1 64 Flowchart of the HandleRecv part 2 65 Flowchart of the HandleSendNext nesses 66 Direct flow from states of the client to GISCONNGCEL ccccceceeeeeeenceeeeeeeeeeeaeeeeeeeeeeeeaes 67 Flowchart of the HandleDisconnect sessen 67 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 270111 73 of 76 NXP Semiconductors UM10721 9 List of tables NXP Reader Library Peer to Peer User Manual Table 1 Table 2 Table 3 Table 4 Table 5 Table 6 Table 7 Table 8 Table 9 UM10721 Device and tag type for MAC layer 4 19 DSAP SSAP values ccesseceeeeesteeeeeeeees 26 Some parameters from 1SO18092 Pal COMPONENT a rieri Ghanian hans 38 Table of Length Reduction values 40 Table of Divisor Send ReCeive eceeee 41 P2P Library identifiers of the IS018092 parametel Sinoni nena e 45 Two peers and their names as called in this SECON scaer ene aretara ne EEan 49 Table of files that are part of sample application written as C headers cceeeeeceeeesseeeeeeeeeees 54 Abbreviations ccceeceeeeeeeeeeeteeeeeeeeeeeeaee 69
98. op can be controlled by values of the parameters from phacDiscLoop_Sw_DataParams_t parameter component Furthermore while running the Discovery loop information about detected and activated devices are hold by that structure Each parameter of the phacDiscLoop_Sw_DataParams_t structure is described in library file NxpRdLib_PublicRelease intfs ohacDiscLoop h Generally the structure holds information regarding to guard time for each tag type This timeout is applied after PCD is configured for particular protocol Only after the guard time Detection of that tag type is attempted number of polling loops for entire Discovery loop Number of times the Discovery loop procedure should look for cards before discovery loop gives up number of polling loops for each tag type separately mode to run Discovery loop listen and poll or vice versa and additional pause mode permission for particular tag type detection within the Discovery loop For all of the three tag types the detection can be executed or skipped separately pointers to underlaying Protocol Abstraction Layer parameter components pointers to NFC tag type components This components store information of detected tags bDetectionConfiguration Or this variable with any of PHAC_DISCLOOP_CON_POLL_A PHAC_DISCLOOP_CON_POLL_B PHAC_DISCLOOP_CON_POLL_F to allow detection of the particular configuration for detection of various tag types int8_t bState Indicates the current state ui
99. pNfcId30ut Out pDataParams pointer to phpalI18092mPI_Sw_DataParams_t parameter component pNfcld3Out the latest NFCID3 registered into PAL pDataParams component returnValues PH_ERR_SUCCESS Operation successful PH_ERR_USE_CONDITION NFCIDS value is invalid 3 3 11 Get protocol parameter Developer may use this function to get parameter value of the 15018092 PAL component phStatus_t phpal118092mPI_GetConfig void pDataParams In uintl6_t wConfig In uintl6_t wValue Out pDataParams pointer to phpalI18092mPI_Sw_DataParams_t parameter component UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 44 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual wConfig identifier of the parameter to be read from phpal118092mPI_Sw_DataParams_t parameter component Parameters that can be read are listed in Table 6 Table 6 P2P Library identifiers of the IS018092 parameters IS018092 Parameter acronym P2P Library identifier Maximal value Packet number PNi PHPAL_I18092MPI_CONFIG_PACKETNO 3 Device ID DID PHPAL_I18092MPI_CONFIG_DID 14 Node Address NAD PHPAL_I18092MPI_CONFIG_NAD 255 Target Timeout TO PHPAL_I18092MPI_CONFIG_WT 14 Frame Length FSL PHPAL_I18092MPI_CONFIG_FSL 3 Retry Count PHPAL_I18092MPI_CONFIG_MAXRETRYCOUNT 5
100. peF_P2P bAtrResLength 17 memcpy RemoteInfo RemoteDevInfo NfcIP_Info ATRInfo amp discLoop sTypeFTargetInfo sTypeF_P2P pAtrRes 17 discLoop sTypeFTargetInfo sTypeF_P2P bAtrResLength 17 Initializing the LLC link Following sample code presents how to activate LLC link After activation no transport packet can be sent because LLCP transport socket has not been connected to a DSAP phStatus_t NFC_LLCPInitialize void uint32_t DummyContext phStatus_t status PH_ERR_SUCCESS Llcp_running TRUE MIU is limit for maximal length of one LLCP frame Consequently this determines length of SNEP fragments LinkParam miu 128 LinkParam lto 100 LinkParam wks 0x0001 LinkParam option 0x02 This function initiates parameter component It stores important pointers to underlaying components status phlnLlcp_Fri_Init UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 51 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM10721 Qa sizeof em Llcp amp LinkPa amp Remote nLlcpDataparams nLlcpDataparams am amp LlcpTransport nfo bTxBuffer sizeof bTxBuffer bRxBuffer sizeof bRxBuffer amp pall18092mP1 NXP Reader Library Peer to Peer User Manual Complete link activation consists of sequence of three functions phlnLicp_Reset
101. re is any Type B tag in the field phStatus_t phacDiscLoop_Sw_Int_DetectF phacDiscLoop_Sw_DataParams_t pDataParams In pDataParams pointer to phacDiscLoop_Sw_DataParams_t parameter component If a tag type F is detected successfully then received Answer to Request type C is copied to pDataParams gt sTypeFTarget Info aTypeF 0 alDmPMm returnValues PHAC_DISCLOOP_ERR_TYPEA_NO_TAG_FOUND tag type F not detected PH_ERR_COLLISION_ERROR more tags type F in the RF field available PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component LLCP modul In the P2P Library there is logical link implemented in full compliance with LLCP specified by NFC forum 3 The purpose of the LLCP is to create manage maintain and correctly disconnect the connection among peers In result multiple logical connections between two or more peers can exist in the same time while still using the 13 54MHz RF link This has nothing to do with the anticollision nor the collision avoidance mechanism those are regarding to 15014443 and ISO18092 protocols According to LLCP specification it is possible to run up to 62 services applications peers on LLCP link connection NXP Reader Library is limited to establish the LLCP link connection with other 5 services in maximum The LLCP ensures the transmission of data or link packets separately they are just numbered from 0 to 15 for internal purposes LLC
102. s document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 59 of 76 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual When send operation is completed by the NXP P2P Library the Send socket callback is set to NULL thus need to be set with a next Transport Send API like input parameter see section 3 2 10 7 4 2 3 2 Application callback for receive The receive callback function shall be called as soon as PDU frame receive all the SNEP messages fragments are PDUs Modifying the receive flags enables performing next receive operation on the application layer see Fig 6 or Fig 9 static void RecvCb void pContext phStatus_t status sSnepClientData bRecvStart RECV_NOT_START sSnepClientData bRecvFinish RECV_FINISHED Once bRecvStart flag cleared on the application layer SNEP client there is one of two conditions fulfilled to perform listening to incoming SNEP responses see Fig 6 or Fig 9 Once bRecvFinished flag is set SNEP response can be tested see Fig 7 and Fig 8 The socket send callback function needs to be passed as parameter to ph_InLlcp_Transport_Recv see section 3 2 10 8 When send operation is completed by the NXP P2P Library the socket receive socket callback is set to NULL thus need to be set with a next Transport Send API like input parameter see section 3 2 10 7 4 2 4
103. sage 65 SNEP transmission successful e 67 Disconnect from SNEP server 67 PUT request Rejected ccceeeceeseeeeeees 68 Error on LLCP layer ceeseeeseeeeeeeeeteeeeeeeeene 68 Abbreviations ssssssssnnssnnnnsenunnnnnunnnnnnnnnnnnnennnnnnn 69 References icccecscssscersessscersestecesesssassassncererseesenenss 71 Legal information sssssssensssnnnnennnnnnnnnnnnnnnennnnnne 72 DefNMtON Siessen niniaren dansare 72 DiSCIAIMELS ceceeceeeeeeeeeeeeeceeeeeeeeeeeeeneeeetees 72 Licenses cccccceceeeeeeeeeeeeeeeeeeeeeeaeeeeeeeeeteeaes 72 Trademarks cceeeeeeeceeeeeeeeeeeeeeeeeeeeesessnneeeees 72 List of TIQUIOSiciccisicciccseessicetecssenteeesecccessncearsnenten 73 List of tables 2 ccccc ccesescccscssscsntesasaserevaresecasesacousie 74 COMPOS wie ccsceccciceceted cesetsctecsacesdeceecstescencesccesesei ee 75 NXP Reader Library Peer to Peer User Manual Please be aware that important notices concerning this document and the product s described herein have been included in the section Legal information NXP B V 2013 All rights reserved For more information please visit http www nxp com For sales office addresses please send an email to salesaddresses nxp com Date of release 24 July 2013 270111 Document identifier UM10721
104. ser Manual phStatus_t phlnLlcp_ChkLlcp void pDataParams In phinLlcp_Check_CB_t pfCheck_CB In void pContext In pDataParams pointer to phFriNfc_Llcp_t parameter component pfCheck_CB pointer to the callback function that will be called when check procedure is complete The accepted and called just for remote device type P2P Initiator or Target pContext pointer to the content input argument for the callback function returnValues FCSTATUS_INVALID_STATE LLCP link is not in PHFRINFC_LLCP_STATE_RESET_INIT state FCSTATUS_INVALID_DEVICE Device type unable to perform NFC P2P FCSTATUS_FAILED Attribute Response from remote device does not agree with LLC Magic Number PH_ERR_SUCCESS Operation successful Other Depending on implementation and underlaying component Activate LLC link This function provides basic LLC initial configuration activates LLC link and MAC layer These are all prerequisite necessary for a later flawless communication via LLC link The LLC link state is changed from checked PHFRINFC_LLCP_STATE_CHECKED to activated PHFRINFC_LLCP_STATE_ACTIVATION Before this function run it is recommended to run phinLlcp_Reset function see section 3 2 7 1 which preconfigures MAC layer internal callback correctly There are two ways how find out link parameters LTO MIU WKS OPT of the remote device Remote link parameters should have been already known from the Discovery loop sin
105. sful NECSTATUS_INVALID_PARAMETER Socketis another than connection oriented type NFCSTATUS_REJECTED Socket is already in receive pending NFCSTATUS_FAILED Operation failed Socket not connected Send data connectionless This function provides sending data via connectionless LLCP transport socket which must be already in the connected state To transmit the data the function performs on LLCP layer sending the UI PDU frame with header created according to DSAP and SSAP from the socket phStatus_t phlnLlcp_Transport_SendTo void pDataParams n phinLlcp_Transport_Socket_t pLlcpSocket n uint8_t nSap n phNfc_sData_t pBuffer n phlnLlcp_TransportSocketSendCb_t pSend_RspCb n void pContext n pDataParams pointer to phFriNfc_Llcp_t parameter component pLlcpSocket pointer to the LLCP transport socket which the data to be sent via nSap destination SAP that the data to be sent to pBuffer buffer containing the data to send Data are in the format of the phNfc_sData_t structure where n 1 bytes represents the data itself and the one byte is length of the data pSend_RspCb callback to be called when the send operation is completed pContext pointer to application data to be used in the callback returnValues NFCSTATUS_SUCCESS Operation successful NFCSTATUS_INVALID_PARAMETER Socketis another than connectionless type Socket is not bound Data in psBuffer to be sent are longer than MIU o
106. side Connection failed and not created Disconnect CB Called at event The local has just sent data packet PDU to the remote Set by phinLicp_Transport_Disconnect Function prototype typedef void pphFriNfc_LlcpTransportSocketDisconnectCb_t void pContext UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 35 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 10 5 3 2 10 6 3 2 10 7 3 2 10 8 UM10721 NXP Reader Library Peer to Peer User Manual NFCSTATUS status pContext pointer to user data passed to processed in the CB status refers to the status of disconnection procedure Following values may be passed NFCSTATUS_SUCCESS disconnection has been confirmed by the remote side Accept CB Called at event The local server has just confirmed sent CC PDU the connection request CONNECT PDU from the remote client Set by phinLicp_Transport_Accept Function prototype void pphFriNfc_LlcpTransportSocketAcceptCb_t void pContext NFCSTATUS status pContext pointer to user data passed to processed in the CB status refers the status of acceptance procedure of connection request If the socket has been connected successfully status is O or NFCSTATUS_SUCCESS Reject CB Called at event The local has just received a data packet PDU to the remote Set by phinLicp_Tra
107. ss Points Shall be assigned by the local LLC to services registered by the service 16 31 environment These registrations shall be made available by the local SDP instance for discovery and use by a remote LLC 32 63 Shall be assigned by the local LLC as the result of an upper layer service request and shall not be available for discovery using the SDP phStatus_t phlnLlcp_Transport_Bind void pDataParams In phlnLlcp_Transport_Socket_t pLlcpSocket In uint8_t nSap In phNfc_sData_t psServiceName In pDataParams pointer to phFriNfc_Llcp_t parameter component pLlcpSocket pointer to the LLCP transport socket nSap local source SAP number to bind the given socket with If this parameter is NULL a free SSAP is assigned dynamically respecting the intervals from Table 2 psServiceName pointer to service name or NULL if no service name If no service name NULL nSAP is considered as unadvertised see impact on SAP value in Table 2 returnValues NFCSTATUS_INVALID_STATE Attempt to bind a socket not created yet or already connected or bound NFCSTATUS_ALREADY_REGISTERED Passed nsa already bound to another socket NFCSTATUS_INVALID_PARAMETER The given SAP out of valid range see Table 2 The given service name already in use bound with another SAP All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1
108. stomer for the products described herein shall be limited in accordance with the Terms and conditions of commercial sale of NXP Semiconductors Right to make changes NXP Semiconductors reserves the right to make changes to information published in this document including without limitation specifications and product descriptions at any time and without notice This document supersedes and replaces all information supplied prior to the publication hereof Suitability for use NXP Semiconductors products are not designed authorized or warranted to be suitable for use in life support life critical or safety critical systems or equipment nor in applications where failure or malfunction of an NXP Semiconductors product can reasonably be expected to result in personal injury death or severe property or environmental damage NXP Semiconductors accepts no liability for inclusion and or use of NXP Semiconductors products in such equipment or applications and therefore such inclusion and or use is at the customer s own risk Applications Applications that are described herein for any of these products are for illustrative purposes only NXP Semiconductors makes no representation or warranty that such applications will be suitable for the specified use without further testing or modification Customers are responsible for the design and operation of their applications and products using NXP Semiconductors products and NXP Semiconductors ac
109. t sends connection request to the mobile device Into psUri there is passed the string urn nfc sn snep which means SNEP server service The string is sent together with the connection request saying that the local requests the remote for providing SNEP server service static phStatus_t NFC_LLCPCreateClient phFriNfc_LlcpTransport_Socket_t ppSocket phNfc_sData_t psUri phStatus_t status NFCSTATUS_SUCCESS uint32_t DummyContext status phlnLlcp_Transport_Socket amp lnLlcpDataparams phFriNfc_LlcpTransport_eConnectionOriented amp sOptions amp sWorkingBuffer ppSocket amp Errcb void amp DummyContext CHECK_SUCCESS status This assignment totally redundant because later phinLlcp_Transport_ConnectByUri function implements service discovery protocol within ppSocket gt socket_dSap 1 SocketConnected FALSE status phlnLlcp_Transport_ConnectByUri amp lnLlcpDataparams ppSocket psUri amp ConnectCb void amp DummyContext UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 53 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 NXP Reader Library Peer to Peer User Manual CHECK_SUCCESS status Program flow may be halt by bodyless loop until SocketConnected flag modified within the connect CB function Licp_running allows passing through since li
110. te_t enum in SnepClient h The states are also included in the flowcharts in Fig 5 Fig 11 Each flowchart begins in one particular input state and end at one only or one among multiple possible output states gt SafetyCnt Safety Counter which should avoid infinite loops when an unintended bhehaviour on the LLCP layer occurs gt bSendStart Send start flag ensures the same SNEP is not sent repeatedly as the SNEP client loops in a state See implementation of this flag in HandleSnepFirst Fig 6 and HandleSendNext Fig 9 functions Legal values SEND_START indicates that sending of the SNEP fragment or request has just been started SEND_NOT_START indicates that sending of a SNEP fragment or request has not been started yet This value is set inside the application callbacks SendCb and SendNULLCb gt bSendFinish Send finish flag ensures that sending is not started until previous sending finished See implementation of this flag in HandleSnepFirst Fig 6 and HandleSendNext Fig 9 functions Legal values SEND_FINISHED indicates that sending of a SNEP fragment has just been completed This value is set inside the application callbacks Sendcb and SendNULLCb SEND_NOT_FINISHED indicates that sending of a SNEP fragment is currently in progress Note This flag is implemented in the application layer SNEP client and it is not directly influenced by the LLCP layer Alternatively this could be implemented
111. the reception on the LLCP DummySend is clarified in section 4 1 11 Since then the client s state is set to receive SNEP response from the server is expected see section 4 2 8 Handling of the SENP response phStatus_t HandleRecv SnepClientData_t pClientData As soon any SNEP Response from the SNEP server received bRecvFinish flag is set to RECV_FINISHED by the application receive callback RecvCb is this handler parses the response Each software flow branch is matched with the particular SNEP response If everything on the client s and server s side goes correctly then the client goes only twice through the cases of this handler First time after sending Put request and subsequently receiving Continue response Second time after sending the last fragment of the SNEP message and subsequently receiving the Success response UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 63 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM10721 NXP Reader Library Peer to Peer User Manual RECEIVE recv_finished NOT OK weve data format OK Recv data lt Rx_buff CONTINUE 0x80 NOT_FOUND OxCO ves EXCESS DATA OxC1 ves BAD_REQUEST OxC2 1 The second part of the flowchart is in Fig 8 Fig 7 Flowchart of the HandleRecv part 1 RECEIVE ERROR SEND_N
112. to be used in the callback returnValues NECSTATUS_INVALID_PARAMETER Non connection oriented socket This socket is already listening and it is pending NFCSTATUS_INVALID_STATE Socket in other state than socket bound PH_ERR_SUCCESS Operation successful 3 2 9 7 Accept an incoming connection request This function is used to accept an incoming connection request the client to accept an incoming connection request It must be used with the socket provided within the listen callback The socket is implicitly switched to the connected state when the function is called phStatus_t phlnLlcp_Transport_Accept void pDataParams n phinLlcp_Transport_Socket_t pLlcpSocket n phlnLlcp_Transport_sSocketOptions_t pOptions n phNfc_sData_t psWorkingBuffer n phinLlcp_TransportSocketErrCb_t pErr_Cb n phlinLlcp_TransportSocketAcceptCbh_t pAccept_RspCb n void pContext n pDataParams pointer to phFriNfc_Llcp_t parameter component pLicpSocket pointer to the transport socket pOptions options to be used with the socket UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 29 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 3 2 9 8 3 2 9 9 UM10721 NXP Reader Library Peer to Peer User Manual psWorkingBuffer a working buffer to be used by the library pErr_Cb error callb
113. tocol OSAL software timers Fig 3 NXP Reader Library P2P As seen on Fig 3 vertical structure of the NXP Reader Library is classified into following layers e API layer gt MIFARE Cards command set gt NFC Activity gt NFC P2P package e Logical Link Control Protocol LLCP e Protocol abstraction layer PAL e Hardware abstraction layer HAL e Bus abstraction layer BAL e Common layer gt Software timers and timer handlers UM10721 All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual Rev 1 1 24 July 2013 6 of 76 COMPANY PUBLIC 270111 NXP Semiconductors UM1 0721 2 2 1 2 2 1 1 2 2 1 2 2 2 1 3 2 2 2 UM10721 NXP Reader Library Peer to Peer User Manual API layer The uppermost API layer is divided into three individual and independent modules taking place on one layer vertically equal Each provides different services which are designed like APIs to be implemented into customer s application yellow Card command sets This module 1 in Fig 3 provides software implementation of certain commands of MIFARE cards 4 5 6 Commands enable to access memory and execute certain operations on the particular card specified in datasheet of the card NFC Activity This module 2 in Fig 3 provides probing the RF field in loop with finding out the card type of detected cards additional possibility to re
114. when the event occurs Function prototype although the function body may be defined by the user the function header and return value need to agree with the CB function prototype defined by the P2P library Function may be a type void Input arguments are explained one by one In general there are two input arguments passed to the called CB The first input argument passed to each CB is pContext pointer to application layer data of any type The pointer needs to be passed to the dedicated LLCP Link API or LLCP Transport Socket API function from section 3 2 7 or 3 2 9 respectively in the same time as pointer to CB function The data may be later used during the CB function execution The second on third argument if any are information passed by the caller of the CB from within the P2P library giving precious information about the event related circumstances There are two types of callbacks in general Link related callbacks and socket related callbacks The link callbacks are called when link status changes from activated to deactivated or vice versa The socket callbacks are triggered on dedicated socket events All information provided in this document is subject to legal disclaimers NXP B V 2013 All rights reserved User manual COMPANY PUBLIC Rev 1 1 24 July 2013 18 of 76 270111 NXP Semiconductors UM1 0721 3 2 5 3 2 6 UM10721 NXP Reader Library Peer to Peer User Manual SYMM The NFC forum def
115. xt pointer to user data passed to processed in the CB status refers to the status of reception procedure If the incoming packet has been received without an error in accordance with LLCP status is 0 or NFCSTATUS_SUCCESS Receive CB connectionless Receive from is notification about information packet has just been received from a remote in connectionless mode Called at event The local has just received data packet UI PDU from the remote in connectionless mode Set by Function prototype typedef void pphFriNfc_LlcpTransportSocketRecvFromCb_t void pContext uint8_t ssap NFCSTATUS status pContext pointer to user data passed to processed in the CB ssap source SAP the data coming from status refers to the status of reception procedure If the incoming packet has been received without an error in accordance with LLCP status is 0 or NFCSTATUS_SUCCESS Protocol layer 15018092 protocol commands All the LLCP packets must be encapsulated regardless of their purpose on the Link layer data carrying packets and link maintenance packets as well S018092 protocol ensures encapsulating link layer packets into final binary format which is ready to be transmitted via RF NXP P2P Library version supports just Passive Initiator mode Since the LLCP is acknowledgement based communication 15018092 PAL exchange function awaits response from another peer within defined time period Thus an MCU implementing the P2P Library sen

Download Pdf Manuals

image

Related Search

Related Contents

ProteOn™ XPR36 Experimental Design and Application - Bio-Rad  Viking Pump Technical Service Manual 270.1 for Industrial Rotary  Videotec HGV52K1A100 camera housing  取扱説明書 - スリーアールシステム  Operating Instructions for the PhosBan Reactor 550 ™  JVC GR-DVL715 Camcorder User Manual  Corsair Graphite Series 380T    Paxar Monarch 9805 Thermal Label Printer    

Copyright © All rights reserved.
Failed to retrieve file