2 * Copyright (C) 2010 NXP Semiconductors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * Project: NFC FRI / HALDL
22 * $Date: Thu Apr 22 13:59:50 2010 $
25 * $Aliases: NFC_FRI1.1_WK1014_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1019_SDK,NFC_FRI1.1_WK1024_SDK $
30 ************************* Header Files ***************************************
33 #include <phNfcStatus.h>
35 #include <phHal4Nfc.h>
36 #include <phOsalNfc.h>
37 #include <phLibNfc_Internal.h>
38 #include <phLibNfc_SE.h>
39 #include <phLibNfc_ndef_raw.h>
40 #include <phLibNfc_initiator.h>
41 #include <phLibNfc_discovery.h>
44 *************************** Macro's ****************************************
47 #ifndef STATIC_DISABLE
54 *************************** Global Variables **********************************
57 /*This Structure contains the Secure Element information*/
58 phLibNfc_SE_List_t sSecuredElementInfo[PHLIBNFC_MAXNO_OF_SE];
61 *************************** Static Function Declaration ***********************
64 /* Response callback for SE Set Mode*/
66 void phLibNfc_SE_SetMode_cb(void *context, NFCSTATUS status);
69 /* SE register listner response notification */
71 void phLibNfc_SeNotification(void *context,
72 phHal_eNotificationType_t type,
73 phHal4Nfc_NotificationInfo_t info,
77 *************************** Function Definitions ******************************
81 * Registers notification handler to handle secure element specific events
83 NFCSTATUS phLibNfc_SE_NtfRegister (
84 pphLibNfc_SE_NotificationCb_t pSE_NotificationCb,
88 NFCSTATUS Status = NFCSTATUS_SUCCESS;
89 pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)gpphLibContext;
91 if((NULL == gpphLibContext) ||
92 (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
94 Status = NFCSTATUS_NOT_INITIALISED;
96 else if((pSE_NotificationCb == NULL)
99 /*parameters sent by upper layer are not valid*/
100 Status = NFCSTATUS_INVALID_PARAMETER;
102 else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
104 Status = NFCSTATUS_SHUTDOWN;
108 /*Register SE notification with lower layer.
109 Any activity on Smx or UICC will be notified */
110 Status = phHal4Nfc_RegisterNotification(
111 pLibContext->psHwReference,
112 eRegisterSecureElement,
113 phLibNfc_SeNotification,
115 if(Status == NFCSTATUS_SUCCESS)
117 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb = pSE_NotificationCb;
118 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt=pContext;
122 /* Registration failed */
123 Status = NFCSTATUS_FAILED;
129 * SE Notification events are notified with this callback
131 STATIC void phLibNfc_SeNotification(void *context,
132 phHal_eNotificationType_t type,
133 phHal4Nfc_NotificationInfo_t info,
136 pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)context;
137 phHal_sEventInfo_t *pEvtInfo = NULL;
138 phLibNfc_uSeEvtInfo_t Se_Trans_Info={{{0,0},{0,0}}};
139 phLibNfc_SE_List_t *pSeInfo=NULL;
141 if(pLibContext != gpphLibContext)
143 /*wrong context returned*/
144 phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1);
148 if((status == NFCSTATUS_SUCCESS) && (type == NFC_EVENT_NOTIFICATION))
150 pEvtInfo = info.psEventInfo;
151 status = NFCSTATUS_SUCCESS;
152 if((pEvtInfo->eventSource == phHal_ePICC_DevType )
153 && (pEvtInfo->eventHost == phHal_eHostController) )
155 sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_Type = phLibNfc_SE_Type_SmartMX;
156 /* Smartx Mx is Activated */
157 pSeInfo = &sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX];
159 if(pEvtInfo->eventHost == phHal_eUICCHost)
161 /* UICC is Activate */
162 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_Type = phLibNfc_SE_Type_UICC;
163 pSeInfo = &sSecuredElementInfo[LIBNFC_SE_UICC_INDEX];
167 /*presently Smx event source is not supported */
171 switch(pEvtInfo->eventType)
173 case NFC_EVT_TRANSACTION:
175 if((pEvtInfo->eventInfo.aid.length != 0) && ((pEvtInfo->eventInfo.aid.length <= 16))) // PLG
177 /*copy the Application id on which transaction happened*/
178 Se_Trans_Info.UiccEvtInfo.aid.buffer =pEvtInfo->eventInfo.aid.buffer;
179 Se_Trans_Info.UiccEvtInfo.aid.length =pEvtInfo->eventInfo.aid.length;
184 Se_Trans_Info.UiccEvtInfo.aid.buffer = NULL;
185 Se_Trans_Info.UiccEvtInfo.aid.length = 0;
187 if((pEvtInfo->eventHost == phHal_eUICCHost)
188 && (info.psEventInfo->eventInfo.uicc_info.param.length
191 /*copy the parameters info on which transaction happened*/
192 Se_Trans_Info.UiccEvtInfo.param.buffer =
193 info.psEventInfo->eventInfo.uicc_info.param.buffer;
194 Se_Trans_Info.UiccEvtInfo.param.length =
195 info.psEventInfo->eventInfo.uicc_info.param.length;
197 /*Notify to upper layer that transaction had happened on the
198 one of the application stored in UICC or Smx*/
199 (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
200 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
201 phLibNfc_eSE_EvtStartTransaction,
202 pSeInfo->hSecureElement,
208 case NFC_EVT_APDU_RECEIVED:
210 if ((pEvtInfo->eventInfo.aid.length != 0) && ((pEvtInfo->eventInfo.aid.length <= 16)))
212 /* Copy received APDU to aid buffer. */
213 Se_Trans_Info.UiccEvtInfo.aid.buffer = pEvtInfo->eventInfo.aid.buffer;
214 Se_Trans_Info.UiccEvtInfo.aid.length = pEvtInfo->eventInfo.aid.length;
217 (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
218 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
219 phLibNfc_eSE_EvtApduReceived,
220 pSeInfo->hSecureElement,
226 case NFC_EVT_MIFARE_ACCESS:
228 /* copy the Block MIFARE accessed */
229 Se_Trans_Info.UiccEvtInfo.aid.buffer = pEvtInfo->eventInfo.aid.buffer;
230 Se_Trans_Info.UiccEvtInfo.aid.length = pEvtInfo->eventInfo.aid.length;
232 (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
233 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
234 phLibNfc_eSE_EvtMifareAccess,
235 pSeInfo->hSecureElement,
241 case NFC_EVT_EMV_CARD_REMOVAL:
243 (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
244 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
245 phLibNfc_eSE_EvtCardRemoval,
246 pSeInfo->hSecureElement,
252 case NFC_EVT_END_OF_TRANSACTION:
254 (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
255 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
256 phLibNfc_eSE_EvtEndTransaction,
257 pSeInfo->hSecureElement,
262 case NFC_EVT_CONNECTIVITY:
264 (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
265 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
266 phLibNfc_eSE_EvtConnectivity,
267 pSeInfo->hSecureElement,
272 case NFC_EVT_START_OF_TRANSACTION:
274 (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
275 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
276 phLibNfc_eSE_EvtTypeTransaction,
277 pSeInfo->hSecureElement,
282 case NFC_EVT_FIELD_ON:
284 (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
285 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
286 phLibNfc_eSE_EvtFieldOn,
287 pSeInfo->hSecureElement,
292 case NFC_EVT_FIELD_OFF:
294 (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
295 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
296 phLibNfc_eSE_EvtFieldOff,
297 pSeInfo->hSecureElement,
318 * Unregister the Secured Element Notification.
320 NFCSTATUS phLibNfc_SE_NtfUnregister(void)
322 NFCSTATUS Status = NFCSTATUS_SUCCESS;
323 pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)gpphLibContext;
325 if((NULL == gpphLibContext) ||
326 (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
328 /*Lib Nfc is not initialized*/
329 Status = NFCSTATUS_NOT_INITIALISED;
331 else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
333 Status = NFCSTATUS_SHUTDOWN;
337 /*Unregister SE event notification with lower layer.
338 even some transaction happens on UICC or Smx will not
339 be notified afterworlds */
340 Status = phHal4Nfc_UnregisterNotification(
341 pLibContext->psHwReference,
342 eRegisterSecureElement,
344 if(Status != NFCSTATUS_SUCCESS)
346 /*Unregister failed*/
347 Status=NFCSTATUS_FAILED;
349 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb=NULL;
350 pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt=NULL;
356 * Get list of available Secure Elements
358 NFCSTATUS phLibNfc_SE_GetSecureElementList(
359 phLibNfc_SE_List_t* pSE_List,
363 NFCSTATUS Status = NFCSTATUS_SUCCESS;
364 uint8_t uNo_Of_SE = 0;
366 if((NULL == gpphLibContext) ||
367 (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
369 Status = NFCSTATUS_NOT_INITIALISED;
371 else if((NULL ==pSE_List) || (NULL ==uSE_count))
373 Status = NFCSTATUS_INVALID_PARAMETER;
375 else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
377 Status = NFCSTATUS_SHUTDOWN;
381 /*Check for which type of Secure Element is available*/
382 if(gpphLibContext->psHwReference->uicc_connected==TRUE)
384 /* Populate the UICC type */
385 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_Type = phLibNfc_SE_Type_UICC;
387 /* Populate the UICC handle */
388 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement =(phLibNfc_Handle)
389 (LIBNFC_SE_UICC_INDEX + LIBNFC_SE_BASE_HANDLE);
391 #ifdef NXP_HAL_ENABLE_SMX
393 pSE_List[LIBNFC_SE_UICC_INDEX].eSE_Type =
394 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_Type;
395 pSE_List[LIBNFC_SE_UICC_INDEX].hSecureElement = (phLibNfc_Handle)
396 (LIBNFC_SE_UICC_INDEX + LIBNFC_SE_BASE_HANDLE);
397 pSE_List[LIBNFC_SE_UICC_INDEX].eSE_CurrentState =
398 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState;
401 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_Type;
402 pSE_List->hSecureElement = (phLibNfc_Handle)
403 (LIBNFC_SE_UICC_INDEX + LIBNFC_SE_BASE_HANDLE);
404 pSE_List->eSE_CurrentState =
405 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState;
407 /* update the No of SE retrieved */
411 if (gpphLibContext->psHwReference->smx_connected ==TRUE)
413 /* if the Smx is also connected to the PN544 */
414 /* Populate the SMX type */
415 sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_Type = phLibNfc_SE_Type_SmartMX;
417 /* Populate the SMX handle */
418 sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement =(phLibNfc_Handle)
419 (LIBNFC_SE_SMARTMX_INDEX + LIBNFC_SE_BASE_HANDLE);
420 pSE_List[LIBNFC_SE_SMARTMX_INDEX].eSE_Type =
421 sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_Type;
422 pSE_List[LIBNFC_SE_SMARTMX_INDEX].hSecureElement = (phLibNfc_Handle)
423 (LIBNFC_SE_SMARTMX_INDEX + LIBNFC_SE_BASE_HANDLE);
424 pSE_List[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState =
425 sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState;
427 /* update the No of SE retrieved */
431 *uSE_count = uNo_Of_SE;
437 * Sets secure element mode.
438 * This function configures SE to specific mode based on activation mode type
441 NFCSTATUS phLibNfc_SE_SetMode ( phLibNfc_Handle hSE_Handle,
442 phLibNfc_eSE_ActivationMode eActivation_mode,
443 pphLibNfc_SE_SetModeRspCb_t pSE_SetMode_Rsp_cb,
447 NFCSTATUS Status = NFCSTATUS_SUCCESS;
448 phHal_eEmulationType_t eEmulationType = NFC_SMARTMX_EMULATION;
449 pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)gpphLibContext;
451 if((NULL == gpphLibContext) ||
452 (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
454 Status = NFCSTATUS_NOT_INITIALISED;
456 else if((pSE_SetMode_Rsp_cb ==NULL)
457 ||(NULL == pContext)||(NULL==(void *)hSE_Handle))
459 Status=NFCSTATUS_INVALID_PARAMETER;
461 else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
463 Status = NFCSTATUS_SHUTDOWN;
465 else if((pLibContext->status.GenCb_pending_status == TRUE)
466 ||(NULL!=pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb))
468 /*previous callback is pending still*/
469 Status =NFCSTATUS_REJECTED;
473 switch(eActivation_mode)
475 case phLibNfc_SE_ActModeVirtual:
477 if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
479 eEmulationType = NFC_UICC_EMULATION;
480 /*Enable the UICC -External reader can see it*/
481 pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc = TRUE;
483 else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
485 eEmulationType = NFC_SMARTMX_EMULATION;
486 /*Enable the SMX -External reader can see it*/
487 pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation = TRUE;
491 Status=NFCSTATUS_INVALID_HANDLE;
493 if(Status==NFCSTATUS_SUCCESS)
495 if(pLibContext->sSeContext.eActivatedMode != phLibNfc_SE_ActModeWired)
497 pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeVirtual;
499 pLibContext->sCardEmulCfg.emuType = eEmulationType;
500 Status = phHal4Nfc_ConfigParameters(
501 pLibContext->psHwReference,
502 NFC_EMULATION_CONFIG,
503 (phHal_uConfig_t*)&pLibContext->sCardEmulCfg,
504 phLibNfc_SE_SetMode_cb,
509 case phLibNfc_SE_ActModeVirtualVolatile:
511 if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
513 eEmulationType = NFC_SMARTMX_EMULATION;
514 /*Enable the SMX -External reader can see it*/
515 pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation = TRUE;
516 pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeVirtualVolatile;
518 Status = phHal4Nfc_Switch_SMX_Mode(
519 pLibContext->psHwReference,
521 phLibNfc_SE_SetMode_cb,
525 else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
527 eEmulationType = NFC_UICC_EMULATION;
528 /*Enable the UICC -External reader can see it*/
529 pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc = TRUE;
530 pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeVirtualVolatile;
532 Status = phHal4Nfc_Switch_Swp_Mode(
533 pLibContext->psHwReference,
535 phLibNfc_SE_SetMode_cb,
541 Status = NFCSTATUS_INVALID_HANDLE;
545 case phLibNfc_SE_ActModeDefault:
547 if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
549 Status = phHal4Nfc_Switch_SMX_Mode(
550 pLibContext->psHwReference,
552 phLibNfc_SE_SetMode_cb,
556 else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
558 Status = phHal4Nfc_Switch_Swp_Mode(
559 pLibContext->psHwReference,
561 phLibNfc_SE_SetMode_cb,
567 Status = NFCSTATUS_INVALID_HANDLE;
572 case phLibNfc_SE_ActModeWired:
574 if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
576 if(pLibContext->CBInfo.pClientNtfRegRespCB!=NULL)
578 /*Disable the SMX -External reader can't see it anymore*/
579 pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation = FALSE;
580 pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeWired;
582 Status = phHal4Nfc_Switch_SMX_Mode(
583 pLibContext->psHwReference,
585 phLibNfc_SE_SetMode_cb,
590 else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
592 /*This mode is not applicable to UICC*/
593 Status = NFCSTATUS_REJECTED;
597 Status = NFCSTATUS_INVALID_HANDLE;
602 case phLibNfc_SE_ActModeOff:
604 /*UICC emulation deactivate*/
605 if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
607 eEmulationType = NFC_UICC_EMULATION;
608 /*Disable the UICC -External reader can't see it anymore*/
609 pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc = FALSE;
612 else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
614 eEmulationType = NFC_SMARTMX_EMULATION;
615 /*Disable the SMX -External reader can't see it anymore*/
616 pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation=FALSE;
621 Status = NFCSTATUS_INVALID_HANDLE;
623 if(Status==NFCSTATUS_SUCCESS)
625 pLibContext->sCardEmulCfg.emuType = eEmulationType;
627 if(pLibContext->sSeContext.eActivatedMode != phLibNfc_SE_ActModeWired)
629 pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeOff;
632 Status = phHal4Nfc_ConfigParameters(pLibContext->psHwReference,
633 NFC_EMULATION_CONFIG,
634 (phHal_uConfig_t*)&pLibContext->sCardEmulCfg,
635 phLibNfc_SE_SetMode_cb,
641 Status=NFCSTATUS_INVALID_PARAMETER;
644 }/*End of eActivation_mode switch */
645 if(Status==NFCSTATUS_PENDING)
647 pLibContext->sSeContext.hSetemp=hSE_Handle;
648 pLibContext->status.GenCb_pending_status = TRUE;
649 pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb = pSE_SetMode_Rsp_cb;
650 pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt=pContext;
652 else if(Status == NFCSTATUS_INVALID_HANDLE)
658 Status = NFCSTATUS_FAILED;
664 * Callback for Se Set mode
666 STATIC void phLibNfc_SE_SetMode_cb(void *context, NFCSTATUS status)
668 pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)context;
669 pphLibNfc_SE_SetModeRspCb_t pUpperLayerCb=NULL;
670 void *pUpperContext=NULL;
671 phLibNfc_Handle hSeHandle=0;
672 uint8_t TempState=FALSE;
674 if(pLibContext != gpphLibContext)
676 /*wrong context returned*/
677 phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1);
681 if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state)
683 /*If shutdown is called in between allow shutdown to happen*/
684 phLibNfc_Pending_Shutdown();
685 status = NFCSTATUS_SHUTDOWN;
689 if(status == NFCSTATUS_SUCCESS)
691 hSeHandle = pLibContext->sSeContext.hSetemp;
693 if(hSeHandle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
695 if(TRUE==pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc)
697 /*If Activation mode was virtual allow external reader to see it*/
698 pLibContext->sSeContext.uUiccActivate = TRUE;
699 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState = phLibNfc_SE_Active;
703 /*If Activation mode was wired don't allow external reader to see it*/
704 pLibContext->sSeContext.uUiccActivate = FALSE;
705 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState =
706 phLibNfc_SE_Inactive;
708 status = NFCSTATUS_SUCCESS;
709 TempState = pLibContext->sSeContext.uUiccActivate;
711 else if (hSeHandle==sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
713 if(TRUE==pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation)
715 /*If Activation mode was virtual allow external reader to see it*/
716 pLibContext->sSeContext.uSmxActivate = TRUE;
717 sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState =
722 /*If Activation mode was wired don't allow external reader to see it*/
723 pLibContext->sSeContext.uSmxActivate = FALSE;
724 sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState=
725 phLibNfc_SE_Inactive;
727 status = NFCSTATUS_SUCCESS;
728 TempState = pLibContext->sSeContext.uSmxActivate;
732 status = NFCSTATUS_FAILED;
737 status = NFCSTATUS_FAILED;
739 pLibContext->status.GenCb_pending_status = FALSE;
743 pUpperLayerCb = pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb;
744 pUpperContext = pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt;
745 pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb = NULL;
746 pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt = NULL;
747 PHNFC_UNUSED_VARIABLE(TempState);
748 /* Call the upper layer cb */
749 if(pUpperLayerCb!= NULL )
751 (*pUpperLayerCb)(pUpperContext,