diff options
-rw-r--r-- | inc/phNfcHalTypes.h | 7 | ||||
-rw-r--r-- | src/phHal4Nfc.c | 5 | ||||
-rw-r--r-- | src/phHciNfc_WI.c | 30 | ||||
-rw-r--r-- | src/phLibNfc.c | 1 | ||||
-rw-r--r-- | src/phLibNfc.h | 6 | ||||
-rw-r--r-- | src/phLibNfc_Internal.h | 3 | ||||
-rw-r--r-- | src/phLibNfc_SE.c | 45 | ||||
-rw-r--r-- | src/phLibNfc_initiator.c | 8 |
8 files changed, 100 insertions, 5 deletions
diff --git a/inc/phNfcHalTypes.h b/inc/phNfcHalTypes.h index 748f01b..a242450 100644 --- a/inc/phNfcHalTypes.h +++ b/inc/phNfcHalTypes.h @@ -835,7 +835,12 @@ typedef enum phHal_Event { /* NXP Specific System Information Events */ NFC_INFO_TXLDO_OVERCUR = 0x71U, NFC_INFO_MEM_VIOLATION = 0x73U, - NFC_INFO_TEMP_OVERHEAT = 0x74U + NFC_INFO_TEMP_OVERHEAT = 0x74U, + + /* NXP EVENTS */ + NFC_EVT_MIFARE_ACCESS = 0x35, + NFC_EVT_APDU_RECEIVED = 0x36, + NFC_EVT_EMV_CARD_REMOVAL = 0x37 }phHal_Event_t; diff --git a/src/phHal4Nfc.c b/src/phHal4Nfc.c index ebd447f..3e7c163 100644 --- a/src/phHal4Nfc.c +++ b/src/phHal4Nfc.c @@ -1240,7 +1240,10 @@ static void phHal4Nfc_HandleEvent( case NFC_EVT_START_OF_TRANSACTION: case NFC_EVT_END_OF_TRANSACTION: case NFC_EVT_CONNECTIVITY: - case NFC_EVT_OPERATION_ENDED: + case NFC_EVT_OPERATION_ENDED: + case NFC_EVT_MIFARE_ACCESS: + case NFC_EVT_APDU_RECEIVED: + case NFC_EVT_EMV_CARD_REMOVAL: sNotificationInfo.info = psEventInfo; sNotificationInfo.status = NFCSTATUS_SUCCESS; sNotificationInfo.type = NFC_EVENT_NOTIFICATION; diff --git a/src/phHciNfc_WI.c b/src/phHciNfc_WI.c index 4da2078..e1310a4 100644 --- a/src/phHciNfc_WI.c +++ b/src/phHciNfc_WI.c @@ -63,6 +63,9 @@ /****************** Static Function Declaration **************************/ +static uint8_t paypass_removal[2] = {0x50, 0x00}; +static uint8_t mifare_access = 0x60; + static NFCSTATUS phHciNfc_Recv_WI_Response( @@ -700,12 +703,33 @@ phHciNfc_Recv_WI_Event( EventInfo.eventType = NFC_EVT_TRANSACTION; EventInfo.eventInfo.aid.buffer = (uint8_t *)p_wi_info->aid; /* check for AID data is at least 1 byte is their */ - if(length > HCP_HEADER_LEN) + if (length > HCP_HEADER_LEN) { EventInfo.eventInfo.aid.length = length - HCP_HEADER_LEN; - (void) memcpy((void *)p_wi_info->aid,message->payload, - EventInfo.eventInfo.aid.length ); + memcpy((void *)p_wi_info->aid, message->payload, + EventInfo.eventInfo.aid.length ); + } + + /* Filter Transaction event */ + if (EventInfo.eventInfo.aid.length == 4) + { + EventInfo.eventType = NFC_EVT_APDU_RECEIVED; + } + else if (EventInfo.eventInfo.aid.length == 2) + { + if (!memcmp(paypass_removal, EventInfo.eventInfo.aid.buffer, EventInfo.eventInfo.aid.length)) + { + EventInfo.eventType = NFC_EVT_EMV_CARD_REMOVAL; + } + else if(mifare_access == EventInfo.eventInfo.aid.buffer[0]) + { + EventInfo.eventType = NFC_EVT_MIFARE_ACCESS; + } } + + EventInfo.eventInfo.aid.buffer = (uint8_t *)p_wi_info->aid; + (void) memcpy((void *)p_wi_info->aid,message->payload, + EventInfo.eventInfo.aid.length ); break; } default: diff --git a/src/phLibNfc.c b/src/phLibNfc.c index 9c7db4f..c08d044 100644 --- a/src/phLibNfc.c +++ b/src/phLibNfc.c @@ -580,6 +580,7 @@ NFCSTATUS phLibNfc_Mgt_Reset(void *pContext) } /* No device is connected */ gpphLibContext->Connected_handle = 0x00; + gpphLibContext->Prev_Connected_handle = 0x00; gpphLibContext->ReleaseType = NFC_INVALID_RELEASE_TYPE; gpphLibContext->eLibNfcCfgMode = NFC_DISCOVERY_STOP; /*Lib Nfc Stack is initilized and in idle state*/ diff --git a/src/phLibNfc.h b/src/phLibNfc.h index 216196f..790d619 100644 --- a/src/phLibNfc.h +++ b/src/phLibNfc.h @@ -173,6 +173,12 @@ typedef enum ETSI TS 102 622 V7.4.0 */ phLibNfc_eSE_EvtFieldOn, // consider using phLibNfc_eSE_EvtConnectivity phLibNfc_eSE_EvtFieldOff, + + phLibNfc_eSE_EvtApduReceived, /* PAYPASS MagStripe or MCHIP_4 transaction */ + + phLibNfc_eSE_EvtCardRemoval, /* Indicates the beginning of an EMV Card Removal sequence */ + + phLibNfc_eSE_EvtMifareAccess /* Indicates when the SMX Emulation MIFARE is accessed */ } phLibNfc_eSE_EvtType_t; /** diff --git a/src/phLibNfc_Internal.h b/src/phLibNfc_Internal.h index 10018ec..304ac22 100644 --- a/src/phLibNfc_Internal.h +++ b/src/phLibNfc_Internal.h @@ -221,6 +221,9 @@ typedef struct phLibNfc_LibContext uint32_t Connected_handle, Discov_handle[MAX_REMOTE_DEVICES]; + /* To store the previous connected handle in case of Multiple protocol tags */ + uint32_t Prev_Connected_handle; + /*Call back function pointers */ phLibNfc_eDiscoveryConfigMode_t eLibNfcCfgMode; diff --git a/src/phLibNfc_SE.c b/src/phLibNfc_SE.c index 5fa4e08..4e839cf 100644 --- a/src/phLibNfc_SE.c +++ b/src/phLibNfc_SE.c @@ -204,6 +204,51 @@ STATIC void phLibNfc_SeNotification(void *context, status); break; } + + case NFC_EVT_APDU_RECEIVED: + { + if ((pEvtInfo->eventInfo.aid.length != 0) && ((pEvtInfo->eventInfo.aid.length <= 16))) + { + /* Copy received APDU to aid buffer. */ + Se_Trans_Info.UiccEvtInfo.aid.buffer = pEvtInfo->eventInfo.aid.buffer; + Se_Trans_Info.UiccEvtInfo.aid.length = pEvtInfo->eventInfo.aid.length; + } + + (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)( + pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt, + phLibNfc_eSE_EvtApduReceived, + pSeInfo->hSecureElement, + &Se_Trans_Info, + status); + break; + } + + case NFC_EVT_MIFARE_ACCESS: + { + /* copy the Block MIFARE accessed */ + Se_Trans_Info.UiccEvtInfo.aid.buffer = pEvtInfo->eventInfo.aid.buffer; + Se_Trans_Info.UiccEvtInfo.aid.length = pEvtInfo->eventInfo.aid.length; + + (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)( + pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt, + phLibNfc_eSE_EvtMifareAccess, + pSeInfo->hSecureElement, + &Se_Trans_Info, + status); + break; + } + + case NFC_EVT_EMV_CARD_REMOVAL: + { + (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)( + pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt, + phLibNfc_eSE_EvtCardRemoval, + pSeInfo->hSecureElement, + &Se_Trans_Info, + status); + break; + } + case NFC_EVT_END_OF_TRANSACTION: { (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)( diff --git a/src/phLibNfc_initiator.c b/src/phLibNfc_initiator.c index 340af78..2a03c05 100644 --- a/src/phLibNfc_initiator.c +++ b/src/phLibNfc_initiator.c @@ -548,6 +548,9 @@ phLibNfc_RemoteDev_ReConnect ( gpphLibContext->CBInfo.pClientConCntx = pContext; gpphLibContext->status.GenCb_pending_status = TRUE; gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConnect; + + gpphLibContext->Prev_Connected_handle = gpphLibContext->Connected_handle; + gpphLibContext->Connected_handle = hRemoteDevice; } else if (NFCSTATUS_INVALID_REMOTE_DEVICE == PHNFCSTATUS(ret_val)) @@ -633,6 +636,7 @@ NFCSTATUS phLibNfc_RemoteDev_Connect( gpphLibContext->CBInfo.pClientConCntx = pContext; gpphLibContext->status.GenCb_pending_status=TRUE; gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConnect; + gpphLibContext->Prev_Connected_handle = gpphLibContext->Connected_handle; gpphLibContext->Connected_handle = hRemoteDevice; } else if(PHNFCSTATUS(RetVal) == NFCSTATUS_INVALID_REMOTE_DEVICE) @@ -757,6 +761,7 @@ STATIC void phLibNfc_RemoteDev_Connect_Cb( /* If remote device is invalid return as TARGET LOST to upper layer*/ /* If error code is other than SUCCESS return NFCSTATUS_TARGET_LOST */ Connect_status = NFCSTATUS_TARGET_LOST; + gpphLibContext->Connected_handle = gpphLibContext->Prev_Connected_handle ; } gpphLibContext->ndef_cntx.is_ndef = CHK_NDEF_NOT_DONE; /* Update the Current Sate*/ @@ -896,6 +901,9 @@ STATIC void phLibNfc_RemoteDev_Disconnect_cb( gpphLibContext->LastTrancvSuccess = FALSE; /*Reset Connected handle */ gpphLibContext->Connected_handle=0x0000; + /*Reset previous Connected handle */ + gpphLibContext->Prev_Connected_handle = 0x0000; + if(gpphLibContext->sSeContext.eActivatedMode == phLibNfc_SE_ActModeWired) { gpphLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeDefault; |