• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2010-2014 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  *  This is the main implementation file for the NFA device manager.
22  *
23  ******************************************************************************/
24 #include <string>
25 
26 #include <android-base/stringprintf.h>
27 #include <base/logging.h>
28 #include <log/log.h>
29 
30 #include "nfa_api.h"
31 #include "nfa_dm_int.h"
32 
33 using android::base::StringPrintf;
34 
35 extern bool nfc_debug_enabled;
36 
37 /*****************************************************************************
38 ** Constants and types
39 *****************************************************************************/
40 static const tNFA_SYS_REG nfa_dm_sys_reg = {nfa_dm_sys_enable, nfa_dm_evt_hdlr,
41                                             nfa_dm_sys_disable,
42                                             nfa_dm_proc_nfcc_power_mode};
43 
44 tNFA_DM_CB nfa_dm_cb = {};
45 
46 #define NFA_DM_NUM_ACTIONS (NFA_DM_MAX_EVT & 0x00ff)
47 
48 /* type for action functions */
49 typedef bool (*tNFA_DM_ACTION)(tNFA_DM_MSG* p_data);
50 
51 /* action function list */
52 const tNFA_DM_ACTION nfa_dm_action[] = {
53     /* device manager local device API events */
54     nfa_dm_enable,                   /* NFA_DM_API_ENABLE_EVT                */
55     nfa_dm_disable,                  /* NFA_DM_API_DISABLE_EVT               */
56     nfa_dm_set_config,               /* NFA_DM_API_SET_CONFIG_EVT            */
57     nfa_dm_get_config,               /* NFA_DM_API_GET_CONFIG_EVT            */
58     nfa_dm_act_request_excl_rf_ctrl, /* NFA_DM_API_REQUEST_EXCL_RF_CTRL_EVT  */
59     nfa_dm_act_release_excl_rf_ctrl, /* NFA_DM_API_RELEASE_EXCL_RF_CTRL_EVT  */
60     nfa_dm_act_enable_polling,       /* NFA_DM_API_ENABLE_POLLING_EVT        */
61     nfa_dm_act_disable_polling,      /* NFA_DM_API_DISABLE_POLLING_EVT       */
62     nfa_dm_act_enable_listening,     /* NFA_DM_API_ENABLE_LISTENING_EVT      */
63     nfa_dm_act_disable_listening,    /* NFA_DM_API_DISABLE_LISTENING_EVT     */
64     nfa_dm_act_pause_p2p,            /* NFA_DM_API_PAUSE_P2P_EVT             */
65     nfa_dm_act_resume_p2p,           /* NFA_DM_API_RESUME_P2P_EVT            */
66     nfa_dm_act_send_raw_frame,       /* NFA_DM_API_RAW_FRAME_EVT             */
67     nfa_dm_set_p2p_listen_tech,      /* NFA_DM_API_SET_P2P_LISTEN_TECH_EVT   */
68     nfa_dm_act_start_rf_discovery,   /* NFA_DM_API_START_RF_DISCOVERY_EVT    */
69     nfa_dm_act_stop_rf_discovery,    /* NFA_DM_API_STOP_RF_DISCOVERY_EVT     */
70     nfa_dm_act_set_rf_disc_duration, /* NFA_DM_API_SET_RF_DISC_DURATION_EVT  */
71     nfa_dm_act_select,               /* NFA_DM_API_SELECT_EVT                */
72     nfa_dm_act_update_rf_params,     /* NFA_DM_API_UPDATE_RF_PARAMS_EVT      */
73     nfa_dm_act_deactivate,           /* NFA_DM_API_DEACTIVATE_EVT            */
74     nfa_dm_act_power_off_sleep,      /* NFA_DM_API_POWER_OFF_SLEEP_EVT       */
75     nfa_dm_ndef_reg_hdlr,            /* NFA_DM_API_REG_NDEF_HDLR_EVT         */
76     nfa_dm_ndef_dereg_hdlr,          /* NFA_DM_API_DEREG_NDEF_HDLR_EVT       */
77     nfa_dm_act_reg_vsc,              /* NFA_DM_API_REG_VSC_EVT               */
78     nfa_dm_act_send_vsc,             /* NFA_DM_API_SEND_VSC_EVT              */
79     nfa_dm_act_disable_timeout,      /* NFA_DM_TIMEOUT_DISABLE_EVT           */
80     nfa_dm_set_power_sub_state,      /* NFA_DM_API_SET_POWER_SUB_STATE_EVT   */
81     nfa_dm_act_send_raw_vs           /* NFA_DM_API_SEND_RAW_VS_EVT           */
82 };
83 
84 /*****************************************************************************
85 ** Local function prototypes
86 *****************************************************************************/
87 static std::string nfa_dm_evt_2_str(uint16_t event);
88 /*******************************************************************************
89 **
90 ** Function         nfa_dm_init
91 **
92 ** Description      Initialises the NFC device manager
93 **
94 ** Returns          void
95 **
96 *******************************************************************************/
nfa_dm_init(void)97 void nfa_dm_init(void) {
98   DLOG_IF(INFO, nfc_debug_enabled) << __func__;
99   memset(&nfa_dm_cb, 0, sizeof(tNFA_DM_CB));
100   nfa_dm_cb.poll_disc_handle = NFA_HANDLE_INVALID;
101   nfa_dm_cb.disc_cb.disc_duration = NFA_DM_DISC_DURATION_POLL;
102   nfa_dm_cb.nfcc_pwr_mode = NFA_DM_PWR_MODE_FULL;
103   nfa_dm_cb.pending_power_state = SCREEN_STATE_INVALID;
104 
105   /* register message handler on NFA SYS */
106   nfa_sys_register(NFA_ID_DM, &nfa_dm_sys_reg);
107 }
108 
109 /*******************************************************************************
110 **
111 ** Function         nfa_dm_evt_hdlr
112 **
113 ** Description      Event handling function for DM
114 **
115 **
116 ** Returns          void
117 **
118 *******************************************************************************/
nfa_dm_evt_hdlr(NFC_HDR * p_msg)119 bool nfa_dm_evt_hdlr(NFC_HDR* p_msg) {
120   bool freebuf = true;
121   uint16_t event = p_msg->event & 0x00ff;
122 
123   DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
124       "event: %s (0x%02x)", nfa_dm_evt_2_str(event).c_str(), event);
125 
126   /* execute action functions */
127   if (event < NFA_DM_NUM_ACTIONS) {
128     freebuf = (*nfa_dm_action[event])((tNFA_DM_MSG*)p_msg);
129   }
130   return freebuf;
131 }
132 
133 /*******************************************************************************
134 **
135 ** Function         nfa_dm_sys_disable
136 **
137 ** Description      This function is called after all subsystems have been
138 **                  disabled.
139 **
140 ** Returns          void
141 **
142 *******************************************************************************/
nfa_dm_sys_disable(void)143 void nfa_dm_sys_disable(void) {
144   /* Disable the DM sub-system */
145   /* If discovery state is not IDLE or DEACTIVATED and graceful disable, */
146   /* then we need to deactivate link or stop discovery                   */
147 
148   if (nfa_sys_is_graceful_disable()) {
149     if ((nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_IDLE) &&
150         ((nfa_dm_cb.disc_cb.disc_flags & NFA_DM_DISC_FLAGS_DISABLING) == 0)) {
151       /* discovery is not started */
152       nfa_dm_disable_complete();
153     } else {
154       /* probably waiting to be disabled */
155       LOG(WARNING) << StringPrintf("DM disc_state state = %d disc_flags:0x%x",
156                                    nfa_dm_cb.disc_cb.disc_state,
157                                    nfa_dm_cb.disc_cb.disc_flags);
158     }
159 
160   } else {
161     nfa_dm_disable_complete();
162   }
163 }
164 
165 /*******************************************************************************
166 **
167 ** Function         nfa_dm_is_protocol_supported
168 **
169 ** Description      Check if protocol is supported by RW module
170 **
171 ** Returns          TRUE if protocol is supported by NFA
172 **
173 *******************************************************************************/
nfa_dm_is_protocol_supported(tNFC_PROTOCOL protocol,uint8_t sel_res)174 bool nfa_dm_is_protocol_supported(tNFC_PROTOCOL protocol, uint8_t sel_res) {
175   return ((protocol == NFC_PROTOCOL_T1T) ||
176           ((protocol == NFC_PROTOCOL_T2T) &&
177            (sel_res == NFC_SEL_RES_NFC_FORUM_T2T)) ||
178           (protocol == NFC_PROTOCOL_T3T) ||
179           (protocol == NFC_PROTOCOL_ISO_DEP) ||
180           (protocol == NFC_PROTOCOL_NFC_DEP) ||
181           (protocol == NFC_PROTOCOL_T5T) || (protocol == NFC_PROTOCOL_MIFARE));
182 }
183 /*******************************************************************************
184 **
185 ** Function         nfa_dm_is_active
186 **
187 ** Description      check if all modules of NFA is done with enable process and
188 **                  NFA is not restoring NFCC.
189 **
190 ** Returns          TRUE, if NFA_DM_ENABLE_EVT is reported and it is not
191 **                  restoring NFCC
192 **
193 *******************************************************************************/
nfa_dm_is_active(void)194 bool nfa_dm_is_active(void) {
195   DLOG_IF(INFO, nfc_debug_enabled)
196       << StringPrintf("flags:0x%x", nfa_dm_cb.flags);
197   if ((nfa_dm_cb.flags & NFA_DM_FLAGS_DM_IS_ACTIVE) &&
198       ((nfa_dm_cb.flags &
199         (NFA_DM_FLAGS_ENABLE_EVT_PEND | NFA_DM_FLAGS_NFCC_IS_RESTORING |
200          NFA_DM_FLAGS_POWER_OFF_SLEEP)) == 0)) {
201     return true;
202   } else
203     return false;
204 }
205 /*******************************************************************************
206 **
207 ** Function         nfa_dm_check_set_config
208 **
209 ** Description      Update config parameters only if it's different from NFCC
210 **
211 **
212 ** Returns          tNFA_STATUS
213 **
214 *******************************************************************************/
nfa_dm_check_set_config(uint8_t tlv_list_len,uint8_t * p_tlv_list,bool app_init)215 tNFA_STATUS nfa_dm_check_set_config(uint8_t tlv_list_len, uint8_t* p_tlv_list,
216                                     bool app_init) {
217   uint8_t type, len, *p_value, *p_stored, max_len;
218   uint8_t xx = 0, updated_len = 0, *p_cur_len;
219   bool update;
220   tNFC_STATUS nfc_status;
221   uint32_t cur_bit;
222 
223   DLOG_IF(INFO, nfc_debug_enabled) << __func__;
224 
225   /* We only allow 32 pending SET_CONFIGs */
226   if (nfa_dm_cb.setcfg_pending_num >= NFA_DM_SETCONFIG_PENDING_MAX) {
227     LOG(ERROR) << StringPrintf(
228         "error: pending number of SET_CONFIG "
229         "exceeded");
230     return NFA_STATUS_FAILED;
231   }
232 
233   while (tlv_list_len - xx >= 2) /* at least type and len */
234   {
235     update = false;
236     type = *(p_tlv_list + xx);
237     len = *(p_tlv_list + xx + 1);
238     p_value = p_tlv_list + xx + 2;
239     p_cur_len = nullptr;
240     if (len > (tlv_list_len - xx - 2)) {
241       LOG(ERROR) << StringPrintf("error: invalid TLV length: t:0x%x, l:%d",
242                                  type, len);
243       android_errorWriteLog(0x534e4554, "221216105");
244       return NFA_STATUS_FAILED;
245     }
246 
247     switch (type) {
248       /*
249       **  Poll F Configuration
250       */
251       case NFC_PMID_PF_RC:
252         p_stored = nfa_dm_cb.params.pf_rc;
253         max_len = NCI_PARAM_LEN_PF_RC;
254         break;
255       case NFC_PMID_TOTAL_DURATION:
256         p_stored = nfa_dm_cb.params.total_duration;
257         max_len = NCI_PARAM_LEN_TOTAL_DURATION;
258         break;
259 
260       /*
261       **  Listen A Configuration
262       */
263       case NFC_PMID_LA_BIT_FRAME_SDD:
264         p_stored = nfa_dm_cb.params.la_bit_frame_sdd;
265         max_len = NCI_PARAM_LEN_LA_BIT_FRAME_SDD;
266         p_cur_len = &nfa_dm_cb.params.la_bit_frame_sdd_len;
267         break;
268       case NFC_PMID_LA_PLATFORM_CONFIG:
269         p_stored = nfa_dm_cb.params.la_platform_config;
270         max_len = NCI_PARAM_LEN_LA_PLATFORM_CONFIG;
271         p_cur_len = &nfa_dm_cb.params.la_platform_config_len;
272         break;
273       case NFC_PMID_LA_SEL_INFO:
274         p_stored = nfa_dm_cb.params.la_sel_info;
275         max_len = NCI_PARAM_LEN_LA_SEL_INFO;
276         p_cur_len = &nfa_dm_cb.params.la_sel_info_len;
277         break;
278       case NFC_PMID_LA_NFCID1:
279         p_stored = nfa_dm_cb.params.la_nfcid1;
280         max_len = NCI_NFCID1_MAX_LEN;
281         p_cur_len = &nfa_dm_cb.params.la_nfcid1_len;
282         break;
283       case NFC_PMID_LA_HIST_BY:
284         p_stored = nfa_dm_cb.params.la_hist_by;
285         max_len = NCI_MAX_HIS_BYTES_LEN;
286         p_cur_len = &nfa_dm_cb.params.la_hist_by_len;
287         break;
288 
289       /*
290       **  Listen B Configuration
291       */
292       case NFC_PMID_LB_SENSB_INFO:
293         p_stored = nfa_dm_cb.params.lb_sensb_info;
294         max_len = NCI_PARAM_LEN_LB_SENSB_INFO;
295         p_cur_len = &nfa_dm_cb.params.lb_sensb_info_len;
296         break;
297       case NFC_PMID_LB_NFCID0:
298         p_stored = nfa_dm_cb.params.lb_nfcid0;
299         max_len = NCI_PARAM_LEN_LB_NFCID0;
300         p_cur_len = &nfa_dm_cb.params.lb_nfcid0_len;
301         break;
302       case NFC_PMID_LB_APPDATA:
303         p_stored = nfa_dm_cb.params.lb_appdata;
304         max_len = NCI_PARAM_LEN_LB_APPDATA;
305         p_cur_len = &nfa_dm_cb.params.lb_appdata_len;
306         break;
307       case NFC_PMID_LB_ADC_FO:
308         p_stored = nfa_dm_cb.params.lb_adc_fo;
309         max_len = NCI_PARAM_LEN_LB_ADC_FO;
310         p_cur_len = &nfa_dm_cb.params.lb_adc_fo_len;
311         break;
312       case NFC_PMID_LB_H_INFO:
313         p_stored = nfa_dm_cb.params.lb_h_info;
314         max_len = NCI_MAX_ATTRIB_LEN;
315         p_cur_len = &nfa_dm_cb.params.lb_h_info_len;
316         break;
317 
318       /*
319       **  Listen F Configuration
320       */
321       case NFC_PMID_LF_PROTOCOL:
322         p_stored = nfa_dm_cb.params.lf_protocol;
323         max_len = NCI_PARAM_LEN_LF_PROTOCOL;
324         p_cur_len = &nfa_dm_cb.params.lf_protocol_len;
325         break;
326       case NFC_PMID_LF_T3T_FLAGS2:
327         p_stored = nfa_dm_cb.params.lf_t3t_flags2;
328         max_len = NCI_PARAM_LEN_LF_T3T_FLAGS2;
329         p_cur_len = &nfa_dm_cb.params.lf_t3t_flags2_len;
330         break;
331       case NFC_PMID_LF_T3T_PMM:
332         p_stored = nfa_dm_cb.params.lf_t3t_pmm;
333         max_len = NCI_PARAM_LEN_LF_T3T_PMM;
334         break;
335 
336       /*
337       **  ISO-DEP and NFC-DEP Configuration
338       */
339       case NFC_PMID_FWI:
340         p_stored = nfa_dm_cb.params.fwi;
341         max_len = NCI_PARAM_LEN_FWI;
342         break;
343       case NFC_PMID_WT:
344         p_stored = nfa_dm_cb.params.wt;
345         max_len = NCI_PARAM_LEN_WT;
346         break;
347       case NFC_PMID_ATR_REQ_GEN_BYTES:
348         p_stored = nfa_dm_cb.params.atr_req_gen_bytes;
349         max_len = NCI_MAX_GEN_BYTES_LEN;
350         p_cur_len = &nfa_dm_cb.params.atr_req_gen_bytes_len;
351         break;
352       case NFC_PMID_ATR_RES_GEN_BYTES:
353         p_stored = nfa_dm_cb.params.atr_res_gen_bytes;
354         max_len = NCI_MAX_GEN_BYTES_LEN;
355         p_cur_len = &nfa_dm_cb.params.atr_res_gen_bytes_len;
356         break;
357       default:
358         /*
359         **  Listen F Configuration
360         */
361         if ((type >= NFC_PMID_LF_T3T_ID1) &&
362             (type < NFC_PMID_LF_T3T_ID1 + NFA_CE_LISTEN_INFO_MAX)) {
363           p_stored = nfa_dm_cb.params.lf_t3t_id[type - NFC_PMID_LF_T3T_ID1];
364           max_len = NCI_PARAM_LEN_LF_T3T_ID(NFC_GetNCIVersion());
365         } else {
366           /* we don't stored this config items */
367           update = true;
368           p_stored = nullptr;
369         }
370         break;
371     }
372 
373     if ((p_stored) && (len <= max_len)) {
374       if (p_cur_len) {
375         if (*p_cur_len != len) {
376           *p_cur_len = len;
377           update = true;
378         } else if (memcmp(p_value, p_stored, len)) {
379           update = true;
380         } else if (appl_dta_mode_flag && app_init) {
381           /* In DTA mode, config update is forced so that length of config
382            * params (i.e update_len) is updated accordingly even for setconfig
383            * have only one tlv */
384           update = true;
385         }
386       } else if (len == max_len) /* fixed length */
387       {
388         if (memcmp(p_value, p_stored, len)) {
389           update = true;
390         } else if (appl_dta_mode_flag && app_init) {
391           /* In DTA mode, config update is forced so that length of config
392            * params (i.e update_len) is updated accordingly even for setconfig
393            * have only one tlv */
394           update = true;
395         }
396       }
397     }
398 
399     if (update) {
400       /* we don't store this type */
401       if (p_stored) {
402         memcpy(p_stored, p_value, len);
403       }
404 
405       /* If need to change TLV in the original list. (Do not modify list if
406        * app_init) */
407       if ((updated_len != xx) && (!app_init)) {
408         memcpy(p_tlv_list + updated_len, p_tlv_list + xx, (len + 2));
409       }
410       updated_len += (len + 2);
411     }
412     xx += len + 2; /* move to next TLV */
413   }
414 
415   /* If any TVLs to update, or if the SetConfig was initiated by the
416    * application, then send the SET_CONFIG command */
417   if (((updated_len || app_init) &&
418        (appl_dta_mode_flag == 0x00 ||
419         (nfa_dm_cb.eDtaMode & 0x0F) == NFA_DTA_HCEF_MODE)) ||
420       (appl_dta_mode_flag && app_init)) {
421     nfc_status = NFC_SetConfig(updated_len, p_tlv_list);
422 
423     if (nfc_status == NFC_STATUS_OK) {
424       if ((nfa_dm_cb.eDtaMode & 0x0F) == NFA_DTA_HCEF_MODE) {
425         nfa_dm_cb.eDtaMode &= ~NFA_DTA_HCEF_MODE;
426         nfa_dm_cb.eDtaMode |= NFA_DTA_DEFAULT_MODE;
427       }
428       /* Keep track of whether we will need to notify NFA_DM_SET_CONFIG_EVT on
429        * NFC_SET_CONFIG_REVT */
430 
431       /* Get the next available bit offset for this setconfig (based on how many
432        * SetConfigs are outstanding) */
433       cur_bit = (uint32_t)(1 << nfa_dm_cb.setcfg_pending_num);
434 
435       /* If setconfig is due to NFA_SetConfig: then set the bit
436        * (NFA_DM_SET_CONFIG_EVT needed on NFC_SET_CONFIG_REVT) */
437       if (app_init) {
438         nfa_dm_cb.setcfg_pending_mask |= cur_bit;
439       }
440       /* Otherwise setconfig is internal: clear the bit (NFA_DM_SET_CONFIG_EVT
441          not needed on NFC_SET_CONFIG_REVT) */
442       else {
443         nfa_dm_cb.setcfg_pending_mask &= ~cur_bit;
444       }
445 
446       /* Increment setcfg_pending counter */
447       nfa_dm_cb.setcfg_pending_num++;
448     }
449     if ((nfa_dm_cb.eDtaMode & NFA_DTA_HCEF_MODE) == NFA_DTA_HCEF_MODE) {
450       nfa_dm_cb.eDtaMode &= ~NFA_DTA_HCEF_MODE;
451     }
452     return (nfc_status);
453 
454   } else {
455     return NFA_STATUS_OK;
456   }
457 }
458 
459 /*******************************************************************************
460 **
461 ** Function         nfa_dm_nfc_revt_2_str
462 **
463 ** Description      convert nfc revt to string
464 **
465 *******************************************************************************/
nfa_dm_evt_2_str(uint16_t event)466 static std::string nfa_dm_evt_2_str(uint16_t event) {
467   switch (NFA_SYS_EVT_START(NFA_ID_DM) | event) {
468     case NFA_DM_API_ENABLE_EVT:
469       return "NFA_DM_API_ENABLE_EVT";
470     case NFA_DM_API_DISABLE_EVT:
471       return "NFA_DM_API_DISABLE_EVT";
472     case NFA_DM_API_SET_CONFIG_EVT:
473       return "NFA_DM_API_SET_CONFIG_EVT";
474     case NFA_DM_API_GET_CONFIG_EVT:
475       return "NFA_DM_API_GET_CONFIG_EVT";
476     case NFA_DM_API_REQUEST_EXCL_RF_CTRL_EVT:
477       return "NFA_DM_API_REQUEST_EXCL_RF_CTRL_EVT";
478     case NFA_DM_API_RELEASE_EXCL_RF_CTRL_EVT:
479       return "NFA_DM_API_RELEASE_EXCL_RF_CTRL_EVT";
480     case NFA_DM_API_ENABLE_POLLING_EVT:
481       return "NFA_DM_API_ENABLE_POLLING_EVT";
482     case NFA_DM_API_DISABLE_POLLING_EVT:
483       return "NFA_DM_API_DISABLE_POLLING_EVT";
484     case NFA_DM_API_ENABLE_LISTENING_EVT:
485       return "NFA_DM_API_ENABLE_LISTENING_EVT";
486     case NFA_DM_API_DISABLE_LISTENING_EVT:
487       return "NFA_DM_API_DISABLE_LISTENING_EVT";
488     case NFA_DM_API_PAUSE_P2P_EVT:
489       return "NFA_DM_API_PAUSE_P2P_EVT";
490     case NFA_DM_API_RESUME_P2P_EVT:
491       return "NFA_DM_API_RESUME_P2P_EVT";
492     case NFA_DM_API_RAW_FRAME_EVT:
493       return "NFA_DM_API_RAW_FRAME_EVT";
494     case NFA_DM_API_SET_P2P_LISTEN_TECH_EVT:
495       return "NFA_DM_API_SET_P2P_LISTEN_TECH_EVT";
496     case NFA_DM_API_START_RF_DISCOVERY_EVT:
497       return "NFA_DM_API_START_RF_DISCOVERY_EVT";
498     case NFA_DM_API_STOP_RF_DISCOVERY_EVT:
499       return "NFA_DM_API_STOP_RF_DISCOVERY_EVT";
500     case NFA_DM_API_SET_RF_DISC_DURATION_EVT:
501       return "NFA_DM_API_SET_RF_DISC_DURATION_EVT";
502     case NFA_DM_API_SELECT_EVT:
503       return "NFA_DM_API_SELECT_EVT";
504     case NFA_DM_API_UPDATE_RF_PARAMS_EVT:
505       return "NFA_DM_API_UPDATE_RF_PARAMS_EVT";
506     case NFA_DM_API_DEACTIVATE_EVT:
507       return "NFA_DM_API_DEACTIVATE_EVT";
508     case NFA_DM_API_POWER_OFF_SLEEP_EVT:
509       return "NFA_DM_API_POWER_OFF_SLEEP_EVT";
510     case NFA_DM_API_REG_NDEF_HDLR_EVT:
511       return "NFA_DM_API_REG_NDEF_HDLR_EVT";
512     case NFA_DM_API_DEREG_NDEF_HDLR_EVT:
513       return "NFA_DM_API_DEREG_NDEF_HDLR_EVT";
514     case NFA_DM_TIMEOUT_DISABLE_EVT:
515       return "NFA_DM_TIMEOUT_DISABLE_EVT";
516     case NFA_DM_API_SET_POWER_SUB_STATE_EVT:
517       return "NFA_DM_API_SET_POWER_SUB_STATE_EVT";
518   }
519 
520   return "Unknown or Vendor Specific";
521 }
522