summaryrefslogtreecommitdiffstats
path: root/src/phLibNfc_SE.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/phLibNfc_SE.c')
-rw-r--r--src/phLibNfc_SE.c111
1 files changed, 109 insertions, 2 deletions
diff --git a/src/phLibNfc_SE.c b/src/phLibNfc_SE.c
index 5fa4e08..968c239 100644
--- a/src/phLibNfc_SE.c
+++ b/src/phLibNfc_SE.c
@@ -135,7 +135,7 @@ STATIC void phLibNfc_SeNotification(void *context,
{
pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)context;
phHal_sEventInfo_t *pEvtInfo = NULL;
- phLibNfc_uSeEvtInfo_t Se_Trans_Info={0};
+ phLibNfc_uSeEvtInfo_t Se_Trans_Info={{{0,0},{0,0}}};
phLibNfc_SE_List_t *pSeInfo=NULL;
if(pLibContext != gpphLibContext)
@@ -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)(
@@ -428,7 +473,6 @@ NFCSTATUS phLibNfc_SE_SetMode ( phLibNfc_Handle hSE_Handle,
switch(eActivation_mode)
{
case phLibNfc_SE_ActModeVirtual:
- case phLibNfc_SE_ActModeDefault:
{
if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
{
@@ -462,6 +506,69 @@ NFCSTATUS phLibNfc_SE_SetMode ( phLibNfc_Handle hSE_Handle,
}
}
break;
+ case phLibNfc_SE_ActModeVirtualVolatile:
+ {
+ if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
+ {
+ eEmulationType = NFC_SMARTMX_EMULATION;
+ /*Enable the SMX -External reader can see it*/
+ pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation = TRUE;
+ pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeVirtualVolatile;
+
+ Status = phHal4Nfc_Switch_SMX_Mode(
+ pLibContext->psHwReference,
+ eSmartMx_Virtual,
+ phLibNfc_SE_SetMode_cb,
+ pLibContext
+ );
+ }
+ else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
+ {
+ eEmulationType = NFC_UICC_EMULATION;
+ /*Enable the UICC -External reader can see it*/
+ pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc = TRUE;
+ pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeVirtualVolatile;
+
+ Status = phHal4Nfc_Switch_Swp_Mode(
+ pLibContext->psHwReference,
+ eSWP_Switch_On,
+ phLibNfc_SE_SetMode_cb,
+ pLibContext
+ );
+ }
+ else
+ {
+ Status = NFCSTATUS_INVALID_HANDLE;
+ }
+ }
+ break;
+ case phLibNfc_SE_ActModeDefault:
+ {
+ if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
+ {
+ Status = phHal4Nfc_Switch_SMX_Mode(
+ pLibContext->psHwReference,
+ eSmartMx_Default,
+ phLibNfc_SE_SetMode_cb,
+ pLibContext
+ );
+ }
+ else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
+ {
+ Status = phHal4Nfc_Switch_Swp_Mode(
+ pLibContext->psHwReference,
+ eSWP_Switch_Default,
+ phLibNfc_SE_SetMode_cb,
+ pLibContext
+ );
+ }
+ else
+ {
+ Status = NFCSTATUS_INVALID_HANDLE;
+ }
+ }
+ break;
+
case phLibNfc_SE_ActModeWired:
{
if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)