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 *
22 *  This file contains functions that interface with the NFCEEs.
23 *
24 ******************************************************************************/
25#include <string.h>
26#include "gki.h"
27#include "nfc_target.h"
28#include "bt_types.h"
29
30#if (NFC_INCLUDED == TRUE)
31#include "nfc_api.h"
32#include "nfc_int.h"
33#include "nci_hmsgs.h"
34
35
36/*******************************************************************************
37**
38** Function         NFC_NfceeDiscover
39**
40** Description      This function is called to enable or disable NFCEE Discovery.
41**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
42**                  as NFC_NFCEE_DISCOVER_REVT.
43**                  The notification from NFCC is reported by tNFC_RESPONSE_CBACK
44**                  as NFC_NFCEE_INFO_REVT.
45**
46** Parameters       discover - 1 to enable discover, 0 to disable.
47**
48** Returns          tNFC_STATUS
49**
50*******************************************************************************/
51tNFC_STATUS NFC_NfceeDiscover (BOOLEAN discover)
52{
53    return nci_snd_nfcee_discover ((UINT8) (discover ? NCI_DISCOVER_ACTION_ENABLE : NCI_DISCOVER_ACTION_DISABLE));
54}
55
56/*******************************************************************************
57**
58** Function         NFC_NfceeModeSet
59**
60** Description      This function is called to activate or de-activate an NFCEE
61**                  connected to the NFCC.
62**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
63**                  as NFC_NFCEE_MODE_SET_REVT.
64**
65** Parameters       nfcee_id - the NFCEE to activate or de-activate.
66**                  mode - NFC_MODE_ACTIVATE to activate NFCEE,
67**                         NFC_MODE_DEACTIVATE to de-activate.
68**
69** Returns          tNFC_STATUS
70**
71*******************************************************************************/
72tNFC_STATUS NFC_NfceeModeSet (UINT8              nfcee_id,
73                              tNFC_NFCEE_MODE    mode)
74{
75    if (mode >= NCI_NUM_NFCEE_MODE)
76    {
77        NFC_TRACE_ERROR1 ("NFC_NfceeModeSet bad mode:%d", mode);
78        return NFC_STATUS_FAILED;
79    }
80
81    return nci_snd_nfcee_mode_set (nfcee_id, mode);
82}
83
84
85
86
87/*******************************************************************************
88**
89** Function         NFC_SetRouting
90**
91** Description      This function is called to configure the CE routing table.
92**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
93**                  as NFC_SET_ROUTING_REVT.
94**
95** Parameters
96**
97** Returns          tNFC_STATUS
98**
99*******************************************************************************/
100tNFC_STATUS NFC_SetRouting (BOOLEAN more,
101                             UINT8  num_tlv,
102                             UINT8  tlv_size,
103                             UINT8  *p_param_tlvs)
104{
105    return nci_snd_set_routing_cmd (more, num_tlv, tlv_size, p_param_tlvs);
106}
107
108/*******************************************************************************
109**
110** Function         NFC_GetRouting
111**
112** Description      This function is called to retrieve the CE routing table from
113**                  NFCC. The response from NFCC is reported by tNFC_RESPONSE_CBACK
114**                  as NFC_GET_ROUTING_REVT.
115**
116** Returns          tNFC_STATUS
117**
118*******************************************************************************/
119tNFC_STATUS NFC_GetRouting (void)
120{
121    return nci_snd_get_routing_cmd ();
122}
123
124
125#endif /* NFC_INCLUDED == TRUE */
126