• 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 file contains functions that interface with the NFC NCI transport.
22  *  On the receive side, it routes events to the appropriate handler
23  *  (callback). On the transmit side, it manages the command transmission.
24  *
25  ******************************************************************************/
26 #include <string.h>
27 #include "bt_types.h"
28 #include "gki.h"
29 #include "nfc_target.h"
30 
31 #include "nci_hmsgs.h"
32 #include "nfc_int.h"
33 
34 /****************************************************************************
35 ** Declarations
36 ****************************************************************************/
37 
38 /*******************************************************************************
39 **
40 ** Function         NFC_TestLoopback
41 **
42 ** Description      This function is called to send the given data packet
43 **                  to NFCC for loopback test.
44 **                  When loopback data is received from NFCC, tNFC_TEST_CBACK .
45 **                  reports a NFC_LOOPBACK_TEVT.
46 **
47 ** Parameters       p_data - the data packet
48 **
49 ** Returns          tNFC_STATUS
50 **
51 *******************************************************************************/
NFC_TestLoopback(NFC_HDR * p_data)52 tNFC_STATUS NFC_TestLoopback(NFC_HDR* p_data) {
53   tNFC_STATUS status = NFC_STATUS_FAILED;
54   tNFC_CONN_CB* p_cb = nfc_find_conn_cb_by_handle(NCI_TEST_ID);
55 
56   if (p_data && p_cb &&
57       (p_data->offset >= (NCI_MSG_OFFSET_SIZE + NCI_DATA_HDR_SIZE))) {
58     status = nfc_ncif_send_data(p_cb, p_data);
59   }
60 
61   if (status != NFC_STATUS_OK) GKI_freebuf(p_data);
62 
63   return status;
64 }
65