nfc_test.c revision e9df6ba5a8fcccf306a80b1670b423be8fe7746a
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 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 "gki.h"
28#include "nfc_target.h"
29#include "bt_types.h"
30
31#if (NFC_INCLUDED == TRUE)
32#include "nfc_int.h"
33#include "nci_hmsgs.h"
34
35/****************************************************************************
36** Declarations
37****************************************************************************/
38
39/*******************************************************************************
40**
41** Function         NFC_TestLoopback
42**
43** Description      This function is called to send the given data packet
44**                  to NFCC for loopback test.
45**                  When loopback data is received from NFCC, tNFC_TEST_CBACK .
46**                  reports a NFC_LOOPBACK_TEVT.
47**
48** Parameters       p_data - the data packet
49**
50** Returns          tNFC_STATUS
51**
52*******************************************************************************/
53tNFC_STATUS NFC_TestLoopback (BT_HDR *p_data)
54{
55    tNFC_STATUS     status  = NFC_STATUS_FAILED;
56    tNFC_CONN_CB    *p_cb   = nfc_find_conn_cb_by_handle (NCI_TEST_ID);
57
58    if (p_data && p_cb && (p_data->offset >= (NCI_MSG_OFFSET_SIZE + NCI_DATA_HDR_SIZE)))
59    {
60        status = nfc_ncif_send_data (p_cb, p_data);
61    }
62
63    if (status != NFC_STATUS_OK)
64        GKI_freebuf (p_data);
65
66    return status;
67}
68
69
70
71
72#endif /* NFC_INCLUDED == TRUE */
73