1/****************************************************************************** 2 * 3 * Copyright (C) 2010-2013 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 20/****************************************************************************** 21 * 22 * This file contains the action functions for device manager state 23 * machine. 24 * 25 ******************************************************************************/ 26#include <string.h> 27#include "nfa_sys.h" 28#include "nfa_api.h" 29#include "nfa_dm_int.h" 30#include "nfa_sys_int.h" 31#include "nfa_ce_int.h" 32#include "nfc_api.h" 33#include "nfa_rw_int.h" 34#include "nfa_rw_api.h" 35#include "nfa_p2p_int.h" 36#include "nci_hmsgs.h" 37 38#if (defined (NFA_CHO_INCLUDED) && (NFA_CHO_INCLUDED==TRUE)) 39#include "nfa_cho_int.h" 40#endif 41 42#if (NFC_NFCEE_INCLUDED == TRUE) 43#include "nfa_ee_int.h" 44#include "nfa_hci_int.h" 45#endif 46 47#if (defined (NFA_SNEP_INCLUDED) && (NFA_SNEP_INCLUDED==TRUE)) 48#include "nfa_snep_int.h" 49#endif 50 51/* This is the timeout value to guarantee disable is performed within reasonable amount of time */ 52#ifndef NFA_DM_DISABLE_TIMEOUT_VAL 53#define NFA_DM_DISABLE_TIMEOUT_VAL 1000 54#endif 55 56static void nfa_dm_set_init_nci_params (void); 57static tNFA_STATUS nfa_dm_start_polling (void); 58static BOOLEAN nfa_dm_deactivate_polling (void); 59static void nfa_dm_excl_disc_cback (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data); 60static void nfa_dm_poll_disc_cback (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data); 61 62 63/******************************************************************************* 64** 65** Function nfa_dm_module_init_cback 66** 67** Description Processing initialization complete event from sub-modules 68** 69** Returns None 70** 71*******************************************************************************/ 72static void nfa_dm_module_init_cback (void) 73{ 74 tNFA_DM_CBACK_DATA dm_cback_data; 75 76 nfa_dm_cb.flags &= ~NFA_DM_FLAGS_ENABLE_EVT_PEND; 77 78 /* All subsystem are initialized */ 79 dm_cback_data.status = NFA_STATUS_OK; 80 (*nfa_dm_cb.p_dm_cback) (NFA_DM_ENABLE_EVT, &dm_cback_data); 81} 82 83/******************************************************************************* 84** 85** Function nfa_dm_nfcc_power_mode_proc_complete_cback 86** 87** Description Processing complete of processing NFCC power state change 88** from all sub-modules 89** 90** Returns None 91** 92*******************************************************************************/ 93static void nfa_dm_nfcc_power_mode_proc_complete_cback (void) 94{ 95 tNFA_DM_PWR_MODE_CHANGE power_mode_change; 96 97 NFA_TRACE_DEBUG1 ("nfa_dm_nfcc_power_mode_proc_complete_cback () nfcc_pwr_mode = 0x%x", 98 nfa_dm_cb.nfcc_pwr_mode); 99 100 /* if NFCC power state is change to full power */ 101 if (nfa_dm_cb.nfcc_pwr_mode != NFA_DM_PWR_MODE_OFF_SLEEP) 102 { 103 nfa_dm_cb.flags &= ~NFA_DM_FLAGS_NFCC_IS_RESTORING; 104 105 /* reconfigure BRCM NFCC */ 106 nfa_dm_disc_sm_execute (NFA_DM_RF_DISCOVER_CMD, NULL); 107 } 108 109 nfa_dm_cb.flags &= ~NFA_DM_FLAGS_SETTING_PWR_MODE; 110 111 power_mode_change.status = NFA_STATUS_OK; 112 power_mode_change.power_mode = nfa_dm_cb.nfcc_pwr_mode; 113 (*nfa_dm_cb.p_dm_cback) (NFA_DM_PWR_MODE_CHANGE_EVT, (tNFA_DM_CBACK_DATA*) &power_mode_change); 114} 115/******************************************************************************* 116** 117** Function nfa_dm_sys_enable 118** 119** Description This function on enable 120** 121** Returns void 122** 123*******************************************************************************/ 124void nfa_dm_sys_enable (void) 125{ 126 nfa_dm_set_init_nci_params (); 127} 128 129/******************************************************************************* 130** 131** Function nfa_dm_set_init_nci_params 132** 133** Description Set initial NCI configuration parameters 134** 135** Returns void 136** 137*******************************************************************************/ 138static void nfa_dm_set_init_nci_params (void) 139{ 140 UINT8 xx; 141 142 /* set NCI default value if other than zero */ 143 144 /* LF_T3T_IDENTIFIERS_1/2/.../16 */ 145 for (xx = 0; xx < NFA_CE_LISTEN_INFO_MAX; xx++) 146 { 147 nfa_dm_cb.params.lf_t3t_id[xx][0] = 0xFF; 148 nfa_dm_cb.params.lf_t3t_id[xx][1] = 0xFF; 149 nfa_dm_cb.params.lf_t3t_id[xx][2] = 0x02; 150 nfa_dm_cb.params.lf_t3t_id[xx][2] = 0xFE; 151 } 152 153 /* LF_T3T_PMM */ 154 for (xx = 0; xx < NCI_PARAM_LEN_LF_T3T_PMM; xx++) 155 { 156 nfa_dm_cb.params.lf_t3t_pmm[xx] = 0xFF; 157 } 158 159 /* LF_T3T_FLAGS: 160 ** DH needs to set this configuration, even if default value (not listening) is used, 161 ** to let NFCC know of intention (not listening) of DH. 162 */ 163 164 /* FWI */ 165 nfa_dm_cb.params.fwi[0] = 0x04; 166 167 /* WT */ 168 nfa_dm_cb.params.wt[0] = 14; 169 170 /* Set CE default configuration */ 171 if (p_nfa_dm_ce_cfg[0]) 172 { 173 nfa_dm_check_set_config (p_nfa_dm_ce_cfg[0], &p_nfa_dm_ce_cfg[1], FALSE); 174 } 175 176 /* Set optional general default configuration */ 177 if (p_nfa_dm_gen_cfg && p_nfa_dm_gen_cfg[0]) 178 { 179 nfa_dm_check_set_config (p_nfa_dm_gen_cfg[0], &p_nfa_dm_gen_cfg[1], FALSE); 180 } 181 182 if (p_nfa_dm_interface_mapping && nfa_dm_num_dm_interface_mapping) 183 { 184 NFC_DiscoveryMap (nfa_dm_num_dm_interface_mapping, p_nfa_dm_interface_mapping, NULL); 185 } 186} 187 188/******************************************************************************* 189** 190** Function nfa_dm_proc_nfcc_power_mode 191** 192** Description Processing NFCC power mode changes 193** 194** Returns None 195** 196*******************************************************************************/ 197void nfa_dm_proc_nfcc_power_mode (UINT8 nfcc_power_mode) 198{ 199 NFA_TRACE_DEBUG1 ("nfa_dm_proc_nfcc_power_mode (): nfcc_power_mode=%d", 200 nfcc_power_mode); 201 202 /* if NFCC power mode is change to full power */ 203 if (nfcc_power_mode == NFA_DM_PWR_MODE_FULL) 204 { 205 memset (&nfa_dm_cb.params, 0x00, sizeof (tNFA_DM_PARAMS)); 206 NFA_TRACE_DEBUG2 ("setcfg_pending_mask=0x%x, setcfg_pending_num=%d", 207 nfa_dm_cb.setcfg_pending_mask, nfa_dm_cb.setcfg_pending_num); 208 nfa_dm_cb.setcfg_pending_mask = 0; 209 nfa_dm_cb.setcfg_pending_num = 0; 210 211 nfa_dm_set_init_nci_params (); 212 } 213 214 nfa_sys_cback_notify_nfcc_power_mode_proc_complete (NFA_ID_DM); 215} 216 217/******************************************************************************* 218** 219** Function nfa_dm_disable_event 220** 221** Description report disable event 222** 223** Returns void 224** 225*******************************************************************************/ 226static void nfa_dm_disable_event (void) 227{ 228 /* Deregister DM from sys */ 229 nfa_sys_deregister (NFA_ID_DM); 230 231 /* Notify app */ 232 nfa_dm_cb.flags &= ~(NFA_DM_FLAGS_DM_IS_ACTIVE 233 |NFA_DM_FLAGS_DM_DISABLING_NFC 234 |NFA_DM_FLAGS_ENABLE_EVT_PEND); 235 (*nfa_dm_cb.p_dm_cback) (NFA_DM_DISABLE_EVT, NULL); 236} 237 238/******************************************************************************* 239** 240** Function nfa_dm_nfc_response_cback 241** 242** Description Call DM event hanlder with NFC response callback data 243** 244** Returns void 245** 246*******************************************************************************/ 247static void nfa_dm_nfc_response_cback (tNFC_RESPONSE_EVT event, tNFC_RESPONSE *p_data) 248{ 249 tNFA_DM_CBACK_DATA dm_cback_data; 250 tNFA_GET_CONFIG *p_nfa_get_confg; 251 tNFA_CONN_EVT_DATA conn_evt; 252 UINT8 dm_cback_evt; 253 254#if (BT_TRACE_VERBOSE == TRUE) 255 NFA_TRACE_DEBUG2 ("nfa_dm_nfc_response_cback () %s(0x%x)", nfa_dm_nfc_revt_2_str (event), event); 256#else 257 NFA_TRACE_DEBUG1 ("nfa_dm_nfc_response_cback () event=0x%x", event); 258#endif 259 260 switch (event) 261 { 262 case NFC_ENABLE_REVT: /* 0 Enable event */ 263 264 /* NFC stack enabled. Enable nfa sub-systems */ 265 if (p_data->enable.status == NFC_STATUS_OK) 266 { 267 nfa_dm_set_init_nci_params (); 268 269 /* Initialize NFA subsystems */ 270 nfa_sys_enable_subsystems (); 271 } 272 else if (nfa_dm_cb.flags & NFA_DM_FLAGS_ENABLE_EVT_PEND) 273 { 274 /* Notify app */ 275 nfa_dm_cb.flags &= ~(NFA_DM_FLAGS_ENABLE_EVT_PEND | NFA_DM_FLAGS_DM_IS_ACTIVE); 276 dm_cback_data.status = p_data->enable.status; 277 (*nfa_dm_cb.p_dm_cback) (NFA_DM_ENABLE_EVT, &dm_cback_data); 278 } 279 break; 280 281 case NFC_DISABLE_REVT: /* 1 Disable event */ 282 nfa_dm_disable_event (); 283 break; 284 285 case NFC_SET_CONFIG_REVT: /* 2 Set Config Response */ 286 /* If this setconfig was due to NFA_SetConfig, then notify the app */ 287 if (nfa_dm_cb.setcfg_pending_mask & 1) /* lsb=whether last NCI_SET_CONFIG was due to NFA_SetConfig */ 288 { 289 dm_cback_data.set_config.status = p_data->set_config.status; 290 dm_cback_data.set_config.num_param_id = p_data->set_config.num_param_id; 291 memcpy (dm_cback_data.set_config.param_ids, p_data->set_config.param_ids, p_data->set_config.num_param_id); 292 (*nfa_dm_cb.p_dm_cback) (NFA_DM_SET_CONFIG_EVT, &dm_cback_data); 293 } 294 295 /* Update the pending mask */ 296 if (nfa_dm_cb.setcfg_pending_num>0) 297 { 298 nfa_dm_cb.setcfg_pending_mask >>= 1; 299 nfa_dm_cb.setcfg_pending_num--; 300 } 301 else 302 { 303 /* This should not occur (means we got a SET_CONFIG_NTF that's unaccounted for */ 304 NFA_TRACE_ERROR0 ("NFA received unexpected NFC_SET_CONFIG_REVT"); 305 } 306 break; 307 308 case NFC_GET_CONFIG_REVT: /* 3 Get Config Response */ 309 if (p_data->get_config.status == NFC_STATUS_OK) 310 { 311 if ((p_nfa_get_confg = (tNFA_GET_CONFIG *) GKI_getbuf ((UINT16) (sizeof (tNFA_GET_CONFIG) + p_data->get_config.tlv_size))) != NULL) 312 { 313 p_nfa_get_confg->status = NFA_STATUS_OK; 314 p_nfa_get_confg->tlv_size = p_data->get_config.tlv_size; 315 memcpy (p_nfa_get_confg->param_tlvs, p_data->get_config.p_param_tlvs, p_data->get_config.tlv_size); 316 (*nfa_dm_cb.p_dm_cback) (NFA_DM_GET_CONFIG_EVT, (tNFA_DM_CBACK_DATA *) p_nfa_get_confg); 317 318 GKI_freebuf (p_nfa_get_confg); 319 return; 320 } 321 else 322 { 323 NFA_TRACE_DEBUG0 ("nfa_dm_nfc_response_cback unable to allocate buffer"); 324 } 325 } 326 327 /* Return result of getconfig to the app */ 328 dm_cback_data.get_config.status = NFA_STATUS_FAILED; 329 (*nfa_dm_cb.p_dm_cback) (NFA_DM_GET_CONFIG_EVT, &dm_cback_data); 330 break; 331 332#if (NFC_NFCEE_INCLUDED == TRUE) 333 case NFC_NFCEE_DISCOVER_REVT: /* NFCEE Discover response */ 334 case NFC_NFCEE_INFO_REVT: /* NFCEE Discover Notification */ 335 case NFC_EE_ACTION_REVT: /* EE Action notification */ 336 case NFC_NFCEE_MODE_SET_REVT: /* NFCEE Mode Set response */ 337 nfa_ee_proc_evt (event, p_data); 338 break; 339 340 case NFC_EE_DISCOVER_REQ_REVT: /* EE Discover Req notification */ 341 if (nfa_dm_is_active() && 342 (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_DISCOVERY) ) 343 { 344 nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE); 345 } 346 nfa_ee_proc_evt (event, p_data); 347 break; 348#endif 349 350 case NFC_RF_FIELD_REVT: /* RF Field information */ 351 dm_cback_data.rf_field.status = NFA_STATUS_OK; 352 dm_cback_data.rf_field.rf_field_status = p_data->rf_field.rf_field; 353 (*nfa_dm_cb.p_dm_cback) (NFA_DM_RF_FIELD_EVT, &dm_cback_data); 354 break; 355 356 case NFC_SET_ROUTING_REVT: /* Configure Routing response */ 357 break; 358 359 case NFC_GET_ROUTING_REVT: /* Retrieve Routing response */ 360 break; 361 362 case NFC_GEN_ERROR_REVT: /* generic error command or notification */ 363 break; 364 365 case NFC_NFCC_RESTART_REVT: /* NFCC has been re-initialized */ 366 367 if (p_data->status == NFC_STATUS_OK) 368 { 369 nfa_dm_cb.nfcc_pwr_mode = NFA_DM_PWR_MODE_FULL; 370 nfa_dm_cb.flags |= NFA_DM_FLAGS_NFCC_IS_RESTORING; 371 372 /* NFCC will start from IDLE when turned on again */ 373 nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_W4_RSP; 374 nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_W4_NTF; 375 nfa_dm_cb.disc_cb.disc_state = NFA_DM_RFST_IDLE; 376 } 377 else 378 { 379 nfa_dm_cb.nfcc_pwr_mode = NFA_DM_PWR_MODE_OFF_SLEEP; 380 } 381 /* Notify NFA submodules change of NFCC power mode */ 382 nfa_sys_cback_reg_nfcc_power_mode_proc_complete (nfa_dm_nfcc_power_mode_proc_complete_cback); 383 nfa_sys_notify_nfcc_power_mode (nfa_dm_cb.nfcc_pwr_mode); 384 break; 385 386 case NFC_NFCC_TIMEOUT_REVT: 387 case NFC_NFCC_TRANSPORT_ERR_REVT: 388 NFA_TRACE_DEBUG1 ("flags:0x%08x", nfa_dm_cb.flags); 389 dm_cback_evt = (event == NFC_NFCC_TIMEOUT_REVT) ? NFA_DM_NFCC_TIMEOUT_EVT : NFA_DM_NFCC_TRANSPORT_ERR_EVT; 390 (*nfa_dm_cb.p_dm_cback) (dm_cback_evt, NULL); 391 break; 392 393 case NFC_NFCC_POWER_OFF_REVT: 394 nfa_dm_cb.nfcc_pwr_mode = NFA_DM_PWR_MODE_OFF_SLEEP; 395 396 /* Notify NFA submodules change of NFCC power mode */ 397 nfa_sys_cback_reg_nfcc_power_mode_proc_complete (nfa_dm_nfcc_power_mode_proc_complete_cback); 398 nfa_sys_notify_nfcc_power_mode (NFA_DM_PWR_MODE_OFF_SLEEP); 399 break; 400 401 case NFC_RF_COMM_PARAMS_UPDATE_REVT: 402 conn_evt.status = p_data->status; 403 nfa_dm_conn_cback_event_notify (NFA_UPDATE_RF_PARAM_RESULT_EVT, &conn_evt); 404 break; 405 406 407 default: 408 break; 409 } 410} 411 412 413/******************************************************************************* 414** 415** Function nfa_dm_enable 416** 417** Description Initialises the NFC device manager 418** 419** Returns TRUE (message buffer to be freed by caller) 420** 421*******************************************************************************/ 422BOOLEAN nfa_dm_enable (tNFA_DM_MSG *p_data) 423{ 424 tNFA_DM_CBACK_DATA dm_cback_data; 425 NFA_TRACE_DEBUG0 ("nfa_dm_enable ()"); 426 427 /* Check if NFA is already enabled */ 428 if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_DM_IS_ACTIVE)) 429 { 430 /* Initialize BRCM control block, it musb be called before setting any flags */ 431 nfa_dm_cb.flags |= (NFA_DM_FLAGS_DM_IS_ACTIVE | NFA_DM_FLAGS_ENABLE_EVT_PEND); 432 nfa_sys_cback_reg_enable_complete (nfa_dm_module_init_cback); 433 434 435 /* Store Enable parameters */ 436 nfa_dm_cb.p_dm_cback = p_data->enable.p_dm_cback; 437 nfa_dm_cb.p_conn_cback = p_data->enable.p_conn_cback; 438 439 /* Enable NFC stack */ 440 NFC_Enable (nfa_dm_nfc_response_cback); 441 } 442 else 443 { 444 NFA_TRACE_ERROR0 ("nfa_dm_enable: ERROR ALREADY ENABLED."); 445 dm_cback_data.status = NFA_STATUS_ALREADY_STARTED; 446 (*(p_data->enable.p_dm_cback)) (NFA_DM_ENABLE_EVT, &dm_cback_data); 447 } 448 449 return (TRUE); 450} 451 452/******************************************************************************* 453** 454** Function nfa_dm_disable 455** 456** Description Disables the NFC device manager 457** 458** Returns TRUE (message buffer to be freed by caller) 459** 460*******************************************************************************/ 461BOOLEAN nfa_dm_disable (tNFA_DM_MSG *p_data) 462{ 463 tNFC_DEACT_TYPE deactivate_type = NFA_DEACTIVATE_TYPE_IDLE; 464 465 NFA_TRACE_DEBUG1 ("nfa_dm_disable (): graceful:%d", p_data->disable.graceful); 466 467 if (p_data->disable.graceful) 468 { 469 /* if RF discovery is enabled */ 470 if (nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_ENABLED) 471 { 472 nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_ENABLED; 473 474 if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_IDLE) 475 { 476 /* if waiting RSP in idle state */ 477 if (nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_W4_RSP) 478 { 479 nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_DISABLING; 480 } 481 } 482 else 483 { 484 nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_DISABLING; 485 nfa_dm_disc_sm_execute (NFA_DM_RF_DEACTIVATE_CMD, (tNFA_DM_RF_DISC_DATA *) &deactivate_type); 486 if ((nfa_dm_cb.disc_cb.disc_flags & (NFA_DM_DISC_FLAGS_W4_RSP|NFA_DM_DISC_FLAGS_W4_NTF)) == 0) 487 { 488 /* not waiting to deactivate, clear the flag now */ 489 nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_DISABLING; 490 } 491 } 492 } 493 /* Start timeout for graceful shutdown. If timer expires, then force an ungraceful shutdown */ 494 nfa_sys_start_timer (&nfa_dm_cb.tle, NFA_DM_TIMEOUT_DISABLE_EVT, NFA_DM_DISABLE_TIMEOUT_VAL); 495 } 496 497 /* Disable all subsystems other than DM (DM will be disabled after all */ 498 /* the other subsystem have been disabled) */ 499 nfa_sys_disable_subsystems (p_data->disable.graceful); 500 return (TRUE); 501} 502 503 504/******************************************************************************* 505** 506** Function nfa_dm_disable_complete 507** 508** Description Called when all NFA subsytems are disabled. 509** 510** NFC core stack can now be disabled. 511** 512** Returns void 513** 514*******************************************************************************/ 515void nfa_dm_disable_complete (void) 516{ 517 NFA_TRACE_DEBUG0 ("nfa_dm_disable_complete ()"); 518 519 if ((nfa_dm_cb.flags & NFA_DM_FLAGS_DM_DISABLING_NFC) == 0) 520 { 521 NFA_TRACE_DEBUG0 ("nfa_dm_disable_complete (): proceeding with nfc core shutdown."); 522 523 nfa_dm_cb.flags |= NFA_DM_FLAGS_DM_DISABLING_NFC; 524 525 nfa_sys_stop_timer (&nfa_dm_cb.tle); 526 527 /* Free all buffers for NDEF handlers */ 528 nfa_dm_ndef_dereg_all(); 529 530 /* Disable nfc core stack */ 531 NFC_Disable (); 532 } 533} 534 535/******************************************************************************* 536** 537** Function nfa_dm_set_config 538** 539** Description Process set config command 540** 541** Returns TRUE (message buffer to be freed by caller) 542** 543*******************************************************************************/ 544BOOLEAN nfa_dm_set_config (tNFA_DM_MSG *p_data) 545{ 546 tNFC_STATUS status; 547 UINT8 buff[255]; 548 UINT8 *p = buff; 549 550 tNFA_DM_CBACK_DATA dm_cback_data; 551 552 if (p_data->setconfig.length + 2 > 255) 553 { 554 /* Total length of TLV must be less than 256 (1 byte) */ 555 status = NFC_STATUS_FAILED; 556 } 557 else 558 { 559 UINT8_TO_STREAM (p, p_data->setconfig.param_id); 560 UINT8_TO_STREAM (p, p_data->setconfig.length); 561 ARRAY_TO_STREAM (p, p_data->setconfig.p_data, p_data->setconfig.length) 562 status = nfa_dm_check_set_config ((UINT8) (p_data->setconfig.length + 2), buff, TRUE); 563 } 564 565 if (status != NFC_STATUS_OK) 566 { 567 dm_cback_data.set_config.status = NFA_STATUS_INVALID_PARAM; 568 (*nfa_dm_cb.p_dm_cback) (NFA_DM_SET_CONFIG_EVT, &dm_cback_data); 569 } 570 571 return (TRUE); 572} 573 574/******************************************************************************* 575** 576** Function nfa_dm_get_config 577** 578** Description Process get config command 579** 580** Returns TRUE (message buffer to be freed by caller) 581** 582*******************************************************************************/ 583BOOLEAN nfa_dm_get_config (tNFA_DM_MSG *p_data) 584{ 585 NFC_GetConfig (p_data->getconfig.num_ids, p_data->getconfig.p_pmids); 586 587 return (TRUE); 588} 589 590/******************************************************************************* 591** 592** Function nfa_dm_conn_cback_event_notify 593** 594** Description Notify application of CONN_CBACK event, using appropriate 595** callback 596** 597** Returns nothing 598** 599*******************************************************************************/ 600void nfa_dm_conn_cback_event_notify (UINT8 event, tNFA_CONN_EVT_DATA *p_data) 601{ 602 if (nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE) 603 { 604 /* Use exclusive RF mode callback */ 605 if (nfa_dm_cb.p_excl_conn_cback) 606 (*nfa_dm_cb.p_excl_conn_cback) (event, p_data); 607 } 608 else 609 { 610 (*nfa_dm_cb.p_conn_cback) (event, p_data); 611 } 612} 613 614/******************************************************************************* 615** 616** Function nfa_dm_rel_excl_rf_control_and_notify 617** 618** Description Stop exclusive RF control and notify app of 619** NFA_EXCLUSIVE_RF_CONTROL_STOPPED_EVT 620** 621** Returns void 622** 623*******************************************************************************/ 624void nfa_dm_rel_excl_rf_control_and_notify (void) 625{ 626 tNFA_CONN_EVT_DATA conn_evt; 627 628 NFA_TRACE_DEBUG0 ("nfa_dm_rel_excl_rf_control_and_notify ()"); 629 630 /* Exclusive RF control stopped. Notify app */ 631 nfa_dm_cb.flags &= ~NFA_DM_FLAGS_EXCL_RF_ACTIVE; 632 633 /* Stop exclusive RF discovery for exclusive RF mode */ 634 nfa_dm_stop_excl_discovery (); 635 636 /* Notify app that exclusive RF control has stopped */ 637 conn_evt.status = NFA_STATUS_OK; 638 (*nfa_dm_cb.p_excl_conn_cback) (NFA_EXCLUSIVE_RF_CONTROL_STOPPED_EVT, &conn_evt); 639 nfa_dm_cb.p_excl_conn_cback = NULL; 640 nfa_dm_cb.p_excl_ndef_cback = NULL; 641} 642 643/******************************************************************************* 644** 645** Function nfa_dm_act_request_excl_rf_ctrl 646** 647** Description Request exclusive RF control 648** 649** Returns TRUE (message buffer to be freed by caller) 650** 651*******************************************************************************/ 652BOOLEAN nfa_dm_act_request_excl_rf_ctrl (tNFA_DM_MSG *p_data) 653{ 654 tNFA_CONN_EVT_DATA conn_evt; 655 656 NFA_TRACE_DEBUG0 ("nfa_dm_act_request_excl_rf_ctrl ()"); 657 658 if (!nfa_dm_cb.p_excl_conn_cback) 659 { 660 if (nfa_dm_cb.disc_cb.disc_state != NFA_DM_RFST_IDLE) 661 { 662 conn_evt.status = NFA_STATUS_FAILED; 663 (*p_data->req_excl_rf_ctrl.p_conn_cback) (NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT, &conn_evt); 664 return TRUE; 665 } 666 667 /* Store callbacks */ 668 nfa_dm_cb.p_excl_conn_cback = p_data->req_excl_rf_ctrl.p_conn_cback; 669 nfa_dm_cb.p_excl_ndef_cback = p_data->req_excl_rf_ctrl.p_ndef_cback; 670 671 nfa_dm_cb.flags |= NFA_DM_FLAGS_EXCL_RF_ACTIVE; 672 673 /* start exclusive RF discovery */ 674 nfa_dm_start_excl_discovery (p_data->req_excl_rf_ctrl.poll_mask, 675 &p_data->req_excl_rf_ctrl.listen_cfg, 676 nfa_dm_excl_disc_cback); 677 } 678 else 679 { 680 NFA_TRACE_ERROR0 ("Exclusive rf control already requested"); 681 682 conn_evt.status = NFA_STATUS_FAILED; 683 (*p_data->req_excl_rf_ctrl.p_conn_cback) (NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT, &conn_evt); 684 } 685 686 return TRUE; 687} 688 689 690/******************************************************************************* 691** 692** Function nfa_dm_act_release_excl_rf_ctrl 693** 694** Description Release exclusive RF control 695** 696** Returns TRUE (message buffer to be freed by caller) 697** 698*******************************************************************************/ 699BOOLEAN nfa_dm_act_release_excl_rf_ctrl (tNFA_DM_MSG *p_data) 700{ 701 NFA_TRACE_DEBUG0 ("nfa_dm_act_release_excl_rf_ctrl ()"); 702 703 /* nfa_dm_rel_excl_rf_control_and_notify() is called when discovery state goes IDLE */ 704 nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_STOPPING; 705 706 /* if discover command has been sent in IDLE state and waiting for response 707 ** then just wait for responose. Otherwise initiate deactivating. 708 */ 709 if (!( (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_IDLE) 710 &&(nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_W4_RSP) )) 711 { 712 nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE); 713 } 714 715 return TRUE; 716} 717 718/******************************************************************************* 719** 720** Function nfa_dm_act_deactivate 721** 722** Description Process deactivate command 723** 724** Returns TRUE (message buffer to be freed by caller) 725** 726*******************************************************************************/ 727BOOLEAN nfa_dm_act_deactivate (tNFA_DM_MSG *p_data) 728{ 729 tNFA_CONN_EVT_DATA conn_evt; 730 tNFA_DEACTIVATE_TYPE deact_type; 731 732 NFA_TRACE_DEBUG0 ("nfa_dm_act_deactivate ()"); 733 734 if ( (p_data->deactivate.sleep_mode == FALSE) /* Always allow deactivate to IDLE */ 735 ||( (nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_T1T) /* Do not allow deactivate to SLEEP for T1T,NFCDEP, ISO15693 */ 736 &&(nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_NFC_DEP) 737 &&(nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_ISO15693) ) ) 738 { 739 if ( (nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_NFC_DEP) 740 &&((nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE) == 0x00) ) 741 { 742 /* Exclusive RF control doesn't use NFA P2P */ 743 /* NFA P2P will deactivate NFC link after deactivating LLCP link */ 744 nfa_p2p_deactivate_llcp (); 745 return (TRUE); 746 } 747 else 748 { 749 deact_type = NFA_DEACTIVATE_TYPE_DISCOVERY; 750 if (p_data->deactivate.sleep_mode) 751 { 752 if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_W4_HOST_SELECT) 753 { 754 /* Deactivate to sleep mode not allowed in this state. */ 755 deact_type = NFA_DEACTIVATE_TYPE_IDLE; 756 } 757 else if (nfa_dm_cb.disc_cb.disc_state != NFA_DM_RFST_LISTEN_SLEEP) 758 { 759 deact_type = NFA_DEACTIVATE_TYPE_SLEEP; 760 } 761 } 762 if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_W4_ALL_DISCOVERIES) 763 { 764 /* Only deactivate to IDLE is allowed in this state. */ 765 deact_type = NFA_DEACTIVATE_TYPE_IDLE; 766 } 767 if (nfa_dm_rf_deactivate (deact_type) == NFA_STATUS_OK) 768 { 769 nfa_rw_stop_presence_check_timer (); 770 return (TRUE); 771 } 772 } 773 } 774 775 NFA_TRACE_ERROR0 ("nfa_dm_act_deactivate (): invalid protocol or mode"); 776 777 /* Notify error to application */ 778 conn_evt.status = NFA_STATUS_FAILED; 779 nfa_dm_conn_cback_event_notify (NFA_DEACTIVATE_FAIL_EVT, &conn_evt); 780 781 return (TRUE); 782} 783 784/******************************************************************************* 785** 786** Function nfa_dm_act_power_off_sleep 787** 788** Description Process power off sleep mode request 789** 790** Returns TRUE (message buffer to be freed by caller) 791** 792*******************************************************************************/ 793BOOLEAN nfa_dm_act_power_off_sleep (tNFA_DM_MSG *p_data) 794{ 795 NFA_TRACE_DEBUG0 ("nfa_dm_act_power_off_sleep ()"); 796 797 NFC_SetPowerOffSleep ((BOOLEAN) (p_data->hdr.layer_specific)); 798 799 return (TRUE); 800} 801 802/******************************************************************************* 803** 804** Function nfa_dm_act_reg_vsc 805** 806** Description Process registers VSC callback 807** 808** Returns TRUE (message buffer to be freed by caller) 809** 810*******************************************************************************/ 811BOOLEAN nfa_dm_act_reg_vsc(tNFA_DM_MSG *p_data) 812{ 813 if (NFC_RegVSCback(p_data->reg_vsc.is_register, p_data->reg_vsc.p_cback) != NFC_STATUS_OK) 814 { 815 NFA_TRACE_ERROR0 ("NFC_RegVSCback failed"); 816 } 817 return (TRUE); 818} 819 820/******************************************************************************* 821** 822** Function nfa_dm_act_send_vsc 823** 824** Description Send the NCI Vendor Specific command to the NCI command queue 825** 826** Returns FALSE (message buffer is NOT freed by caller) 827** 828*******************************************************************************/ 829BOOLEAN nfa_dm_act_send_vsc(tNFA_DM_MSG *p_data) 830{ 831 BT_HDR *p_cmd = (BT_HDR *)p_data; 832 833 p_cmd->offset = sizeof (tNFA_DM_API_SEND_VSC) - BT_HDR_SIZE; 834 p_cmd->len = p_data->send_vsc.cmd_params_len; 835 NFC_SendVsCommand (p_data->send_vsc.oid, p_cmd, p_data->send_vsc.p_cback); 836 837 /* Most dm action functions return TRUE, so nfa-sys frees the GKI buffer carrying the message, 838 * This action function re-use the GKI buffer to send the VSC, so the GKI buffer can not be freed by nfa-sys */ 839 return (FALSE); 840} 841 842/******************************************************************************* 843** 844** Function nfa_dm_start_polling 845** 846** Description Start polling 847** 848** Returns tNFA_STATUS 849** 850*******************************************************************************/ 851tNFA_STATUS nfa_dm_start_polling (void) 852{ 853 tNFA_STATUS status; 854 tNFA_TECHNOLOGY_MASK poll_tech_mask; 855 tNFA_DM_DISC_TECH_PROTO_MASK poll_disc_mask = 0; 856 857 NFA_TRACE_DEBUG0 ("nfa_dm_start_polling ()"); 858 859 poll_tech_mask = nfa_dm_cb.poll_mask; 860 861 /* start RF discovery with discovery callback */ 862 if (nfa_dm_cb.poll_disc_handle == NFA_HANDLE_INVALID) 863 { 864 if (poll_tech_mask & NFA_TECHNOLOGY_MASK_A) 865 { 866 poll_disc_mask |= NFA_DM_DISC_MASK_PA_T1T; 867 poll_disc_mask |= NFA_DM_DISC_MASK_PA_T2T; 868 poll_disc_mask |= NFA_DM_DISC_MASK_PA_ISO_DEP; 869 poll_disc_mask |= NFA_DM_DISC_MASK_PA_NFC_DEP; 870 poll_disc_mask |= NFA_DM_DISC_MASK_P_LEGACY; 871 } 872 if (poll_tech_mask & NFA_TECHNOLOGY_MASK_A_ACTIVE) 873 { 874 poll_disc_mask |= NFA_DM_DISC_MASK_PAA_NFC_DEP; 875 } 876 if (poll_tech_mask & NFA_TECHNOLOGY_MASK_B) 877 { 878 poll_disc_mask |= NFA_DM_DISC_MASK_PB_ISO_DEP; 879 } 880 if (poll_tech_mask & NFA_TECHNOLOGY_MASK_F) 881 { 882 poll_disc_mask |= NFA_DM_DISC_MASK_PF_T3T; 883 poll_disc_mask |= NFA_DM_DISC_MASK_PF_NFC_DEP; 884 } 885 if (poll_tech_mask & NFA_TECHNOLOGY_MASK_F_ACTIVE) 886 { 887 poll_disc_mask |= NFA_DM_DISC_MASK_PFA_NFC_DEP; 888 } 889 if (poll_tech_mask & NFA_TECHNOLOGY_MASK_ISO15693) 890 { 891 poll_disc_mask |= NFA_DM_DISC_MASK_P_ISO15693; 892 } 893 if (poll_tech_mask & NFA_TECHNOLOGY_MASK_B_PRIME) 894 { 895 poll_disc_mask |= NFA_DM_DISC_MASK_P_B_PRIME; 896 } 897 if (poll_tech_mask & NFA_TECHNOLOGY_MASK_KOVIO) 898 { 899 poll_disc_mask |= NFA_DM_DISC_MASK_P_KOVIO; 900 } 901 902 nfa_dm_cb.poll_disc_handle = nfa_dm_add_rf_discover (poll_disc_mask, 903 NFA_DM_DISC_HOST_ID_DH, 904 nfa_dm_poll_disc_cback); 905 906 if (nfa_dm_cb.poll_disc_handle != NFA_HANDLE_INVALID) 907 status = NFA_STATUS_OK; 908 else 909 status = NFA_STATUS_FAILED; 910 } 911 else 912 { 913 status = NFA_STATUS_OK; 914 } 915 916 return (status); 917} 918 919/******************************************************************************* 920** 921** Function nfa_dm_act_enable_polling 922** 923** Description Process enable polling command 924** 925** Returns TRUE (message buffer to be freed by caller) 926** 927*******************************************************************************/ 928BOOLEAN nfa_dm_act_enable_polling (tNFA_DM_MSG *p_data) 929{ 930 tNFA_CONN_EVT_DATA evt_data; 931 932 NFA_TRACE_DEBUG0 ("nfa_dm_act_enable_polling ()"); 933 934 if ( (!(nfa_dm_cb.flags & NFA_DM_FLAGS_POLLING_ENABLED)) 935 &&(!(nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE) ) ) 936 { 937 nfa_dm_cb.poll_mask = p_data->enable_poll.poll_mask; 938 939 if (nfa_dm_start_polling () == NFA_STATUS_OK) 940 { 941 nfa_dm_cb.flags |= NFA_DM_FLAGS_POLLING_ENABLED; 942 943 evt_data.status = NFA_STATUS_OK; 944 nfa_dm_conn_cback_event_notify (NFA_POLL_ENABLED_EVT, &evt_data); 945 return (TRUE); 946 } 947 } 948 else 949 { 950 NFA_TRACE_ERROR0 ("nfa_dm_act_enable_polling (): already started"); 951 } 952 953 /* send NFA_POLL_ENABLED_EVT with NFA_STATUS_FAILED */ 954 evt_data.status = NFA_STATUS_FAILED; 955 nfa_dm_conn_cback_event_notify (NFA_POLL_ENABLED_EVT, &evt_data); 956 957 return (TRUE); 958} 959 960/******************************************************************************* 961** 962** Function nfa_dm_deactivate_polling 963** 964** Description Deactivate any polling state 965** 966** Returns TRUE if need to wait for deactivation 967** 968*******************************************************************************/ 969static BOOLEAN nfa_dm_deactivate_polling (void) 970{ 971 NFA_TRACE_DEBUG0 ("nfa_dm_deactivate_polling ()"); 972 973 if ( (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_W4_ALL_DISCOVERIES) 974 ||(nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_W4_HOST_SELECT) ) 975 { 976 nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE); 977 return FALSE; 978 } 979 else if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_POLL_ACTIVE) 980 { 981 if (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_NFC_DEP) 982 { 983 /* NFA P2P will deactivate NFC link after deactivating LLCP link */ 984 nfa_p2p_deactivate_llcp (); 985 } 986 else 987 { 988 nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE); 989 } 990 return TRUE; 991 } 992 else 993 { 994 return FALSE; 995 } 996} 997 998/******************************************************************************* 999** 1000** Function nfa_dm_act_disable_polling 1001** 1002** Description Process disable polling command 1003** 1004** Returns TRUE (message buffer to be freed by caller) 1005** 1006*******************************************************************************/ 1007BOOLEAN nfa_dm_act_disable_polling (tNFA_DM_MSG *p_data) 1008{ 1009 tNFA_CONN_EVT_DATA evt_data; 1010 1011 NFA_TRACE_DEBUG0 ("nfa_dm_act_disable_polling ()"); 1012 1013 if (nfa_dm_cb.poll_disc_handle != NFA_HANDLE_INVALID) 1014 { 1015 nfa_dm_cb.flags &= ~NFA_DM_FLAGS_POLLING_ENABLED; 1016 1017 if (nfa_dm_deactivate_polling () == FALSE) 1018 { 1019 nfa_dm_delete_rf_discover (nfa_dm_cb.poll_disc_handle); 1020 nfa_dm_cb.poll_disc_handle = NFA_HANDLE_INVALID; 1021 1022 evt_data.status = NFA_STATUS_OK; 1023 nfa_dm_conn_cback_event_notify (NFA_POLL_DISABLED_EVT, &evt_data); 1024 } 1025 else 1026 { 1027 nfa_dm_cb.flags |= NFA_DM_FLAGS_SEND_POLL_STOP_EVT; 1028 } 1029 } 1030 else 1031 { 1032 evt_data.status = NFA_STATUS_FAILED; 1033 nfa_dm_conn_cback_event_notify (NFA_POLL_DISABLED_EVT, &evt_data); 1034 } 1035 1036 return (TRUE); 1037} 1038 1039/******************************************************************************* 1040** 1041** Function nfa_dm_act_send_raw_frame 1042** 1043** Description Send an raw frame on RF link 1044** 1045** Returns TRUE (message buffer to be freed by caller) 1046** 1047*******************************************************************************/ 1048BOOLEAN nfa_dm_act_send_raw_frame (tNFA_DM_MSG *p_data) 1049{ 1050 tNFC_STATUS status = NFC_STATUS_FAILED; 1051 1052 NFA_TRACE_DEBUG0 ("nfa_dm_act_send_raw_frame ()"); 1053 1054 /* If NFC link is activated */ 1055 if ( (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_POLL_ACTIVE) 1056 ||(nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_LISTEN_ACTIVE) ) 1057 { 1058 /* If not in exclusive mode, and not activated for LISTEN, then forward raw data to NFA_RW to send */ 1059 if ( !(nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE) 1060 &&!(nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_LISTEN_ACTIVE) 1061 &&( (nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_T1T) 1062 ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_T2T) 1063 ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_T3T) 1064 ||( (nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_ISO_DEP) 1065 &&(nfa_dm_cb.disc_cb.activated_rf_interface == NFC_INTERFACE_ISO_DEP) ) 1066 ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_ISO15693) ) ) 1067 { 1068 /* if RW is checking presence then it will put into pending queue */ 1069 status = nfa_rw_send_raw_frame ((BT_HDR*)p_data); 1070 } 1071 else 1072 { 1073 status = NFC_SendData (NFC_RF_CONN_ID, (BT_HDR*) p_data); 1074 /* Already freed or NCI layer will free buffer */ 1075 return FALSE; 1076 } 1077 } 1078 1079 if (status == NFC_STATUS_FAILED) 1080 { 1081 /* free the buffer */ 1082 return TRUE; 1083 } 1084 else 1085 { 1086 /* NCI layer will free buffer */ 1087 return FALSE; 1088 } 1089} 1090 1091/******************************************************************************* 1092** 1093** Function nfa_dm_set_p2p_listen_tech 1094** 1095** Description Notify change of P2P listen technologies to NFA P2P 1096** 1097** Returns TRUE (message buffer to be freed by caller) 1098** 1099*******************************************************************************/ 1100BOOLEAN nfa_dm_set_p2p_listen_tech (tNFA_DM_MSG *p_data) 1101{ 1102 NFA_TRACE_DEBUG1 ("nfa_dm_set_p2p_listen_tech () tech_mask = %d", 1103 p_data->set_p2p_listen_tech.tech_mask); 1104 1105 nfa_p2p_update_listen_tech (p_data->set_p2p_listen_tech.tech_mask); 1106 nfa_dm_conn_cback_event_notify (NFA_SET_P2P_LISTEN_TECH_EVT, NULL); 1107 1108 return (TRUE); 1109} 1110 1111/******************************************************************************* 1112** 1113** Function nfa_dm_act_start_rf_discovery 1114** 1115** Description Process start RF discovery command 1116** 1117** Returns TRUE (message buffer to be freed by caller) 1118** 1119*******************************************************************************/ 1120BOOLEAN nfa_dm_act_start_rf_discovery (tNFA_DM_MSG *p_data) 1121{ 1122 tNFA_CONN_EVT_DATA evt_data; 1123 1124 NFA_TRACE_DEBUG0 ("nfa_dm_act_start_rf_discovery ()"); 1125 1126 if (nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_ENABLED) 1127 { 1128 evt_data.status = NFA_STATUS_OK; 1129 nfa_dm_conn_cback_event_notify (NFA_RF_DISCOVERY_STARTED_EVT, &evt_data); 1130 } 1131 else if (nfa_dm_cb.disc_cb.disc_state != NFA_DM_RFST_IDLE) 1132 { 1133 evt_data.status = NFA_STATUS_SEMANTIC_ERROR; 1134 nfa_dm_conn_cback_event_notify (NFA_RF_DISCOVERY_STARTED_EVT, &evt_data); 1135 } 1136 else 1137 { 1138 nfa_dm_cb.disc_cb.disc_flags |= (NFA_DM_DISC_FLAGS_ENABLED|NFA_DM_DISC_FLAGS_NOTIFY); 1139 nfa_dm_start_rf_discover (); 1140 } 1141 1142 return (TRUE); 1143} 1144 1145/******************************************************************************* 1146** 1147** Function nfa_dm_act_stop_rf_discovery 1148** 1149** Description Process stop RF discovery command 1150** 1151** Returns TRUE (message buffer to be freed by caller) 1152** 1153*******************************************************************************/ 1154BOOLEAN nfa_dm_act_stop_rf_discovery (tNFA_DM_MSG *p_data) 1155{ 1156 tNFA_CONN_EVT_DATA evt_data; 1157 1158 NFA_TRACE_DEBUG0 ("nfa_dm_act_stop_rf_discovery ()"); 1159 1160 if (!(nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_ENABLED) || 1161 (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_IDLE) ) 1162 { 1163 nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_ENABLED; 1164 1165 /* if discover command has been sent in IDLE state and waiting for response */ 1166 if (nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_W4_RSP) 1167 { 1168 nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_STOPPING; 1169 } 1170 else 1171 { 1172 evt_data.status = NFA_STATUS_OK; 1173 nfa_dm_conn_cback_event_notify (NFA_RF_DISCOVERY_STOPPED_EVT, &evt_data); 1174 } 1175 } 1176 else 1177 { 1178 nfa_dm_cb.disc_cb.disc_flags &= ~NFA_DM_DISC_FLAGS_ENABLED; 1179 nfa_dm_cb.disc_cb.disc_flags |= NFA_DM_DISC_FLAGS_STOPPING; 1180 nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_IDLE); 1181 } 1182 return (TRUE); 1183} 1184 1185/******************************************************************************* 1186** 1187** Function nfa_dm_act_set_rf_disc_duration 1188** 1189** Description Set duration for RF discovery 1190** 1191** Returns TRUE (message buffer to be freed by caller) 1192** 1193*******************************************************************************/ 1194BOOLEAN nfa_dm_act_set_rf_disc_duration (tNFA_DM_MSG *p_data) 1195{ 1196 nfa_dm_cb.disc_cb.disc_duration = p_data->disc_duration.rf_disc_dur_ms; 1197 return (TRUE); 1198} 1199 1200/******************************************************************************* 1201** 1202** Function nfa_dm_act_select 1203** 1204** Description Process RF select command 1205** 1206** Returns TRUE (message buffer to be freed by caller) 1207** 1208*******************************************************************************/ 1209BOOLEAN nfa_dm_act_select (tNFA_DM_MSG *p_data) 1210{ 1211 NFA_TRACE_DEBUG0 ("nfa_dm_act_select ()"); 1212 1213 nfa_dm_rf_discover_select (p_data->select.rf_disc_id, 1214 p_data->select.protocol, 1215 p_data->select.rf_interface); 1216 return (TRUE); 1217} 1218 1219/******************************************************************************* 1220** 1221** Function nfa_dm_act_update_rf_params 1222** 1223** Description Process update RF communication parameters command 1224** 1225** Returns TRUE (message buffer to be freed by caller) 1226** 1227*******************************************************************************/ 1228BOOLEAN nfa_dm_act_update_rf_params (tNFA_DM_MSG *p_data) 1229{ 1230 tNFA_CONN_EVT_DATA conn_evt; 1231 1232 NFA_TRACE_DEBUG0 ("nfa_dm_act_update_rf_params ()"); 1233 1234 if (NFC_UpdateRFCommParams (&p_data->update_rf_params.params) != NFC_STATUS_OK) 1235 { 1236 conn_evt.status = NFA_STATUS_FAILED; 1237 nfa_dm_conn_cback_event_notify (NFA_UPDATE_RF_PARAM_RESULT_EVT, &conn_evt); 1238 } 1239 1240 return (TRUE); 1241} 1242 1243/******************************************************************************* 1244** 1245** Function nfa_dm_act_disable_timeout 1246** 1247** Description timeout on disable process. Shutdown immediately 1248** 1249** Returns TRUE (message buffer to be freed by caller) 1250** 1251*******************************************************************************/ 1252BOOLEAN nfa_dm_act_disable_timeout (tNFA_DM_MSG *p_data) 1253{ 1254 tNFA_DM_API_DISABLE disable; 1255 1256 disable.graceful = FALSE; 1257 nfa_dm_disable ((tNFA_DM_MSG *) &disable); 1258 return (TRUE); 1259} 1260 1261/******************************************************************************* 1262** 1263** Function nfa_dm_act_conn_cback_notify 1264** 1265** Description Notify app of reader/writer/ndef events 1266** 1267** Returns nothing 1268** 1269*******************************************************************************/ 1270void nfa_dm_act_conn_cback_notify (UINT8 event, tNFA_CONN_EVT_DATA *p_data) 1271{ 1272 NFA_TRACE_DEBUG1 ("nfa_dm_act_conn_cback_notify (): event:0x%X", event); 1273 1274 /* Notify event using appropriate CONN_CBACK */ 1275 nfa_dm_conn_cback_event_notify (event, p_data); 1276 1277 /* If not in exclusive RF mode, then read NDEF message from tag (if automatic reading is enabled) */ 1278 if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE)) 1279 { 1280 if ( (event == NFA_NDEF_DETECT_EVT) 1281 &&(nfa_dm_cb.flags & NFA_DM_FLAGS_AUTO_READING_NDEF) ) 1282 { 1283 /* read NDEF message from tag */ 1284 if (p_data->ndef_detect.status == NFA_STATUS_OK) 1285 { 1286 NFA_RwReadNDef (); 1287 } 1288 else if (p_data->ndef_detect.status == NFA_STATUS_FAILED) 1289 { 1290 nfa_dm_cb.flags &= ~NFA_DM_FLAGS_AUTO_READING_NDEF; 1291 } 1292 /* ignore NFA_STATUS_BUSY */ 1293 } 1294 else if ( (event == NFA_READ_CPLT_EVT) 1295 &&(nfa_dm_cb.flags & NFA_DM_FLAGS_AUTO_READING_NDEF)) 1296 { 1297 /* reading NDEF message is done */ 1298 nfa_dm_cb.flags &= ~NFA_DM_FLAGS_AUTO_READING_NDEF; 1299 } 1300 } 1301} 1302 1303/******************************************************************************* 1304** 1305** Function nfa_dm_act_data_cback 1306** 1307** Description Processing data from RF link 1308** 1309** Returns None 1310** 1311*******************************************************************************/ 1312static void nfa_dm_act_data_cback (UINT8 conn_id, tNFC_CONN_EVT event, tNFC_CONN *p_data) 1313{ 1314 BT_HDR *p_msg = (BT_HDR *) p_data->data.p_data; 1315 tNFA_CONN_EVT_DATA evt_data; 1316 1317 NFA_TRACE_DEBUG1 ("nfa_dm_act_data_cback (): event = 0x%X", event); 1318 1319 if (event == NFC_DATA_CEVT) 1320 { 1321 if (p_msg) 1322 { 1323 evt_data.data.p_data = (UINT8 *) (p_msg + 1) + p_msg->offset; 1324 evt_data.data.len = p_msg->len; 1325 1326 nfa_dm_conn_cback_event_notify (NFA_DATA_EVT, &evt_data); 1327 1328 GKI_freebuf (p_msg); 1329 } 1330 else 1331 { 1332 NFA_TRACE_ERROR0 ("nfa_dm_act_data_cback (): received NFC_DATA_CEVT with NULL data pointer"); 1333 } 1334 } 1335 else if (event == NFC_DEACTIVATE_CEVT) 1336 { 1337 NFC_SetStaticRfCback (NULL); 1338 } 1339} 1340 1341/******************************************************************************* 1342** 1343** Function nfa_dm_excl_disc_cback 1344** 1345** Description Processing event from discovery callback 1346** 1347** Returns None 1348** 1349*******************************************************************************/ 1350static void nfa_dm_excl_disc_cback (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data) 1351{ 1352 tNFA_CONN_EVT_DATA evt_data; 1353 1354 NFA_TRACE_DEBUG1 ("nfa_dm_excl_disc_cback (): event:0x%02X", event); 1355 1356 switch (event) 1357 { 1358 case NFA_DM_RF_DISC_START_EVT: 1359 evt_data.status = NFA_STATUS_OK; 1360 nfa_dm_conn_cback_event_notify (NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT, &evt_data); 1361 break; 1362 1363 case NFA_DM_RF_DISC_ACTIVATED_EVT: 1364 if (nfa_dm_cb.disc_cb.activated_tech_mode == NFC_DISCOVERY_TYPE_POLL_A) 1365 { 1366 /* store SEL_RES response */ 1367 nfa_dm_cb.disc_cb.activated_sel_res = p_data->activate.rf_tech_param.param.pa.sel_rsp; 1368 } 1369 1370 if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_LISTEN_ACTIVE) 1371 { 1372 /* Set data callback to receive raw frame */ 1373 NFC_SetStaticRfCback (nfa_dm_act_data_cback); 1374 1375 memset (&(evt_data.activated.params), 0x00, sizeof (tNFA_TAG_PARAMS)); 1376 memcpy (&(evt_data.activated.activate_ntf), &(p_data->activate), sizeof (tNFC_ACTIVATE_DEVT)); 1377 1378 nfa_dm_conn_cback_event_notify (NFA_ACTIVATED_EVT, &evt_data); 1379 } 1380 else 1381 { 1382 /* holding activation notification until sub-module is ready */ 1383 nfa_dm_cb.p_activate_ntf = (UINT8*) GKI_getbuf (sizeof (tNFC_ACTIVATE_DEVT)); 1384 1385 if (nfa_dm_cb.p_activate_ntf) 1386 { 1387 memcpy (nfa_dm_cb.p_activate_ntf, 1388 &(p_data->activate), 1389 sizeof (tNFC_ACTIVATE_DEVT)); 1390 1391 if ( (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T1T) 1392 ||(nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T2T) 1393 ||(nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T3T) 1394 ||( (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_ISO_DEP) 1395 &&(nfa_dm_cb.disc_cb.activated_rf_interface == NFC_INTERFACE_ISO_DEP) ) 1396 ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_ISO15693) ) 1397 { 1398 /* Notify NFA tag sub-system */ 1399 nfa_rw_proc_disc_evt (NFA_DM_RF_DISC_ACTIVATED_EVT, p_data, FALSE); 1400 } 1401 else /* if NFC-DEP, ISO-DEP with frame interface or others */ 1402 { 1403 /* Set data callback to receive raw frame */ 1404 NFC_SetStaticRfCback (nfa_dm_act_data_cback); 1405 nfa_dm_notify_activation_status (NFA_STATUS_OK, NULL); 1406 } 1407 } 1408 else 1409 { 1410 /* deactivate and restart RF discovery */ 1411 nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_DISCOVERY); 1412 } 1413 } 1414 break; 1415 1416 case NFA_DM_RF_DISC_DEACTIVATED_EVT: 1417 1418 /* clear stored NFCID/UID */ 1419 nfa_dm_cb.activated_nfcid_len = 0; 1420 1421 if (nfa_dm_cb.disc_cb.activated_protocol != NFC_PROTOCOL_NFC_DEP) 1422 { 1423 /* Notify NFA RW sub-systems */ 1424 nfa_rw_proc_disc_evt (NFA_DM_RF_DISC_DEACTIVATED_EVT, NULL, FALSE); 1425 } 1426 1427 /* if deactivated as sleep mode */ 1428 if ( (p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP) 1429 ||(p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP_AF) ) 1430 { 1431 evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_SLEEP; 1432 } 1433 else 1434 { 1435 evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_IDLE; 1436 } 1437 1438 /* notify deactivation to upper layer */ 1439 nfa_dm_conn_cback_event_notify (NFA_DEACTIVATED_EVT, &evt_data); 1440 1441 /* clean up SEL_RES response */ 1442 nfa_dm_cb.disc_cb.activated_sel_res = 0; 1443 break; 1444 1445 default: 1446 NFA_TRACE_ERROR0 ("Unexpected event"); 1447 break; 1448 } 1449} 1450 1451/******************************************************************************* 1452** 1453** Function nfa_dm_poll_disc_cback 1454** 1455** Description Processing event from discovery callback 1456** 1457** Returns None 1458** 1459*******************************************************************************/ 1460static void nfa_dm_poll_disc_cback (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data) 1461{ 1462 tNFA_CONN_EVT_DATA evt_data; 1463 1464 NFA_TRACE_DEBUG1 ("nfa_dm_poll_disc_cback (): event:0x%02X", event); 1465 1466 switch (event) 1467 { 1468 case NFA_DM_RF_DISC_START_EVT: 1469 break; 1470 1471 case NFA_DM_RF_DISC_ACTIVATED_EVT: 1472 1473 if (nfa_dm_cb.disc_cb.activated_tech_mode == NFC_DISCOVERY_TYPE_POLL_A) 1474 { 1475 /* store SEL_RES response */ 1476 nfa_dm_cb.disc_cb.activated_sel_res = p_data->activate.rf_tech_param.param.pa.sel_rsp; 1477 } 1478 1479 /* holding activation notification until sub-module is ready */ 1480 nfa_dm_cb.p_activate_ntf = (UINT8*) GKI_getbuf (sizeof (tNFC_ACTIVATE_DEVT)); 1481 1482 if (nfa_dm_cb.p_activate_ntf) 1483 { 1484 memcpy (nfa_dm_cb.p_activate_ntf, 1485 &(p_data->activate), 1486 sizeof (tNFC_ACTIVATE_DEVT)); 1487 1488 if ( (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_NFC_DEP) 1489 &&(nfa_dm_cb.disc_cb.activated_rf_interface == NFC_INTERFACE_NFC_DEP) ) 1490 { 1491 /* activate LLCP */ 1492 nfa_p2p_activate_llcp (p_data); 1493 } 1494 else if ( (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T1T) 1495 ||(nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T2T) 1496 ||(nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T3T) 1497 ||( (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_ISO_DEP) 1498 &&(nfa_dm_cb.disc_cb.activated_rf_interface == NFC_INTERFACE_ISO_DEP) ) 1499 ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_ISO15693) ) 1500 { 1501 /* Notify NFA tag sub-system */ 1502 nfa_rw_proc_disc_evt (NFA_DM_RF_DISC_ACTIVATED_EVT, p_data, TRUE); 1503 } 1504 else /* if NFC-DEP/ISO-DEP with frame interface */ 1505 { 1506 /* Set data callback to receive raw frame */ 1507 NFC_SetStaticRfCback (nfa_dm_act_data_cback); 1508 nfa_dm_notify_activation_status (NFA_STATUS_OK, NULL); 1509 } 1510 } 1511 else 1512 { 1513 /* deactivate and restart RF discovery */ 1514 nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_DISCOVERY); 1515 } 1516 break; 1517 1518 case NFA_DM_RF_DISC_DEACTIVATED_EVT: 1519 1520 /* clear stored NFCID/UID */ 1521 nfa_dm_cb.activated_nfcid_len = 0; 1522 1523 if ( (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_NFC_DEP) 1524 &&(nfa_dm_cb.disc_cb.activated_rf_interface == NFC_INTERFACE_NFC_DEP) ) 1525 { 1526 /* 1527 ** If LLCP link is not deactivated yet, 1528 ** LLCP will receive deactivation ntf through data callback. 1529 ** NFA P2P will receive callback event from LLCP. 1530 */ 1531 } 1532 else 1533 { 1534 /* Notify NFA RW sub-systems */ 1535 nfa_rw_proc_disc_evt (NFA_DM_RF_DISC_DEACTIVATED_EVT, NULL, TRUE); 1536 } 1537 1538 /* if NFA sent NFA_ACTIVATED_EVT earlier */ 1539 if (nfa_dm_cb.flags & NFA_DM_FLAGS_SEND_DEACTIVATED_EVT) 1540 { 1541 nfa_dm_cb.flags &= ~NFA_DM_FLAGS_SEND_DEACTIVATED_EVT; 1542 1543 /* if deactivated as sleep mode */ 1544 if ( (p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP) 1545 ||(p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP_AF) ) 1546 { 1547 evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_SLEEP; 1548 } 1549 else 1550 { 1551 evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_IDLE; 1552 } 1553 /* notify deactivation to application */ 1554 nfa_dm_conn_cback_event_notify (NFA_DEACTIVATED_EVT, &evt_data); 1555 } 1556 1557 /* clean up SEL_RES response */ 1558 nfa_dm_cb.disc_cb.activated_sel_res = 0; 1559 1560 if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_POLLING_ENABLED)) 1561 { 1562 /* deregister discovery callback from NFA DM Discovery */ 1563 nfa_dm_delete_rf_discover (nfa_dm_cb.poll_disc_handle); 1564 nfa_dm_cb.poll_disc_handle = NFA_HANDLE_INVALID; 1565 1566 /* this is for disable polling */ 1567 if (nfa_dm_cb.flags & NFA_DM_FLAGS_SEND_POLL_STOP_EVT) 1568 { 1569 nfa_dm_cb.flags &= ~NFA_DM_FLAGS_SEND_POLL_STOP_EVT; 1570 1571 evt_data.status = NFA_STATUS_OK; 1572 nfa_dm_conn_cback_event_notify (NFA_POLL_DISABLED_EVT, &evt_data); 1573 } 1574 } 1575 break; 1576 } 1577} 1578 1579/******************************************************************************* 1580** 1581** Function nfa_dm_notify_activation_status 1582** 1583** Description Processing activation status from sub-modules 1584** 1585** Returns None 1586** 1587*******************************************************************************/ 1588void nfa_dm_notify_activation_status (tNFA_STATUS status, tNFA_TAG_PARAMS *p_params) 1589{ 1590 tNFA_CONN_EVT_DATA evt_data; 1591 tNFC_RF_TECH_PARAMS *p_tech_params; 1592 UINT8 *p_nfcid = NULL, nfcid_len; 1593 1594 NFA_TRACE_DEBUG1 ("nfa_dm_notify_activation_status (): status:0x%X", status); 1595 1596 if (!nfa_dm_cb.p_activate_ntf) 1597 { 1598 /* this is for NFA P2P listen */ 1599 return; 1600 } 1601 1602 if (status == NFA_STATUS_OK) 1603 { 1604 /* notify NFC link activation */ 1605 memcpy ( &(evt_data.activated.activate_ntf), 1606 nfa_dm_cb.p_activate_ntf, 1607 sizeof (tNFC_ACTIVATE_DEVT)); 1608 1609 p_tech_params = &evt_data.activated.activate_ntf.rf_tech_param; 1610 1611 if (p_params) 1612 { 1613 memcpy (&(evt_data.activated.params), 1614 p_params, 1615 sizeof (tNFA_TAG_PARAMS)); 1616 } 1617 1618 /* get length of NFCID and location */ 1619 if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_A) 1620 { 1621 nfcid_len = p_tech_params->param.pa.nfcid1_len; 1622 p_nfcid = p_tech_params->param.pa.nfcid1; 1623 } 1624 else if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_B) 1625 { 1626 nfcid_len = NFC_NFCID0_MAX_LEN; 1627 p_nfcid = p_tech_params->param.pb.nfcid0; 1628 } 1629 else if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_F) 1630 { 1631 nfcid_len = NFC_NFCID2_LEN; 1632 p_nfcid = p_tech_params->param.pf.nfcid2; 1633 } 1634 else if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_ISO15693) 1635 { 1636 nfcid_len = NFC_ISO15693_UID_LEN; 1637 p_nfcid = p_tech_params->param.pi93.uid; 1638 } 1639 else 1640 { 1641 nfcid_len = 0; 1642 } 1643 1644 /* 1645 ** If not in exlusive RF mode, and 1646 ** P2P activation, then push default NDEF message through SNEP 1647 ** TAG activation, then read NDEF message 1648 */ 1649 if (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_NFC_DEP) 1650 { 1651 /* 1652 ** Default NDEF message will be put to NFC Forum defualt SNEP server 1653 ** after receiving NFA_LLCP_ACTIVATED_EVT. 1654 */ 1655 } 1656 /* Do not perform NDEF operations on KOVIO */ 1657 else if (p_tech_params->mode == NFC_DISCOVERY_TYPE_POLL_KOVIO) 1658 { 1659 NFA_TRACE_DEBUG1 ("Not an NFC-Forum tag, bypassing NDEF detection", nfa_dm_cb.disc_cb.activated_protocol); 1660 } 1661 else if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE)) 1662 { 1663 /* 1664 ** if the same tag is activated then do not perform auto NDEF detection. 1665 ** Application may put a tag into sleep mode and reactivate the same tag. 1666 */ 1667 1668 if ( (p_tech_params->mode != nfa_dm_cb.disc_cb.activated_tech_mode) 1669 ||(nfcid_len != nfa_dm_cb.activated_nfcid_len) 1670 ||(memcmp (p_nfcid, nfa_dm_cb.activated_nfcid, nfcid_len))) 1671 { 1672 if ( (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T1T) 1673 ||(nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T2T) 1674 ||(nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T3T) 1675 ||( (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_ISO_DEP) 1676 &&(nfa_dm_cb.disc_cb.activated_rf_interface == NFC_INTERFACE_ISO_DEP) ) 1677 ||(nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_ISO15693) ) 1678 { 1679 if (p_nfa_dm_cfg->auto_detect_ndef) 1680 { 1681 if (p_nfa_dm_cfg->auto_read_ndef) 1682 { 1683 nfa_dm_cb.flags |= NFA_DM_FLAGS_AUTO_READING_NDEF; 1684 } 1685 NFA_RwDetectNDef (); 1686 } 1687 else if (p_nfa_dm_cfg->auto_read_ndef) 1688 { 1689 NFA_RwReadNDef (); 1690 } 1691 } 1692 } 1693 } 1694 1695 /* store activated tag information */ 1696 nfa_dm_cb.activated_nfcid_len = nfcid_len; 1697 if (nfcid_len) 1698 memcpy (nfa_dm_cb.activated_nfcid, p_nfcid, nfcid_len); 1699 1700 nfa_dm_cb.flags |= NFA_DM_FLAGS_SEND_DEACTIVATED_EVT; 1701 nfa_dm_conn_cback_event_notify (NFA_ACTIVATED_EVT, &evt_data); 1702 } 1703 else 1704 { 1705 /* if NFC_DEP, NFA P2P will deactivate */ 1706 if (nfa_dm_cb.disc_cb.activated_protocol != NFC_PROTOCOL_NFC_DEP) 1707 { 1708 nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_DISCOVERY); 1709 } 1710 } 1711 1712 GKI_freebuf (nfa_dm_cb.p_activate_ntf); 1713 nfa_dm_cb.p_activate_ntf = NULL; 1714} 1715 1716#if (BT_TRACE_VERBOSE == TRUE) 1717/******************************************************************************* 1718** 1719** Function nfa_dm_nfc_revt_2_str 1720** 1721** Description convert nfc revt to string 1722** 1723*******************************************************************************/ 1724char *nfa_dm_nfc_revt_2_str (tNFC_RESPONSE_EVT event) 1725{ 1726 switch (event) { 1727 case NFC_ENABLE_REVT: 1728 return "NFC_ENABLE_REVT"; 1729 1730 case NFC_DISABLE_REVT: 1731 return "NFC_DISABLE_REVT"; 1732 1733 case NFC_SET_CONFIG_REVT: 1734 return "NFC_SET_CONFIG_REVT"; 1735 1736 case NFC_GET_CONFIG_REVT: 1737 return "NFC_GET_CONFIG_REVT"; 1738 1739 case NFC_NFCEE_DISCOVER_REVT: 1740 return "NFC_NFCEE_DISCOVER_REVT"; 1741 1742 case NFC_NFCEE_INFO_REVT: 1743 return "NFC_NFCEE_INFO_REVT"; 1744 1745 case NFC_NFCEE_MODE_SET_REVT: 1746 return "NFC_NFCEE_MODE_SET_REVT"; 1747 1748 case NFC_RF_FIELD_REVT: 1749 return "NFC_RF_FIELD_REVT"; 1750 1751 case NFC_EE_ACTION_REVT: 1752 return "NFC_EE_ACTION_REVT"; 1753 1754 case NFC_EE_DISCOVER_REQ_REVT: 1755 return "NFC_EE_DISCOVER_REQ_REVT"; 1756 1757 case NFC_SET_ROUTING_REVT: 1758 return "NFC_SET_ROUTING_REVT"; 1759 1760 case NFC_GET_ROUTING_REVT: 1761 return "NFC_GET_ROUTING_REVT"; 1762 1763 case NFC_GEN_ERROR_REVT: 1764 return "NFC_GEN_ERROR_REVT"; 1765 1766 case NFC_NFCC_RESTART_REVT: 1767 return "NFC_NFCC_RESTART_REVT"; 1768 1769 case NFC_NFCC_TIMEOUT_REVT: 1770 return "NFC_NFCC_TIMEOUT_REVT"; 1771 1772 case NFC_NFCC_TRANSPORT_ERR_REVT: 1773 return "NFC_NFCC_TRANSPORT_ERR_REVT"; 1774 1775 case NFC_NFCC_POWER_OFF_REVT: 1776 return "NFC_NFCC_POWER_OFF_REVT"; 1777 1778 default: 1779 return "unknown revt"; 1780 break; 1781 } 1782} 1783#endif /* BT_VERBOSE */ 1784