nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 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 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 19 | /****************************************************************************** |
| 20 | * |
| 21 | * This is the private interface file for the NFA SNEP. |
| 22 | * |
| 23 | ******************************************************************************/ |
| 24 | #ifndef NFA_SNEP_INT_H |
| 25 | #define NFA_SNEP_INT_H |
| 26 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 27 | #if (NFA_SNEP_INCLUDED == TRUE) |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 28 | #include "llcp_api.h" |
| 29 | #include "nfa_snep_api.h" |
| 30 | |
| 31 | /***************************************************************************** |
| 32 | ** Constants and data types |
| 33 | *****************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 34 | /* SNEP Acceptable Length size */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 35 | |
| 36 | /* NFA SNEP events */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 37 | enum { |
| 38 | NFA_SNEP_API_START_DEFAULT_SERVER_EVT = NFA_SYS_EVT_START(NFA_ID_SNEP), |
| 39 | NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT, |
| 40 | NFA_SNEP_API_REG_SERVER_EVT, |
| 41 | NFA_SNEP_API_REG_CLIENT_EVT, |
| 42 | NFA_SNEP_API_DEREG_EVT, |
| 43 | NFA_SNEP_API_CONNECT_EVT, |
| 44 | NFA_SNEP_API_GET_REQ_EVT, |
| 45 | NFA_SNEP_API_PUT_REQ_EVT, |
| 46 | NFA_SNEP_API_GET_RESP_EVT, |
| 47 | NFA_SNEP_API_PUT_RESP_EVT, |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 48 | NFA_SNEP_API_DISCONNECT_EVT |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 49 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | /* data type for NFA_SNEP_API_START_DEFAULT_SERVER_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 53 | typedef struct { |
| 54 | NFC_HDR hdr; |
| 55 | tNFA_SNEP_CBACK* p_cback; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 56 | } tNFA_SNEP_API_START_DEFAULT_SERVER; |
| 57 | |
| 58 | /* data type for NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 59 | typedef struct { |
| 60 | NFC_HDR hdr; |
| 61 | tNFA_SNEP_CBACK* p_cback; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 62 | } tNFA_SNEP_API_STOP_DEFAULT_SERVER; |
| 63 | |
| 64 | /* data type for NFA_SNEP_API_REG_SERVER_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 65 | typedef struct { |
| 66 | NFC_HDR hdr; |
| 67 | uint8_t server_sap; |
| 68 | char service_name[LLCP_MAX_SN_LEN + 1]; |
| 69 | tNFA_SNEP_CBACK* p_cback; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 70 | } tNFA_SNEP_API_REG_SERVER; |
| 71 | |
| 72 | /* data type for NFA_SNEP_API_REG_CLIENT_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 73 | typedef struct { |
| 74 | NFC_HDR hdr; |
| 75 | tNFA_SNEP_CBACK* p_cback; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 76 | } tNFA_SNEP_API_REG_CLIENT; |
| 77 | |
| 78 | /* data type for NFA_SNEP_API_DEREG_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 79 | typedef struct { |
| 80 | NFC_HDR hdr; |
| 81 | tNFA_HANDLE reg_handle; /* handle for registered server/client */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 82 | } tNFA_SNEP_API_DEREG; |
| 83 | |
| 84 | /* data type for NFA_SNEP_API_CONNECT_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 85 | typedef struct { |
| 86 | NFC_HDR hdr; |
| 87 | tNFA_HANDLE client_handle; /* handle for client */ |
| 88 | char service_name[LLCP_MAX_SN_LEN + 1]; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 89 | } tNFA_SNEP_API_CONNECT; |
| 90 | |
| 91 | /* data type for NFA_SNEP_API_GET_REQ_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 92 | typedef struct { |
| 93 | NFC_HDR hdr; |
| 94 | tNFA_HANDLE conn_handle; /* handle for data link connection */ |
| 95 | uint32_t buff_length; /* length of buffer; acceptable length */ |
| 96 | uint32_t ndef_length; /* length of current NDEF message */ |
| 97 | uint8_t* p_ndef_buff; /* buffer for NDEF message */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 98 | } tNFA_SNEP_API_GET_REQ; |
| 99 | |
| 100 | /* data type for NFA_SNEP_API_PUT_REQ_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 101 | typedef struct { |
| 102 | NFC_HDR hdr; |
| 103 | tNFA_HANDLE conn_handle; /* handle for data link connection */ |
| 104 | uint32_t ndef_length; /* length of NDEF message */ |
| 105 | uint8_t* p_ndef_buff; /* buffer for NDEF message */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 106 | } tNFA_SNEP_API_PUT_REQ; |
| 107 | |
| 108 | /* data type for NFA_SNEP_API_GET_RESP_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 109 | typedef struct { |
| 110 | NFC_HDR hdr; |
| 111 | tNFA_HANDLE conn_handle; /* handle for data link connection */ |
| 112 | tNFA_SNEP_RESP_CODE resp_code; /* response code */ |
| 113 | uint32_t ndef_length; /* length of NDEF message */ |
| 114 | uint8_t* p_ndef_buff; /* buffer for NDEF message */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 115 | } tNFA_SNEP_API_GET_RESP; |
| 116 | |
| 117 | /* data type for NFA_SNEP_API_PUT_RESP_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 118 | typedef struct { |
| 119 | NFC_HDR hdr; |
| 120 | tNFA_HANDLE conn_handle; /* handle for data link connection */ |
| 121 | tNFA_SNEP_RESP_CODE resp_code; /* response code */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 122 | } tNFA_SNEP_API_PUT_RESP; |
| 123 | |
| 124 | /* data type for NFA_SNEP_API_DISCONNECT_EVT */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 125 | typedef struct { |
| 126 | NFC_HDR hdr; |
| 127 | tNFA_HANDLE conn_handle; /* response code */ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 128 | bool flush; /* TRUE if discard pending data */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 129 | } tNFA_SNEP_API_DISCONNECT; |
| 130 | |
| 131 | /* union of all event data types */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 132 | typedef union { |
| 133 | NFC_HDR hdr; |
| 134 | tNFA_SNEP_API_START_DEFAULT_SERVER |
| 135 | api_start_default_server; /* NFA_SNEP_API_START_DEFAULT_SERVER_EVT */ |
| 136 | tNFA_SNEP_API_STOP_DEFAULT_SERVER |
| 137 | api_stop_default_server; /* NFA_SNEP_API_STOP_DEFAULT_SERVER_EVT */ |
| 138 | tNFA_SNEP_API_REG_SERVER api_reg_server; /* NFA_SNEP_API_REG_SERVER_EVT */ |
| 139 | tNFA_SNEP_API_REG_CLIENT api_reg_client; /* NFA_SNEP_API_REG_CLIENT_EVT */ |
| 140 | tNFA_SNEP_API_DEREG api_dereg; /* NFA_SNEP_API_DEREG_EVT */ |
| 141 | tNFA_SNEP_API_CONNECT api_connect; /* NFA_SNEP_API_CONNECT_EVT */ |
| 142 | tNFA_SNEP_API_GET_REQ api_get_req; /* NFA_SNEP_API_GET_REQ_EVT */ |
| 143 | tNFA_SNEP_API_PUT_REQ api_put_req; /* NFA_SNEP_API_PUT_REQ_EVT */ |
| 144 | tNFA_SNEP_API_GET_RESP api_get_resp; /* NFA_SNEP_API_GET_RESP_EVT */ |
| 145 | tNFA_SNEP_API_PUT_RESP api_put_resp; /* NFA_SNEP_API_PUT_RESP_EVT */ |
| 146 | tNFA_SNEP_API_DISCONNECT api_disc; /* NFA_SNEP_API_DISCONNECT_EVT */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 147 | } tNFA_SNEP_MSG; |
| 148 | |
| 149 | /***************************************************************************** |
| 150 | ** control block |
| 151 | *****************************************************************************/ |
| 152 | |
| 153 | /* NFA SNEP service control block */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 154 | /* ignore flags while searching */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 155 | /* waiting for connection confirm */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 156 | /* data link connected */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 157 | /* Waiting for continue response */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 158 | /* Waiting for continue request */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 159 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 160 | typedef struct { |
| 161 | uint8_t local_sap; /* local SAP of service */ |
| 162 | uint8_t remote_sap; /* local SAP of service */ |
| 163 | uint8_t flags; /* internal flags */ |
| 164 | tNFA_SNEP_CBACK* p_cback; /* callback for event */ |
| 165 | TIMER_LIST_ENT timer; /* timer for client */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 166 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 167 | uint16_t tx_miu; /* adjusted MIU for throughput */ |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 168 | bool congest; /* TRUE if data link connection is congested */ |
| 169 | bool rx_fragments; /* TRUE if waiting more fragments */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 170 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 171 | uint8_t tx_code; /* transmitted code in request/response */ |
| 172 | uint8_t rx_code; /* received code in request/response */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 173 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 174 | uint32_t acceptable_length; |
| 175 | uint32_t buff_length; /* size of buffer for NDEF message */ |
| 176 | uint32_t ndef_length; /* length of NDEF message */ |
| 177 | uint32_t cur_length; /* currently sent or received length */ |
| 178 | uint8_t* p_ndef_buff; /* NDEF message buffer */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 179 | } tNFA_SNEP_CONN; |
| 180 | |
| 181 | /* |
| 182 | ** NFA SNEP control block |
| 183 | */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 184 | typedef struct { |
| 185 | tNFA_SNEP_CONN conn[NFA_SNEP_MAX_CONN]; |
| 186 | bool listen_enabled; |
| 187 | bool is_dta_mode; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 188 | } tNFA_SNEP_CB; |
| 189 | |
| 190 | /* |
| 191 | ** NFA SNEP default server control block |
| 192 | */ |
| 193 | |
| 194 | /* multiple data link connections for default server */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 195 | typedef struct { |
| 196 | tNFA_HANDLE conn_handle; /* connection handle for default server */ |
| 197 | uint8_t* p_rx_ndef; /* buffer to receive NDEF */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 198 | } tNFA_SNEP_DEFAULT_CONN; |
| 199 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 200 | #define NFA_SNEP_DEFAULT_MAX_CONN 3 |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 201 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 202 | typedef struct { |
| 203 | tNFA_HANDLE server_handle; /* registered handle for default server */ |
| 204 | tNFA_SNEP_DEFAULT_CONN |
| 205 | conn[NFA_SNEP_DEFAULT_MAX_CONN]; /* connections for default server */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 206 | |
| 207 | } tNFA_SNEP_DEFAULT_CB; |
| 208 | |
| 209 | /***************************************************************************** |
| 210 | ** External variables |
| 211 | *****************************************************************************/ |
| 212 | |
| 213 | /* NFA SNEP control block */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 214 | extern tNFA_SNEP_CB nfa_snep_cb; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 215 | |
| 216 | /* NFA SNEP default server control block */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 217 | extern tNFA_SNEP_DEFAULT_CB nfa_snep_default_cb; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 218 | |
| 219 | /***************************************************************************** |
| 220 | ** External functions |
| 221 | *****************************************************************************/ |
| 222 | /* |
| 223 | ** nfa_snep_main.c |
| 224 | */ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 225 | void nfa_snep_init(bool is_dta_mode); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 226 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 227 | #endif /* (NFA_SNEP_INCLUDED == TRUE) */ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 228 | #endif /* NFA_SNEP_INT_H */ |