1 /* 2 * Copyright (C) 2010 NXP Semiconductors 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17 /*! 18 * \file phLibNfc_initiator.c 19 20 * Project: NFC FRI 1.1 21 * 22 * $Date: Fri Apr 23 14:34:08 2010 $ 23 * $Author: ing07385 $ 24 * $Revision: 1.53 $ 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 $ 26 * 27 */ 28 29 /* 30 ************************* Header Files **************************************** 31 */ 32 33 #include <phLibNfcStatus.h> 34 #include <phLibNfc.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> 42 43 44 /* 45 *************************** Macro's **************************************** 46 */ 47 48 #ifndef STATIC_DISABLE 49 #define STATIC static 50 #else 51 #define STATIC 52 #endif 53 54 /* 55 *************************** Global Variables ********************************** 56 */ 57 58 59 60 /* 61 *************************** Static Function Declaration *********************** 62 */ 63 64 /* Target discvovery notification callback */ 65 STATIC void phLibNfc_NotificationRegister_Resp_Cb ( 66 void *context, 67 phHal_eNotificationType_t type, 68 phHal4Nfc_NotificationInfo_t info, 69 NFCSTATUS status 70 ); 71 72 /*Remote device connect response callback*/ 73 STATIC void phLibNfc_RemoteDev_Connect_Cb( 74 void *pContext, 75 phHal_sRemoteDevInformation_t *pRmtdev_info, 76 NFCSTATUS status 77 ); 78 79 /*Remote device disconnect response callback*/ 80 STATIC void phLibNfc_RemoteDev_Disconnect_cb( 81 void *context, 82 phHal_sRemoteDevInformation_t *reg_handle, 83 NFCSTATUS status 84 ); 85 /*Remote device Transceive response callback*/ 86 STATIC void phLibNfc_RemoteDev_Transceive_Cb(void *context, 87 phHal_sRemoteDevInformation_t *pRmtdev_info, 88 phNfc_sData_t *response, 89 NFCSTATUS status 90 ); 91 /*Set P2P config paramater response callback*/ 92 STATIC void phLibNfc_Mgt_SetP2P_ConfigParams_Cb( 93 void *context, 94 NFCSTATUS status 95 ); 96 97 98 /* 99 *************************** Function Definitions ****************************** 100 */ 101 102 /** 103 * Response to target discovery. 104 */ 105 STATIC 106 void phLibNfc_NotificationRegister_Resp_Cb ( 107 void *context, 108 phHal_eNotificationType_t type, 109 phHal4Nfc_NotificationInfo_t info, 110 NFCSTATUS status 111 ) 112 { 113 NFCSTATUS RetVal = NFCSTATUS_SUCCESS, 114 Status = NFCSTATUS_SUCCESS; 115 uint16_t DeviceIndx, DeviceIndx1; 116 uint8_t sak_byte=0; 117 uint8_t tag_disc_flg = 0; 118 phLibNfc_NtfRegister_RspCb_t pClientCb=NULL; 119 pClientCb =gpphLibContext->CBInfo.pClientNtfRegRespCB; 120 PHNFC_UNUSED_VARIABLE(context); 121 122 123 if(( type != NFC_DISCOVERY_NOTIFICATION ) 124 &&(PHNFCSTATUS(status)!=NFCSTATUS_DESELECTED)) 125 { 126 Status = NFCSTATUS_FAILED; 127 } 128 else 129 { 130 DeviceIndx=0;DeviceIndx1=0; 131 while(DeviceIndx < info.psDiscoveryInfo->NumberOfDevices) 132 { 133 switch(info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]->RemDevType) 134 { 135 case phHal_eMifare_PICC: 136 { 137 /*Mifare Tag discovered*/ 138 sak_byte = info.psDiscoveryInfo-> 139 ppRemoteDevInfo[DeviceIndx]->RemoteDevInfo.Iso14443A_Info.Sak; 140 if((TRUE == gpphLibContext->RegNtfType.MifareUL)&& (sak_byte==0x00)) 141 { 142 /*Copy the tag related info*/ 143 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 144 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 145 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 146 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo; 147 gpphLibContext->Discov_handle[DeviceIndx1] = 148 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 149 DeviceIndx1++; 150 tag_disc_flg++; 151 } 152 153 if((TRUE == gpphLibContext->RegNtfType.MifareStd)&& 154 (((sak_byte & 0x18)==0x08)||((sak_byte & 0x18)==0x18))) 155 { 156 /*Copy the tag related info*/ 157 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 158 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 159 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 160 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo; 161 gpphLibContext->Discov_handle[DeviceIndx1]= 162 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 163 DeviceIndx1++; 164 tag_disc_flg++; 165 } 166 167 }break; 168 case phHal_eISO14443_A_PICC: 169 { 170 /*ISO 14443-A type tag discovered*/ 171 if(TRUE == gpphLibContext->RegNtfType.ISO14443_4A) 172 { 173 /*Copy the ISO type A tag info*/ 174 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 175 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 176 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 177 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo; 178 gpphLibContext->Discov_handle[DeviceIndx1] = 179 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 180 DeviceIndx1++; 181 tag_disc_flg++; 182 } 183 }break; 184 case phHal_eISO14443_3A_PICC: 185 { 186 /*ISO 14443-A type tag discovered*/ 187 if(TRUE == gpphLibContext->RegNtfType.MifareUL) 188 { 189 /*Copy the ISO type A tag info*/ 190 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 191 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 192 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 193 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo; 194 gpphLibContext->Discov_handle[DeviceIndx1] = 195 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 196 DeviceIndx1++; 197 tag_disc_flg++; 198 } 199 }break; 200 case phHal_eISO14443_B_PICC: 201 { 202 /*ISO 14443-B type tag Discovered */ 203 if(TRUE == gpphLibContext->RegNtfType.ISO14443_4B) 204 { 205 /*Copy the Type B tag info */ 206 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 207 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 208 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 209 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo; 210 gpphLibContext->Discov_handle[DeviceIndx1] = 211 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 212 DeviceIndx1++; 213 tag_disc_flg++; 214 } 215 }break; 216 case phHal_eFelica_PICC: 217 { 218 /*Felica Type Tag Discovered */ 219 if(TRUE == gpphLibContext->RegNtfType.Felica) 220 { 221 /*Copy the Felica tag info */ 222 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 223 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 224 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 225 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo; 226 gpphLibContext->Discov_handle[DeviceIndx1] = 227 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 228 DeviceIndx1++; 229 tag_disc_flg++; 230 } 231 }break; 232 case phHal_eJewel_PICC: 233 { 234 /*Jewel Type Tag Discovered */ 235 if(TRUE == gpphLibContext->RegNtfType.Jewel) 236 { 237 /*Copy the Felica tag info */ 238 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 239 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 240 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 241 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo; 242 gpphLibContext->Discov_handle[DeviceIndx1] = 243 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 244 DeviceIndx1++; 245 tag_disc_flg++; 246 } 247 } 248 break; 249 case phHal_eISO15693_PICC: 250 { 251 /*Jewel Type Tag Discovered */ 252 if(TRUE == gpphLibContext->RegNtfType.ISO15693) 253 { 254 /*Copy the Felica tag info */ 255 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 256 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 257 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 258 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo; 259 gpphLibContext->Discov_handle[DeviceIndx1] = 260 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 261 DeviceIndx1++; 262 tag_disc_flg++; 263 } 264 } 265 break; 266 case phHal_eNfcIP1_Target: 267 { 268 if(TRUE == gpphLibContext->RegNtfType.NFC) 269 { 270 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 271 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 272 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 273 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx].psRemoteDevInfo; 274 gpphLibContext->Discov_handle[DeviceIndx1] = 275 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 276 DeviceIndx1++; 277 tag_disc_flg++; 278 } 279 } 280 break; 281 case phHal_eNfcIP1_Initiator: 282 { 283 if(TRUE == gpphLibContext->RegNtfType.NFC) 284 { 285 gpphLibContext->LibNfcState.cur_state=eLibNfcHalStateConnect; 286 gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo= 287 info.psDiscoveryInfo->ppRemoteDevInfo[DeviceIndx]; 288 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev = 289 (uint32_t)gpphLibContext->psRemoteDevList[DeviceIndx1].psRemoteDevInfo; 290 gpphLibContext->sNfcIp_Context.Rem_Initiator_Handle= 291 gpphLibContext->psRemoteDevList[DeviceIndx1].hTargetDev; 292 DeviceIndx1++; 293 tag_disc_flg++; 294 } 295 } 296 break; 297 default : 298 { 299 break; 300 } 301 } 302 DeviceIndx++; 303 } 304 } 305 306 if((tag_disc_flg >0 )&&(status != NFCSTATUS_FAILED)) 307 { 308 gpphLibContext->dev_cnt = tag_disc_flg; 309 /* Check for if the discovered tags are multiple or 310 Multiple protocol tag */ 311 if((gpphLibContext->dev_cnt > 1)&&( 312 (status ==NFCSTATUS_MULTIPLE_PROTOCOLS) || 313 (status ==NFCSTATUS_MULTIPLE_TAGS)) ) 314 { 315 status = status; 316 } 317 else 318 { 319 status =NFCSTATUS_SUCCESS; 320 } 321 /*Notify to upper layer the no of tag discovered and 322 the protocol */ 323 if (NULL != pClientCb) 324 { 325 pClientCb( 326 (void*)gpphLibContext->CBInfo.pClientNtfRegRespCntx, 327 gpphLibContext->psRemoteDevList, 328 gpphLibContext->dev_cnt, 329 status 330 ); 331 } 332 333 } 334 else if(PHNFCSTATUS(status)==NFCSTATUS_DESELECTED) 335 { 336 info.psDiscoveryInfo->NumberOfDevices = 0; 337 if (NULL != pClientCb) 338 { 339 gpphLibContext->LibNfcState.cur_state=eLibNfcHalStateRelease; 340 pClientCb((void*)gpphLibContext->CBInfo.pClientNtfRegRespCntx, 341 NULL, 342 0, 343 status); 344 } 345 346 } 347 else /*Reconfigure the discovery wheel*/ 348 { 349 RetVal = phHal4Nfc_ConfigureDiscovery ( gpphLibContext->psHwReference, 350 NFC_DISCOVERY_RESUME, 351 &(gpphLibContext->sADDconfig), 352 phLibNfc_config_discovery_cb, 353 gpphLibContext); 354 355 if((RetVal!=NFCSTATUS_SUCCESS) &&(RetVal!=NFCSTATUS_PENDING)) 356 { 357 Status = NFCSTATUS_FAILED; 358 } 359 360 } 361 if(Status == NFCSTATUS_FAILED) 362 { 363 if (NULL != pClientCb) 364 { 365 pClientCb(gpphLibContext->CBInfo.pClientNtfRegRespCntx, 366 NULL, 367 0, 368 Status); 369 } 370 } 371 return; 372 } 373 374 /** 375 * This interface registers notification handler for target discovery. 376 */ 377 NFCSTATUS 378 phLibNfc_RemoteDev_NtfRegister( 379 phLibNfc_Registry_Info_t* pRegistryInfo, 380 phLibNfc_NtfRegister_RspCb_t pNotificationHandler, 381 void *pContext 382 ) 383 { 384 NFCSTATUS RetVal = NFCSTATUS_SUCCESS; 385 386 387 /*Check for valid parameters*/ 388 if((NULL == pNotificationHandler) 389 || (NULL == pContext) 390 ||(NULL== pRegistryInfo)) 391 { 392 RetVal= NFCSTATUS_INVALID_PARAMETER; 393 } 394 else if((NULL == gpphLibContext) || 395 (gpphLibContext->LibNfcState.cur_state 396 == eLibNfcHalStateShutdown)) 397 { 398 RetVal = NFCSTATUS_NOT_INITIALISED; 399 } 400 else if(gpphLibContext->LibNfcState.next_state 401 == eLibNfcHalStateShutdown) 402 { 403 /*Next state is shutdown*/ 404 RetVal= NFCSTATUS_SHUTDOWN; 405 } 406 else 407 { 408 409 PHDBG_INFO("LibNfc:Registering Notification Handler"); 410 411 412 (void) memcpy(&(gpphLibContext->RegNtfType),pRegistryInfo, 413 sizeof(phLibNfc_Registry_Info_t)); 414 /* Register Discovery Notification Handler*/ 415 416 /*Register for NFCIP1 target type*/ 417 RetVal = phHal4Nfc_RegisterNotification( 418 gpphLibContext->psHwReference, 419 eRegisterP2PDiscovery, 420 phLibNfc_NotificationRegister_Resp_Cb, 421 (void*)gpphLibContext 422 ); 423 /*Register for Tag discovery*/ 424 RetVal = phHal4Nfc_RegisterNotification( 425 gpphLibContext->psHwReference, 426 eRegisterTagDiscovery, 427 phLibNfc_NotificationRegister_Resp_Cb, 428 (void*)gpphLibContext 429 ); 430 gpphLibContext->CBInfo.pClientNtfRegRespCB = pNotificationHandler; 431 gpphLibContext->CBInfo.pClientNtfRegRespCntx = pContext; 432 /*Register notification handler with below layer*/ 433 434 } 435 return RetVal; 436 } 437 /** 438 * This interface unregisters notification handler for target discovery. 439 */ 440 NFCSTATUS phLibNfc_RemoteDev_NtfUnregister(void) 441 { 442 NFCSTATUS RetVal = NFCSTATUS_SUCCESS; 443 if((NULL == gpphLibContext) || 444 (gpphLibContext->LibNfcState.cur_state 445 == eLibNfcHalStateShutdown)) 446 { 447 /*Lib Nfc not Initialized*/ 448 RetVal = NFCSTATUS_NOT_INITIALISED; 449 } 450 else if(gpphLibContext->LibNfcState.next_state 451 == eLibNfcHalStateShutdown) 452 { 453 /*Lib Nfc Shutdown*/ 454 RetVal= NFCSTATUS_SHUTDOWN; 455 } 456 else 457 { 458 /*Unregister notification handler with lower layer */ 459 RetVal = phHal4Nfc_UnregisterNotification( 460 gpphLibContext->psHwReference, 461 eRegisterP2PDiscovery, 462 gpphLibContext); 463 464 RetVal = phHal4Nfc_UnregisterNotification( 465 gpphLibContext->psHwReference, 466 eRegisterTagDiscovery, 467 gpphLibContext); 468 469 gpphLibContext->CBInfo.pClientNtfRegRespCB = NULL; 470 gpphLibContext->CBInfo.pClientNtfRegRespCntx =NULL; 471 PHDBG_INFO("LibNfc:Unregister Notification Handler"); 472 } 473 return RetVal; 474 } 475 476 477 /** 478 * Connect to a single Remote Device 479 */ 480 NFCSTATUS phLibNfc_RemoteDev_Connect( 481 phLibNfc_Handle hRemoteDevice, 482 pphLibNfc_ConnectCallback_t pNotifyConnect_RspCb, 483 void *pContext 484 ) 485 { 486 487 NFCSTATUS RetVal = NFCSTATUS_FAILED; 488 phLibNfc_sRemoteDevInformation_t *psRemoteDevInfo; 489 490 if((NULL == gpphLibContext) || 491 (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown)) 492 { 493 RetVal = NFCSTATUS_NOT_INITIALISED; 494 }/* Check valid parameters*/ 495 else if((NULL == pContext) 496 || (NULL == pNotifyConnect_RspCb) 497 || (NULL == (void*)hRemoteDevice)) 498 { 499 RetVal= NFCSTATUS_INVALID_PARAMETER; 500 } 501 /* Check valid lib nfc State*/ 502 else if(gpphLibContext->LibNfcState.next_state 503 == eLibNfcHalStateShutdown) 504 { 505 RetVal= NFCSTATUS_SHUTDOWN; 506 } 507 else if((gpphLibContext->Discov_handle[0] != hRemoteDevice)&& 508 (gpphLibContext->Discov_handle[1] != hRemoteDevice)&& 509 (gpphLibContext->Discov_handle[2] != hRemoteDevice)&& 510 (gpphLibContext->Discov_handle[3] != hRemoteDevice)&& 511 (gpphLibContext->Discov_handle[4] != hRemoteDevice)&& 512 (gpphLibContext->Discov_handle[5] != hRemoteDevice)&& 513 (gpphLibContext->Discov_handle[6] != hRemoteDevice)&& 514 (gpphLibContext->Discov_handle[7] != hRemoteDevice)&& 515 (gpphLibContext->Discov_handle[8] != hRemoteDevice)&& 516 (gpphLibContext->Discov_handle[9] != hRemoteDevice)) 517 { 518 RetVal= NFCSTATUS_INVALID_HANDLE; 519 } 520 else 521 { 522 psRemoteDevInfo = (phLibNfc_sRemoteDevInformation_t*)hRemoteDevice; 523 524 /* Call the HAL connect*/ 525 RetVal = phHal4Nfc_Connect(gpphLibContext->psHwReference, 526 psRemoteDevInfo, 527 phLibNfc_RemoteDev_Connect_Cb, 528 (void* )gpphLibContext); 529 if(RetVal== NFCSTATUS_PENDING) 530 { 531 /* If HAL Connect is pending update the LibNFC state machine 532 and store the CB pointer and Context, 533 mark the General CB pending status is TRUE*/ 534 gpphLibContext->CBInfo.pClientConnectCb = pNotifyConnect_RspCb; 535 gpphLibContext->CBInfo.pClientConCntx = pContext; 536 gpphLibContext->status.GenCb_pending_status=TRUE; 537 gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConnect; 538 gpphLibContext->Connected_handle = hRemoteDevice; 539 } 540 else if(PHNFCSTATUS(RetVal) == NFCSTATUS_INVALID_REMOTE_DEVICE) 541 { 542 /* The Handle given for connect is invalid*/ 543 RetVal= NFCSTATUS_TARGET_NOT_CONNECTED; 544 } 545 else 546 { 547 /* Lower layer returns internal error code return NFCSTATUS_FAILED*/ 548 RetVal = NFCSTATUS_FAILED; 549 } 550 } 551 return RetVal; 552 } 553 /** 554 * Response callback for remote device connect 555 */ 556 STATIC void phLibNfc_RemoteDev_Connect_Cb( 557 void *pContext, 558 phHal_sRemoteDevInformation_t *pRmtdev_info, 559 NFCSTATUS status 560 ) 561 { 562 NFCSTATUS Connect_status = NFCSTATUS_SUCCESS; 563 /*Check valid lib nfc context is returned from lower layer*/ 564 if((phLibNfc_LibContext_t *)pContext == gpphLibContext) 565 { 566 567 /* Mark General Callback pending status as false*/ 568 gpphLibContext->status.GenCb_pending_status = FALSE; 569 570 /* Check the shutdown is called during the lower layer Connect in process, 571 If yes call shutdown call and return NFCSTATUS_SHUTDOWN */ 572 if((eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state)) 573 { 574 phLibNfc_Pending_Shutdown(); 575 Connect_status = NFCSTATUS_SHUTDOWN; 576 577 } 578 else if(PHNFCSTATUS(status)==NFCSTATUS_SUCCESS) 579 { 580 /* Copy the Remote device address as connected handle*/ 581 gpphLibContext->Connected_handle =(uint32_t) pRmtdev_info; 582 /* Update the state to connected and return status as SUCCESS*/ 583 gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConnect; 584 Connect_status = NFCSTATUS_SUCCESS; 585 } 586 else 587 { /* if(PHNFCSTATUS(status)==NFCSTATUS_INVALID_REMOTE_DEVICE) */ 588 /* If remote device is invalid return as TARGET LOST to upper layer*/ 589 /* If error code is other than SUCCESS return NFCSTATUS_TARGET_LOST */ 590 Connect_status = NFCSTATUS_TARGET_LOST; 591 } 592 gpphLibContext->ndef_cntx.is_ndef = CHK_NDEF_NOT_DONE; 593 /* Update the Current Sate*/ 594 phLibNfc_UpdateCurState(Connect_status,(phLibNfc_LibContext_t *)pContext); 595 /* Call the upper layer callback*/ 596 gpphLibContext->CBInfo.pClientConnectCb( 597 gpphLibContext->CBInfo.pClientConCntx, 598 (uint32_t)pRmtdev_info, 599 (phLibNfc_sRemoteDevInformation_t*)pRmtdev_info, 600 Connect_status); 601 } 602 else 603 { /*exception: wrong context pointer returned*/ 604 phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); 605 } 606 return; 607 } 608 609 /** 610 * Allows to disconnect from already connected target. 611 */ 612 NFCSTATUS phLibNfc_RemoteDev_Disconnect( phLibNfc_Handle hRemoteDevice, 613 phLibNfc_eReleaseType_t ReleaseType, 614 pphLibNfc_DisconnectCallback_t pDscntCallback, 615 void* pContext 616 ) 617 { 618 NFCSTATUS RetVal = NFCSTATUS_SUCCESS; 619 phLibNfc_sRemoteDevInformation_t *psRemoteDevInfo=NULL; 620 621 /*Check for valid parameter*/ 622 if((NULL == gpphLibContext) || 623 (gpphLibContext->LibNfcState.cur_state 624 == eLibNfcHalStateShutdown)) 625 { 626 RetVal = NFCSTATUS_NOT_INITIALISED; 627 } 628 else if((NULL == pContext) || 629 (NULL == pDscntCallback)||(hRemoteDevice == 0)) 630 { 631 RetVal= NFCSTATUS_INVALID_PARAMETER; 632 } 633 /* Check for valid state,If De initialize is called then 634 return NFCSTATUS_SHUTDOWN */ 635 else if(gpphLibContext->LibNfcState.next_state 636 == eLibNfcHalStateShutdown) 637 { 638 RetVal= NFCSTATUS_SHUTDOWN; 639 } 640 else if(gpphLibContext->Connected_handle==0) 641 { 642 RetVal=NFCSTATUS_TARGET_NOT_CONNECTED; 643 } 644 /* The given handle is not the connected handle return NFCSTATUS_INVALID_HANDLE*/ 645 else if(hRemoteDevice != gpphLibContext->Connected_handle ) 646 { 647 RetVal=NFCSTATUS_INVALID_HANDLE; 648 } 649 else 650 { 651 if((eLibNfcHalStateRelease == gpphLibContext->LibNfcState.next_state) 652 ||((gpphLibContext->sSeContext.eActivatedMode == phLibNfc_SE_ActModeWired)&& 653 (ReleaseType != NFC_SMARTMX_RELEASE)) 654 ||((gpphLibContext->sSeContext.eActivatedMode != phLibNfc_SE_ActModeWired)&& 655 (ReleaseType == NFC_SMARTMX_RELEASE))) 656 { /* Previous disconnect callback is pending */ 657 RetVal = NFCSTATUS_REJECTED; 658 } 659 else if(eLibNfcHalStateTransaction == gpphLibContext->LibNfcState.next_state) 660 { /* Previous Transaction is Pending*/ 661 RetVal = NFCSTATUS_BUSY; 662 PHDBG_INFO("LibNfc:Transaction is Pending"); 663 } 664 else 665 { 666 gpphLibContext->ReleaseType = ReleaseType; 667 psRemoteDevInfo = (phLibNfc_sRemoteDevInformation_t*)hRemoteDevice; 668 RetVal = phHal4Nfc_Disconnect(gpphLibContext->psHwReference, 669 (phHal_sRemoteDevInformation_t*)psRemoteDevInfo, 670 gpphLibContext->ReleaseType, 671 (pphHal4Nfc_DiscntCallback_t) 672 phLibNfc_RemoteDev_Disconnect_cb, 673 (void *)gpphLibContext); 674 if( NFCSTATUS_PENDING == PHNFCSTATUS(RetVal)) 675 { 676 /*Copy the upper layer Callback pointer and context*/ 677 gpphLibContext->CBInfo.pClientDisConnectCb = pDscntCallback; 678 gpphLibContext->CBInfo.pClientDConCntx = pContext; 679 /* Mark general callback pending status as TRUE and update the state*/ 680 gpphLibContext->status.GenCb_pending_status=TRUE; 681 gpphLibContext->LibNfcState.next_state = eLibNfcHalStateRelease; 682 683 } 684 else 685 { 686 /*If lower layer returns other than pending 687 (internal error codes) return NFCSTATUS_FAILED */ 688 RetVal = NFCSTATUS_FAILED; 689 } 690 } 691 } 692 return RetVal; 693 } 694 /** 695 * Response callback for Remote device Disconnect. 696 */ 697 STATIC void phLibNfc_RemoteDev_Disconnect_cb( 698 void *context, 699 phHal_sRemoteDevInformation_t *reg_handle, 700 NFCSTATUS status 701 ) 702 { 703 NFCSTATUS DisCnct_status = NFCSTATUS_SUCCESS; 704 pphLibNfc_DisconnectCallback_t pUpper_NtfCb = NULL; 705 void *pUpper_Context = NULL; 706 707 /* Copy the upper layer Callback and context*/ 708 pUpper_NtfCb = gpphLibContext->CBInfo.pClientDisConnectCb; 709 pUpper_Context = gpphLibContext->CBInfo.pClientDConCntx; 710 711 /* Check valid context is returned or not */ 712 if((phLibNfc_LibContext_t *)context != gpphLibContext) 713 { 714 /*exception: wrong context pointer returned*/ 715 phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); 716 } 717 else 718 { 719 /* Mark the General callback pending status FALSE */ 720 gpphLibContext->status.GenCb_pending_status = FALSE; 721 gpphLibContext->CBInfo.pClientDisConnectCb = NULL; 722 gpphLibContext->CBInfo.pClientDConCntx = NULL; 723 724 gpphLibContext->ndef_cntx.is_ndef = CHK_NDEF_NOT_DONE; 725 gpphLibContext->LastTrancvSuccess = FALSE; 726 /*Reset Connected handle */ 727 gpphLibContext->Connected_handle=0x0000; 728 if(NULL != gpphLibContext->psBufferedAuth) 729 { 730 if(NULL != gpphLibContext->psBufferedAuth->sRecvData.buffer) 731 { 732 phOsalNfc_FreeMemory( 733 gpphLibContext->psBufferedAuth->sRecvData.buffer); 734 } 735 if(NULL != gpphLibContext->psBufferedAuth->sSendData.buffer) 736 { 737 phOsalNfc_FreeMemory( 738 gpphLibContext->psBufferedAuth->sSendData.buffer); 739 } 740 phOsalNfc_FreeMemory(gpphLibContext->psBufferedAuth); 741 gpphLibContext->psBufferedAuth = NULL; 742 } 743 } 744 /* Check DeInit is called or not */ 745 if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state) 746 { 747 /*call shutdown and return status as NFCSTATUS_SHUTDOWN */ 748 phLibNfc_Pending_Shutdown(); 749 DisCnct_status = NFCSTATUS_SHUTDOWN; 750 } 751 else if(NFCSTATUS_SUCCESS == status) 752 { 753 DisCnct_status = NFCSTATUS_SUCCESS; 754 gpphLibContext->LibNfcState.next_state = eLibNfcHalStateRelease; 755 } 756 else 757 { 758 DisCnct_status = NFCSTATUS_FAILED; 759 phLibNfc_UpdateCurState(DisCnct_status,(phLibNfc_LibContext_t *)context); 760 } 761 /* Call the upper layer Callback */ 762 (*pUpper_NtfCb)(pUpper_Context, 763 (uint32_t)reg_handle, 764 DisCnct_status); 765 return; 766 } 767 768 /** 769 * This interface allows to perform Read/write operation on remote device. 770 */ 771 NFCSTATUS 772 phLibNfc_RemoteDev_Transceive(phLibNfc_Handle hRemoteDevice, 773 phLibNfc_sTransceiveInfo_t* psTransceiveInfo, 774 pphLibNfc_TransceiveCallback_t pTransceive_RspCb, 775 void* pContext 776 ) 777 { 778 NFCSTATUS RetVal = NFCSTATUS_SUCCESS; 779 780 /*Check for valid parameter */ 781 782 if((NULL == gpphLibContext) || 783 (gpphLibContext->LibNfcState.cur_state 784 == eLibNfcHalStateShutdown)) 785 { 786 RetVal = NFCSTATUS_NOT_INITIALISED; 787 } 788 else if((NULL == psTransceiveInfo) 789 || (NULL == pTransceive_RspCb) 790 || (NULL == (void *)hRemoteDevice) 791 || (NULL == psTransceiveInfo->sRecvData.buffer) 792 || (NULL == psTransceiveInfo->sSendData.buffer) 793 || (NULL == pContext)) 794 { 795 RetVal= NFCSTATUS_INVALID_PARAMETER; 796 } 797 /* Check the state for DeInit is called or not,if yes return NFCSTATUS_SHUTDOWN*/ 798 else if(gpphLibContext->LibNfcState.next_state 799 == eLibNfcHalStateShutdown) 800 { 801 RetVal= NFCSTATUS_SHUTDOWN; 802 }/* If there is no handle connected return NFCSTATUS_TARGET_NOT_CONNECTED*/ 803 else if(gpphLibContext->Connected_handle==0) 804 { 805 RetVal=NFCSTATUS_TARGET_NOT_CONNECTED; 806 }/* If the given handle is not the connected handle return NFCSTATUS_INVALID_HANDLE */ 807 else if(gpphLibContext->Connected_handle!= hRemoteDevice ) 808 { 809 RetVal=NFCSTATUS_INVALID_HANDLE; 810 } /*If the transceive is called before finishing the previous transceive function 811 return NFCSTATUS_REJECTED */ 812 else if((eLibNfcHalStateTransaction == 813 gpphLibContext->LibNfcState.next_state) 814 ||(phHal_eNfcIP1_Initiator== 815 ((phHal_sRemoteDevInformation_t*)hRemoteDevice)->RemDevType)) 816 { 817 RetVal = NFCSTATUS_REJECTED; 818 } 819 else 820 { 821 gpphLibContext->ndef_cntx.eLast_Call = RawTrans; 822 (void)memcpy((void *)(gpphLibContext->psTransInfo), 823 (void *)psTransceiveInfo, 824 sizeof(phLibNfc_sTransceiveInfo_t)); 825 /* Check the given Mifare command is supported or not , 826 If not return NFCSTATUS_COMMAND_NOT_SUPPORTED */ 827 if( (((phHal_sRemoteDevInformation_t*)hRemoteDevice)->RemDevType == 828 phHal_eMifare_PICC)&& 829 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareRaw ) && 830 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareAuthentA ) && 831 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareAuthentB ) && 832 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareRead16 ) && 833 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareRead ) && 834 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareWrite16 ) && 835 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareWrite4 ) && 836 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareDec ) && 837 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareTransfer ) && 838 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareRestore ) && 839 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareReadSector ) && 840 ( gpphLibContext->psTransInfo->cmd.MfCmd != phHal_eMifareWriteSector )) 841 { 842 RetVal = NFCSTATUS_COMMAND_NOT_SUPPORTED; 843 } 844 if(eLibNfcHalStatePresenceChk != 845 gpphLibContext->LibNfcState.next_state) 846 { 847 PHDBG_INFO("LibNfc:Transceive In Progress"); 848 if((((phHal_sRemoteDevInformation_t*)hRemoteDevice)->RemDevType == 849 phHal_eMifare_PICC) && (((phHal_sRemoteDevInformation_t*) 850 hRemoteDevice)->RemoteDevInfo.Iso14443A_Info.Sak != 0)&& 851 (phHal_eMifareAuthentA == gpphLibContext->psTransInfo->cmd.MfCmd)) 852 { 853 if(NULL != gpphLibContext->psBufferedAuth) 854 { 855 if(NULL != gpphLibContext->psBufferedAuth->sRecvData.buffer) 856 { 857 phOsalNfc_FreeMemory( 858 gpphLibContext->psBufferedAuth->sRecvData.buffer); 859 } 860 if(NULL != gpphLibContext->psBufferedAuth->sSendData.buffer) 861 { 862 phOsalNfc_FreeMemory( 863 gpphLibContext->psBufferedAuth->sSendData.buffer); 864 } 865 phOsalNfc_FreeMemory(gpphLibContext->psBufferedAuth); 866 } 867 gpphLibContext->psBufferedAuth 868 =(phLibNfc_sTransceiveInfo_t *) 869 phOsalNfc_GetMemory(sizeof(phLibNfc_sTransceiveInfo_t)); 870 gpphLibContext->psBufferedAuth->addr = psTransceiveInfo->addr; 871 gpphLibContext->psBufferedAuth->cmd = psTransceiveInfo->cmd; 872 gpphLibContext->psBufferedAuth->sSendData.length 873 = psTransceiveInfo->sSendData.length; 874 gpphLibContext->psBufferedAuth->sRecvData.length 875 = psTransceiveInfo->sRecvData.length; 876 gpphLibContext->psBufferedAuth->sSendData.buffer 877 = (uint8_t *) 878 phOsalNfc_GetMemory( 879 gpphLibContext->psTransInfo->sSendData.length); 880 881 (void)memcpy((void *) 882 (gpphLibContext->psBufferedAuth->sSendData.buffer), 883 (void *)psTransceiveInfo->sSendData.buffer, 884 psTransceiveInfo->sSendData.length); 885 886 gpphLibContext->psBufferedAuth->sRecvData.buffer 887 = (uint8_t *) 888 phOsalNfc_GetMemory( 889 gpphLibContext->psTransInfo->sRecvData.length); 890 } 891 /*Call the lower layer Transceive function */ 892 RetVal = phHal4Nfc_Transceive( gpphLibContext->psHwReference, 893 (phHal_sTransceiveInfo_t*)gpphLibContext->psTransInfo, 894 (phLibNfc_sRemoteDevInformation_t*)hRemoteDevice, 895 (pphHal4Nfc_TransceiveCallback_t) 896 phLibNfc_RemoteDev_Transceive_Cb, 897 (void* )gpphLibContext); 898 if(PHNFCSTATUS(RetVal) == NFCSTATUS_PENDING) 899 { 900 /* Copy the upper layer callback pointer and context */ 901 gpphLibContext->CBInfo.pClientTransceiveCb = pTransceive_RspCb; 902 gpphLibContext->CBInfo.pClientTranseCntx = pContext; 903 /* Mark the General callback pending status is TRUE */ 904 gpphLibContext->status.GenCb_pending_status = TRUE; 905 /*Transceive is in Progress-Used in Release API*/ 906 907 /*Update the state machine*/ 908 gpphLibContext->LibNfcState.next_state = eLibNfcHalStateTransaction; 909 } 910 } 911 else 912 { 913 gpphLibContext->status.GenCb_pending_status = FALSE; 914 RetVal = NFCSTATUS_FAILED; 915 } 916 } 917 return RetVal; 918 } 919 /** 920 * Response for Remote device transceive. 921 */ 922 STATIC 923 void phLibNfc_RemoteDev_Transceive_Cb(void *context, 924 phHal_sRemoteDevInformation_t *pRmtdev_info, 925 phNfc_sData_t *response, 926 NFCSTATUS status 927 ) 928 { 929 NFCSTATUS trans_status = NFCSTATUS_SUCCESS; 930 phNfc_sData_t *trans_resp= NULL; 931 void *pUpper_Context = NULL; 932 pphLibNfc_TransceiveCallback_t pUpper_TagNtfCb = 933 gpphLibContext->CBInfo.pClientTransceiveCb; 934 935 /*Check valid context is returned or not */ 936 if((phLibNfc_LibContext_t *)context == gpphLibContext) 937 { 938 trans_resp = &gpphLibContext->psTransInfo->sRecvData; 939 940 pUpper_Context = gpphLibContext->CBInfo.pClientTranseCntx; 941 gpphLibContext->status.GenCb_pending_status = FALSE; 942 943 /*If DeInit is called during the transceive, 944 call the shutdown and return NFCSTATUS_SHUTDOWN*/ 945 if(gpphLibContext->LibNfcState.next_state 946 == eLibNfcHalStateShutdown) 947 { 948 phLibNfc_Pending_Shutdown(); 949 trans_status = NFCSTATUS_SHUTDOWN; 950 } 951 /* If Disconnect is called return NFCSTATUS_ABORTED */ 952 else if(eLibNfcHalStateRelease == 953 gpphLibContext->LibNfcState.next_state) 954 { 955 trans_status = NFCSTATUS_ABORTED; 956 } 957 /* If the received lower layer status is not SUCCESS return NFCSTATUS_FAILED */ 958 else if( NFCSTATUS_SUCCESS == status) 959 { 960 trans_status = NFCSTATUS_SUCCESS; 961 } 962 else if((PHNFCSTATUS(status) != NFCSTATUS_SUCCESS) && 963 (phHal_eMifare_PICC == pRmtdev_info->RemDevType) && 964 (0x00 != pRmtdev_info->RemoteDevInfo.Iso14443A_Info.Sak)) 965 { 966 trans_status = NFCSTATUS_FAILED; 967 /* card type is mifare 1k/4k, then reconnect */ 968 trans_status = phHal4Nfc_Connect(gpphLibContext->psHwReference, 969 pRmtdev_info, 970 (pphHal4Nfc_ConnectCallback_t) 971 phLibNfc_Reconnect_Mifare_Cb, 972 (void *)gpphLibContext); 973 } 974 else 975 { 976 trans_status = NFCSTATUS_TARGET_LOST; 977 } 978 /*Update the state machine */ 979 phLibNfc_UpdateCurState(status,gpphLibContext); 980 gpphLibContext->LibNfcState.next_state = eLibNfcHalStateConnect; 981 if(NFCSTATUS_PENDING != trans_status) 982 { 983 /* Tranceive over */ 984 PHDBG_INFO("LibNfc:TXRX Callback-Update the Transceive responce"); 985 if (NULL != pUpper_TagNtfCb) 986 { 987 if(trans_status == NFCSTATUS_SUCCESS) 988 { 989 gpphLibContext->LastTrancvSuccess = TRUE; 990 pUpper_Context = gpphLibContext->CBInfo.pClientTranseCntx; 991 trans_resp->buffer = response->buffer; 992 trans_resp->length = response->length; 993 /* Notify the upper layer */ 994 PHDBG_INFO("LibNfc:Transceive Complete"); 995 /* Notify the Transceive Completion to upper layer */ 996 gpphLibContext->CBInfo.pClientTransceiveCb(pUpper_Context, 997 (uint32_t)pRmtdev_info, 998 trans_resp, 999 trans_status); 1000 } 1001 else 1002 { 1003 gpphLibContext->LastTrancvSuccess = FALSE; 1004 pUpper_Context = gpphLibContext->CBInfo.pClientTranseCntx; 1005 trans_resp->length = 0; 1006 /* Notify the upper layer */ 1007 PHDBG_INFO("LibNfc:Transceive Complete"); 1008 /* Notify the Transceive Completion to upper layer */ 1009 gpphLibContext->CBInfo.pClientTransceiveCb(pUpper_Context, 1010 (uint32_t)pRmtdev_info, 1011 trans_resp, 1012 trans_status); 1013 } 1014 } 1015 } 1016 1017 } 1018 else 1019 { /*exception: wrong context pointer returned*/ 1020 phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); 1021 } 1022 1023 return; 1024 } 1025 /** 1026 * Interface to configure P2P configurations. 1027 */ 1028 NFCSTATUS 1029 phLibNfc_Mgt_SetP2P_ConfigParams(phLibNfc_sNfcIPCfg_t* pConfigInfo, 1030 pphLibNfc_RspCb_t pConfigRspCb, 1031 void* pContext 1032 ) 1033 { 1034 NFCSTATUS RetVal = NFCSTATUS_FAILED; 1035 /* LibNfc Initialized or not */ 1036 if((NULL == gpphLibContext)|| 1037 (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown)) 1038 { 1039 RetVal = NFCSTATUS_NOT_INITIALISED; 1040 }/* Check for valid parameters */ 1041 else if((NULL == pConfigInfo) || (NULL == pConfigRspCb) 1042 || (NULL == pContext)) 1043 { 1044 RetVal= NFCSTATUS_INVALID_PARAMETER; 1045 } 1046 else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown) 1047 { 1048 RetVal = NFCSTATUS_SHUTDOWN; 1049 } 1050 else if(TRUE == gpphLibContext->status.GenCb_pending_status) 1051 { /*Previous callback is pending */ 1052 RetVal = NFCSTATUS_BUSY; 1053 } 1054 else 1055 { 1056 if(eLibNfcHalStatePresenceChk != 1057 gpphLibContext->LibNfcState.next_state) 1058 { 1059 phHal_uConfig_t uConfig; 1060 /* copy General bytes of Max length = 48 bytes */ 1061 (void)memcpy((void *)&(uConfig.nfcIPConfig.generalBytes), 1062 (void *)pConfigInfo->generalBytes, 1063 pConfigInfo->generalBytesLength); 1064 /* also copy the General Bytes length*/ 1065 uConfig.nfcIPConfig.generalBytesLength = pConfigInfo->generalBytesLength; 1066 1067 RetVal = phHal4Nfc_ConfigParameters( 1068 gpphLibContext->psHwReference, 1069 NFC_P2P_CONFIG, 1070 &uConfig, 1071 phLibNfc_Mgt_SetP2P_ConfigParams_Cb, 1072 (void *)gpphLibContext 1073 ); 1074 } 1075 else 1076 { 1077 gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCb= NULL; 1078 RetVal = NFCSTATUS_PENDING; 1079 } 1080 if(NFCSTATUS_PENDING == RetVal) 1081 { 1082 /* save the context and callback for later use */ 1083 gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCb = pConfigRspCb; 1084 gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCntx = pContext; 1085 gpphLibContext->status.GenCb_pending_status=TRUE; 1086 /* Next state is configured */ 1087 gpphLibContext->LibNfcState.next_state =eLibNfcHalStateConfigReady; 1088 } 1089 else 1090 { 1091 RetVal = NFCSTATUS_FAILED; 1092 } 1093 } 1094 return RetVal; 1095 } 1096 /** 1097 * Response callback for P2P configurations. 1098 */ 1099 STATIC void phLibNfc_Mgt_SetP2P_ConfigParams_Cb(void *context, 1100 NFCSTATUS status) 1101 { 1102 pphLibNfc_RspCb_t pClientCb=NULL; 1103 void *pUpperLayerContext=NULL; 1104 /* Check for the context returned by below layer */ 1105 if((phLibNfc_LibContext_t *)context != gpphLibContext) 1106 { /*wrong context returned*/ 1107 phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); 1108 } 1109 else 1110 { 1111 if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state) 1112 { /*shutdown called before completion of this api allow 1113 shutdown to happen */ 1114 phLibNfc_Pending_Shutdown(); 1115 status = NFCSTATUS_SHUTDOWN; 1116 } 1117 else 1118 { 1119 gpphLibContext->status.GenCb_pending_status = FALSE; 1120 if(NFCSTATUS_SUCCESS != status) 1121 { 1122 status = NFCSTATUS_FAILED; 1123 } 1124 else 1125 { 1126 status = NFCSTATUS_SUCCESS; 1127 } 1128 } 1129 /*update the current state */ 1130 phLibNfc_UpdateCurState(status,gpphLibContext); 1131 1132 pClientCb = gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCb; 1133 pUpperLayerContext = gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCntx; 1134 1135 gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCb = NULL; 1136 gpphLibContext->sNfcIp_Context.pClientNfcIpCfgCntx = NULL; 1137 if (NULL != pClientCb) 1138 { 1139 /* Notify to upper layer status of configure operation */ 1140 pClientCb(pUpperLayerContext, status); 1141 } 1142 } 1143 return; 1144 } 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155