1/******************************************************************************
2 *
3 *  Copyright (C) 2010-2012 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 P2P.
22 *
23 ******************************************************************************/
24#include <string.h>
25#include "nfc_api.h"
26#include "nfa_sys.h"
27#include "nfa_sys_int.h"
28#include "nfa_dm_int.h"
29#include "llcp_api.h"
30#include "llcp_defs.h"
31#include "nfa_p2p_api.h"
32#include "nfa_p2p_int.h"
33
34/*****************************************************************************
35**  Global Variables
36*****************************************************************************/
37
38/* system manager control block definition */
39#if NFA_DYNAMIC_MEMORY == FALSE
40tNFA_P2P_CB nfa_p2p_cb;
41#endif
42
43/*****************************************************************************
44**  Static Functions
45*****************************************************************************/
46
47/* event handler function type */
48static BOOLEAN nfa_p2p_evt_hdlr (BT_HDR *p_msg);
49
50/* disable function type */
51static void nfa_p2p_sys_disable (void);
52
53/* debug functions type */
54#if (BT_TRACE_VERBOSE == TRUE)
55static char *nfa_p2p_llcp_state_code (tNFA_P2P_LLCP_STATE state_code);
56#endif
57
58/*****************************************************************************
59**  Constants
60*****************************************************************************/
61static const tNFA_SYS_REG nfa_p2p_sys_reg =
62{
63    NULL,
64    nfa_p2p_evt_hdlr,
65    nfa_p2p_sys_disable,
66    NULL
67};
68
69#define NFA_P2P_NUM_ACTIONS  (NFA_P2P_LAST_EVT & 0x00ff)
70
71/* type for action functions */
72typedef BOOLEAN (*tNFA_P2P_ACTION) (tNFA_P2P_MSG *p_data);
73
74/* action function list */
75const tNFA_P2P_ACTION nfa_p2p_action[] =
76{
77    nfa_p2p_reg_server,                     /* NFA_P2P_API_REG_SERVER_EVT       */
78    nfa_p2p_reg_client,                     /* NFA_P2P_API_REG_CLIENT_EVT       */
79    nfa_p2p_dereg,                          /* NFA_P2P_API_DEREG_EVT            */
80    nfa_p2p_accept_connection,              /* NFA_P2P_API_ACCEPT_CONN_EVT      */
81    nfa_p2p_reject_connection,              /* NFA_P2P_API_REJECT_CONN_EVT      */
82    nfa_p2p_disconnect,                     /* NFA_P2P_API_DISCONNECT_EVT       */
83    nfa_p2p_create_data_link_connection,    /* NFA_P2P_API_CONNECT_EVT          */
84    nfa_p2p_send_ui,                        /* NFA_P2P_API_SEND_UI_EVT          */
85    nfa_p2p_send_data,                      /* NFA_P2P_API_SEND_DATA_EVT        */
86    nfa_p2p_set_local_busy,                 /* NFA_P2P_API_SET_LOCAL_BUSY_EVT   */
87    nfa_p2p_get_link_info,                  /* NFA_P2P_API_GET_LINK_INFO_EVT    */
88    nfa_p2p_get_remote_sap,                 /* NFA_P2P_API_GET_REMOTE_SAP_EVT   */
89    nfa_p2p_set_llcp_cfg                    /* NFA_P2P_API_SET_LLCP_CFG_EVT     */
90};
91
92/*******************************************************************************
93**
94** Function         nfa_p2p_discovery_cback
95**
96** Description      Processing event from discovery callback for listening
97**
98**
99** Returns          None
100**
101*******************************************************************************/
102void nfa_p2p_discovery_cback (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data)
103{
104    tNFA_CONN_EVT_DATA evt_data;
105
106    P2P_TRACE_DEBUG1 ("nfa_p2p_discovery_cback (): event:0x%02X", event);
107
108    switch (event)
109    {
110    case NFA_DM_RF_DISC_START_EVT:
111        if (p_data->status == NFC_STATUS_OK)
112        {
113            nfa_p2p_cb.llcp_state = NFA_P2P_LLCP_STATE_LISTENING;
114        }
115        break;
116
117    case NFA_DM_RF_DISC_ACTIVATED_EVT:
118
119        /* notify NFC link activation */
120        memcpy (&(evt_data.activated.activate_ntf),
121                &(p_data->activate),
122                sizeof (tNFC_ACTIVATE_DEVT));
123        nfa_dm_conn_cback_event_notify (NFA_ACTIVATED_EVT, &evt_data);
124
125        if ((p_data->activate.protocol        == NFC_PROTOCOL_NFC_DEP)
126          &&(p_data->activate.intf_param.type == NFC_INTERFACE_NFC_DEP))
127        {
128            nfa_p2p_activate_llcp (p_data);
129        }
130        break;
131
132    case NFA_DM_RF_DISC_DEACTIVATED_EVT:
133
134        /* notify deactivation */
135        if (  (p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP)
136            ||(p_data->deactivate.type == NFC_DEACTIVATE_TYPE_SLEEP_AF)  )
137        {
138            evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_SLEEP;
139        }
140        else
141        {
142            evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_IDLE;
143        }
144        nfa_dm_conn_cback_event_notify (NFA_DEACTIVATED_EVT, &evt_data);
145        break;
146
147    case NFA_DM_RF_DISC_CMD_IDLE_CMPL_EVT:
148        /* DH initiated deactivation in NFA_DM_RFST_LISTEN_SLEEP */
149        evt_data.deactivated.type = NFA_DEACTIVATE_TYPE_IDLE;
150        nfa_dm_conn_cback_event_notify (NFA_DEACTIVATED_EVT, &evt_data);
151        break;
152
153    default:
154        P2P_TRACE_ERROR0 ("Unexpected event");
155        break;
156    }
157}
158
159/*******************************************************************************
160**
161** Function         nfa_p2p_llcp_link_cback
162**
163** Description      Processing event from LLCP link management callback
164**
165**
166** Returns          None
167**
168*******************************************************************************/
169void nfa_p2p_llcp_link_cback (UINT8 event, UINT8 reason)
170{
171    tNFA_LLCP_ACTIVATED     llcp_activated;
172    tNFA_LLCP_DEACTIVATED   llcp_deactivated;
173
174    P2P_TRACE_DEBUG1 ("nfa_p2p_llcp_link_cback () event:0x%x", event);
175
176    if (event == LLCP_LINK_ACTIVATION_COMPLETE_EVT)
177    {
178        LLCP_GetLinkMIU (&nfa_p2p_cb.local_link_miu, &nfa_p2p_cb.remote_link_miu);
179        nfa_p2p_cb.llcp_state = NFA_P2P_LLCP_STATE_ACTIVATED;
180
181        if (nfa_p2p_cb.is_initiator)
182        {
183            /* notify NFA DM to send Activate Event to applicaiton with status  */
184            nfa_dm_notify_activation_status (NFA_STATUS_OK, NULL);
185        }
186
187        llcp_activated.is_initiator    = nfa_p2p_cb.is_initiator;
188        llcp_activated.local_link_miu  = nfa_p2p_cb.local_link_miu;
189        llcp_activated.remote_link_miu = nfa_p2p_cb.remote_link_miu;
190        llcp_activated.remote_lsc      = LLCP_GetRemoteLSC ();
191        llcp_activated.remote_wks      = LLCP_GetRemoteWKS ();
192
193        nfa_dm_act_conn_cback_notify (NFA_LLCP_ACTIVATED_EVT, (tNFA_CONN_EVT_DATA *) &llcp_activated);
194
195    }
196    else if (event == LLCP_LINK_ACTIVATION_FAILED_EVT)
197    {
198        nfa_p2p_cb.llcp_state = NFA_P2P_LLCP_STATE_IDLE;
199
200        if (nfa_p2p_cb.is_initiator)
201        {
202            /* notify NFA DM to send Activate Event to applicaiton with status  */
203            nfa_dm_notify_activation_status (NFA_STATUS_FAILED, NULL);
204        }
205
206        nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_DISCOVERY);
207    }
208    else /* LLCP_LINK_DEACTIVATED_EVT       */
209    {
210        nfa_p2p_cb.llcp_state = NFA_P2P_LLCP_STATE_IDLE;
211
212        llcp_deactivated.reason = reason;
213        nfa_dm_act_conn_cback_notify (NFA_LLCP_DEACTIVATED_EVT, (tNFA_CONN_EVT_DATA *)&llcp_deactivated);
214
215        if (  (nfa_p2p_cb.is_initiator)
216            &&(reason != LLCP_LINK_RF_LINK_LOSS_ERR)  ) /* if NFC link is still up */
217        {
218            nfa_dm_rf_deactivate (NFA_DEACTIVATE_TYPE_DISCOVERY);
219        }
220    }
221}
222
223/*******************************************************************************
224**
225** Function         nfa_p2p_activate_llcp
226**
227** Description      Activate LLCP link
228**
229**
230** Returns          None
231**
232*******************************************************************************/
233void nfa_p2p_activate_llcp (tNFC_DISCOVER *p_data)
234{
235    tLLCP_ACTIVATE_CONFIG config;
236
237    P2P_TRACE_DEBUG0 ("nfa_p2p_activate_llcp ()");
238
239    if (  (p_data->activate.rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_A)
240        ||(p_data->activate.rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_F)
241        ||(p_data->activate.rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_A_ACTIVE)
242        ||(p_data->activate.rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_F_ACTIVE)  )
243    {
244        config.is_initiator = TRUE;
245    }
246    else
247    {
248        config.is_initiator = FALSE;
249    }
250
251    nfa_p2p_cb.is_initiator = config.is_initiator;
252
253    config.max_payload_size = p_data->activate.intf_param.intf_param.pa_nfc.max_payload_size;
254    config.waiting_time     = p_data->activate.intf_param.intf_param.pa_nfc.waiting_time;
255    config.p_gen_bytes      = p_data->activate.intf_param.intf_param.pa_nfc.gen_bytes;
256    config.gen_bytes_len    = p_data->activate.intf_param.intf_param.pa_nfc.gen_bytes_len;
257
258    LLCP_ActivateLink (config, nfa_p2p_llcp_link_cback);
259}
260
261/*******************************************************************************
262**
263** Function         nfa_p2p_deactivate_llcp
264**
265** Description      Deactivate LLCP link
266**
267**
268** Returns          None
269**
270*******************************************************************************/
271void nfa_p2p_deactivate_llcp (void)
272{
273    P2P_TRACE_DEBUG0 ("nfa_p2p_deactivate_llcp ()");
274
275    LLCP_DeactivateLink ();
276}
277
278/*******************************************************************************
279**
280** Function         nfa_p2p_init
281**
282** Description      Initialize NFA P2P
283**
284**
285** Returns          None
286**
287*******************************************************************************/
288void nfa_p2p_init (void)
289{
290    UINT8 xx;
291
292    P2P_TRACE_DEBUG0 ("nfa_p2p_init ()");
293
294    /* initialize control block */
295    memset (&nfa_p2p_cb, 0, sizeof (tNFA_P2P_CB));
296    nfa_p2p_cb.dm_disc_handle = NFA_HANDLE_INVALID;
297    nfa_p2p_cb.trace_level    = APPL_INITIAL_TRACE_LEVEL;
298
299    for (xx = 0; xx < LLCP_MAX_SDP_TRANSAC; xx++)
300    {
301        nfa_p2p_cb.sdp_cb[xx].local_sap = LLCP_INVALID_SAP;
302    }
303
304    /* register message handler on NFA SYS */
305    nfa_sys_register (NFA_ID_P2P,  &nfa_p2p_sys_reg);
306}
307
308
309/*******************************************************************************
310**
311** Function         nfa_p2p_sys_disable
312**
313** Description      Deregister NFA P2P from NFA SYS/DM
314**
315**
316** Returns          None
317**
318*******************************************************************************/
319static void nfa_p2p_sys_disable (void)
320{
321    P2P_TRACE_DEBUG0 ("nfa_p2p_sys_disable()");
322
323    /* deregister message handler on NFA SYS */
324    nfa_sys_deregister (NFA_ID_P2P);
325}
326
327/*******************************************************************************
328**
329** Function         nfa_p2p_set_config
330**
331** Description      Set General bytes and WT parameters for LLCP
332**
333**
334** Returns          void
335**
336*******************************************************************************/
337void nfa_p2p_set_config (tNFA_DM_DISC_TECH_PROTO_MASK disc_mask)
338{
339    UINT8 wt, gen_bytes_len = LLCP_MAX_GEN_BYTES;
340    UINT8 params[LLCP_MAX_GEN_BYTES + 5], *p, length;
341
342    P2P_TRACE_DEBUG0 ("nfa_p2p_set_config ()");
343
344    LLCP_GetDiscoveryConfig (&wt, params + 2, &gen_bytes_len);
345
346    if (disc_mask & ( NFA_DM_DISC_MASK_PA_NFC_DEP
347                     |NFA_DM_DISC_MASK_PF_NFC_DEP
348                     |NFA_DM_DISC_MASK_PAA_NFC_DEP
349                     |NFA_DM_DISC_MASK_PFA_NFC_DEP) )
350    {
351        p = params;
352
353        UINT8_TO_BE_STREAM (p, NFC_PMID_ATR_REQ_GEN_BYTES);
354        UINT8_TO_BE_STREAM (p, gen_bytes_len);
355
356        p += gen_bytes_len;
357        length = gen_bytes_len + 2;
358
359        nfa_dm_check_set_config (length, params, FALSE);
360    }
361
362    if (disc_mask & ( NFA_DM_DISC_MASK_LA_NFC_DEP
363                     |NFA_DM_DISC_MASK_LF_NFC_DEP
364                     |NFA_DM_DISC_MASK_LAA_NFC_DEP
365                     |NFA_DM_DISC_MASK_LFA_NFC_DEP) )
366    {
367        p = params;
368
369        UINT8_TO_BE_STREAM (p, NFC_PMID_ATR_RES_GEN_BYTES);
370        UINT8_TO_BE_STREAM (p, gen_bytes_len);
371
372        p += gen_bytes_len;
373        length = gen_bytes_len + 2;
374
375        UINT8_TO_BE_STREAM (p, NFC_PMID_WT);
376        UINT8_TO_BE_STREAM (p, NCI_PARAM_LEN_WT);
377        UINT8_TO_BE_STREAM (p, wt);
378
379        length += 3;
380
381        nfa_dm_check_set_config (length, params, FALSE);
382    }
383}
384
385/*******************************************************************************
386**
387** Function         nfa_p2p_enable_listening
388**
389** Description      Configure listen technologies and protocols for LLCP
390**                  If LLCP WKS is changed then LLCP Gen bytes will be updated.
391**
392** Returns          void
393**
394*******************************************************************************/
395void nfa_p2p_enable_listening (tNFA_SYS_ID sys_id, BOOLEAN update_wks)
396{
397    tNFA_DM_DISC_TECH_PROTO_MASK p2p_listen_mask = 0;
398
399    P2P_TRACE_DEBUG2 ("nfa_p2p_enable_listening () sys_id = %d, update_wks = %d",
400                       sys_id, update_wks);
401
402    if (sys_id == NFA_ID_P2P)
403        nfa_p2p_cb.is_p2p_listening = TRUE;
404    else if (sys_id == NFA_ID_CHO)
405        nfa_p2p_cb.is_cho_listening = TRUE;
406    else if (sys_id == NFA_ID_SNEP)
407        nfa_p2p_cb.is_snep_listening = TRUE;
408
409    if (nfa_p2p_cb.dm_disc_handle != NFA_HANDLE_INVALID)
410    {
411        /* if need to update WKS in LLCP Gen bytes */
412        if (update_wks)
413        {
414            /* update LLCP Gen Bytes */
415            nfa_p2p_set_config (NFA_DM_DISC_MASK_PA_NFC_DEP|NFA_DM_DISC_MASK_LA_NFC_DEP);
416        }
417        return;
418    }
419
420    /* collect listen technologies with NFC-DEP protocol */
421    if (nfa_p2p_cb.listen_tech_mask & NFA_TECHNOLOGY_MASK_A)
422        p2p_listen_mask |= NFA_DM_DISC_MASK_LA_NFC_DEP;
423
424    if (nfa_p2p_cb.listen_tech_mask & NFA_TECHNOLOGY_MASK_F)
425        p2p_listen_mask |= NFA_DM_DISC_MASK_LF_NFC_DEP;
426
427    if (nfa_p2p_cb.listen_tech_mask & NFA_TECHNOLOGY_MASK_A_ACTIVE)
428        p2p_listen_mask |= NFA_DM_DISC_MASK_LAA_NFC_DEP;
429
430    if (nfa_p2p_cb.listen_tech_mask & NFA_TECHNOLOGY_MASK_F_ACTIVE)
431        p2p_listen_mask |= NFA_DM_DISC_MASK_LFA_NFC_DEP;
432
433    if (p2p_listen_mask)
434    {
435        /* Configure listen technologies and protocols and register callback to NFA DM discovery */
436        nfa_p2p_cb.dm_disc_handle = nfa_dm_add_rf_discover (p2p_listen_mask,
437                                                            NFA_DM_DISC_HOST_ID_DH,
438                                                            nfa_p2p_discovery_cback);
439    }
440}
441
442/*******************************************************************************
443**
444** Function         nfa_p2p_disable_listening
445**
446** Description      Remove listen technologies and protocols for LLCP and
447**                  deregister callback from NFA DM discovery if all of P2P/CHO/SNEP
448**                  doesn't listen LLCP any more.
449**                  If LLCP WKS is changed then ATR_RES will be updated.
450**
451** Returns          void
452**
453*******************************************************************************/
454void nfa_p2p_disable_listening (tNFA_SYS_ID sys_id, BOOLEAN update_wks)
455{
456
457    P2P_TRACE_DEBUG2 ("nfa_p2p_disable_listening ()  sys_id = %d, update_wks = %d",
458                       sys_id, update_wks);
459
460    if (sys_id == NFA_ID_P2P)
461        nfa_p2p_cb.is_p2p_listening = FALSE;
462    else if (sys_id == NFA_ID_CHO)
463        nfa_p2p_cb.is_cho_listening = FALSE;
464    else if (sys_id == NFA_ID_SNEP)
465        nfa_p2p_cb.is_snep_listening = FALSE;
466
467    if (nfa_p2p_cb.dm_disc_handle != NFA_HANDLE_INVALID)
468    {
469        if (  (nfa_p2p_cb.is_p2p_listening == FALSE)
470            &&(nfa_p2p_cb.is_cho_listening == FALSE)
471            &&(nfa_p2p_cb.is_snep_listening == FALSE)  )
472        {
473            nfa_p2p_cb.llcp_state = NFA_P2P_LLCP_STATE_IDLE;
474
475            nfa_dm_delete_rf_discover (nfa_p2p_cb.dm_disc_handle);
476            nfa_p2p_cb.dm_disc_handle = NFA_HANDLE_INVALID;
477        }
478        else if (update_wks)
479        {
480            /* update LLCP Gen Bytes */
481            nfa_p2p_set_config (NFA_DM_DISC_MASK_PA_NFC_DEP|NFA_DM_DISC_MASK_LA_NFC_DEP);
482        }
483    }
484}
485
486/*******************************************************************************
487**
488** Function         nfa_p2p_update_listen_tech
489**
490** Description      Update P2P listen technologies. If there is change then
491**                  restart or stop P2P listen.
492**
493** Returns          void
494**
495*******************************************************************************/
496void nfa_p2p_update_listen_tech (tNFA_TECHNOLOGY_MASK tech_mask)
497{
498    P2P_TRACE_DEBUG1 ("nfa_p2p_update_listen_tech ()  tech_mask = %d", tech_mask);
499
500    if (nfa_p2p_cb.listen_tech_mask != tech_mask)
501    {
502        nfa_p2p_cb.listen_tech_mask = tech_mask;
503
504        if (nfa_p2p_cb.dm_disc_handle != NFA_HANDLE_INVALID)
505        {
506            nfa_dm_delete_rf_discover (nfa_p2p_cb.dm_disc_handle);
507            nfa_p2p_cb.dm_disc_handle = NFA_HANDLE_INVALID;
508        }
509
510        /* restart discovery without updating sub-module status */
511        if (nfa_p2p_cb.is_p2p_listening)
512            nfa_p2p_enable_listening (NFA_ID_P2P, FALSE);
513        else if (nfa_p2p_cb.is_cho_listening)
514            nfa_p2p_enable_listening (NFA_ID_CHO, FALSE);
515        else if (nfa_p2p_cb.is_snep_listening)
516            nfa_p2p_enable_listening (NFA_ID_SNEP, FALSE);
517    }
518}
519
520/*******************************************************************************
521**
522** Function         nfa_p2p_evt_hdlr
523**
524** Description      Processing event for NFA P2P
525**
526**
527** Returns          TRUE if p_msg needs to be deallocated
528**
529*******************************************************************************/
530static BOOLEAN nfa_p2p_evt_hdlr (BT_HDR *p_hdr)
531{
532    BOOLEAN delete_msg = TRUE;
533    UINT16  event;
534
535    tNFA_P2P_MSG *p_msg = (tNFA_P2P_MSG *)p_hdr;
536
537#if (BT_TRACE_VERBOSE == TRUE)
538    P2P_TRACE_DEBUG2 ("nfa_p2p_evt_hdlr (): LLCP State [%s], Event [%s]",
539                       nfa_p2p_llcp_state_code (nfa_p2p_cb.llcp_state),
540                       nfa_p2p_evt_code (p_msg->hdr.event));
541#else
542    P2P_TRACE_DEBUG2 ("nfa_p2p_evt_hdlr (): State 0x%02x, Event 0x%02x",
543                       nfa_p2p_cb.llcp_state, p_msg->hdr.event);
544#endif
545
546    event = p_msg->hdr.event & 0x00ff;
547
548    /* execute action functions */
549    if (event < NFA_P2P_NUM_ACTIONS)
550    {
551        delete_msg = (*nfa_p2p_action[event]) (p_msg);
552    }
553    else
554    {
555        P2P_TRACE_ERROR0 ("Unhandled event");
556    }
557
558    return delete_msg;
559}
560
561
562#if (BT_TRACE_VERBOSE == TRUE)
563/*******************************************************************************
564**
565** Function         nfa_p2p_llcp_state_code
566**
567** Description
568**
569** Returns          string of state
570**
571*******************************************************************************/
572static char *nfa_p2p_llcp_state_code (tNFA_P2P_LLCP_STATE state_code)
573{
574    switch (state_code)
575    {
576    case NFA_P2P_LLCP_STATE_IDLE:
577        return "Link IDLE";
578    case NFA_P2P_LLCP_STATE_LISTENING:
579        return "Link LISTENING";
580    case NFA_P2P_LLCP_STATE_ACTIVATED:
581        return "Link ACTIVATED";
582    default:
583        return "Unknown state";
584    }
585}
586
587/*******************************************************************************
588**
589** Function         nfa_p2p_evt_code
590**
591** Description
592**
593** Returns          string of event
594**
595*******************************************************************************/
596char *nfa_p2p_evt_code (UINT16 evt_code)
597{
598    switch (evt_code)
599    {
600    case NFA_P2P_API_REG_SERVER_EVT:
601        return "API_REG_SERVER";
602    case NFA_P2P_API_REG_CLIENT_EVT:
603        return "API_REG_CLIENT";
604    case NFA_P2P_API_DEREG_EVT:
605        return "API_DEREG";
606    case NFA_P2P_API_ACCEPT_CONN_EVT:
607        return "API_ACCEPT_CONN";
608    case NFA_P2P_API_REJECT_CONN_EVT:
609        return "API_REJECT_CONN";
610    case NFA_P2P_API_DISCONNECT_EVT:
611        return "API_DISCONNECT";
612    case NFA_P2P_API_CONNECT_EVT:
613        return "API_CONNECT";
614    case NFA_P2P_API_SEND_UI_EVT:
615        return "API_SEND_UI";
616    case NFA_P2P_API_SEND_DATA_EVT:
617        return "API_SEND_DATA";
618    case NFA_P2P_API_SET_LOCAL_BUSY_EVT:
619        return "API_SET_LOCAL_BUSY";
620    case NFA_P2P_API_GET_LINK_INFO_EVT:
621        return "API_GET_LINK_INFO";
622    case NFA_P2P_API_GET_REMOTE_SAP_EVT:
623        return "API_GET_REMOTE_SAP";
624    case NFA_P2P_API_SET_LLCP_CFG_EVT:
625        return "API_SET_LLCP_CFG_EVT";
626    default:
627        return "Unknown event";
628    }
629}
630#endif  /* Debug Functions */
631