merge with master
[adaptation/devices/nfc-plugin-nxp.git] / src / phFriNfc_LlcpTransport.h
1 /*\r
2  * Copyright (C) 2010 NXP Semiconductors\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 /**\r
18  * \file  phFriNfc_LlcpTransport.h\r
19  * \brief \r
20  *\r
21  * Project: NFC-FRI\r
22  *\r
23  */       \r
24  \r
25 #ifndef PHFRINFC_LLCP_TRANSPORT_H\r
26 #define PHFRINFC_LLCP_TRANSPORT_H\r
27 #include <phNfcHalTypes.h>\r
28 #include <phNfcLlcpTypes.h>\r
29 #include <phNfcTypes.h>\r
30 #include <phLibNfcStatus.h>\r
31 #include <phFriNfc_Llcp.h>\r
32 #include <phFriNfc_LlcpUtils.h>\r
33 #ifdef ANDROID\r
34 #include <string.h>\r
35 #endif\r
36 \r
37 \r
38 typedef uint32_t    phFriNfc_Socket_Handle;\r
39 \r
40 /**\r
41  * \ingroup grp_fri_nfc_llcp_mac\r
42  * \brief Declaration of a TRANSPORT type\r
43  */\r
44 struct phFriNfc_LlcpTransport;\r
45 typedef struct phFriNfc_LlcpTransport phFriNfc_LlcpTransport_t;\r
46 \r
47 struct phFriNfc_LlcpTransport_Socket;\r
48 typedef struct phFriNfc_LlcpTransport_Socket phFriNfc_LlcpTransport_Socket_t;\r
49 \r
50 /*========== ENUMERATES ===========*/\r
51 \r
52 /* Enum reperesents the different LLCP Link status*/\r
53 typedef enum phFriNfc_LlcpTransportSocket_eSocketState\r
54 {\r
55    phFriNfc_LlcpTransportSocket_eSocketDefault,\r
56    phFriNfc_LlcpTransportSocket_eSocketCreated,\r
57    phFriNfc_LlcpTransportSocket_eSocketBound,\r
58    phFriNfc_LlcpTransportSocket_eSocketRegistered,\r
59    phFriNfc_LlcpTransportSocket_eSocketConnected,\r
60    phFriNfc_LlcpTransportSocket_eSocketConnecting,\r
61    phFriNfc_LlcpTransportSocket_eSocketAccepted,\r
62    phFriNfc_LlcpTransportSocket_eSocketDisconnected,\r
63    phFriNfc_LlcpTransportSocket_eSocketDisconnecting,\r
64    phFriNfc_LlcpTransportSocket_eSocketRejected,\r
65 }phFriNfc_LlcpTransportSocket_eSocketState_t;\r
66 \r
67 \r
68 \r
69 /*========== CALLBACKS ===========*/\r
70 \r
71 /**\r
72 *\ingroup grp_fri_nfc\r
73 *\r
74 * \brief LLCP socket error notification callback definition\r
75 */\r
76 typedef void (*pphFriNfc_LlcpTransportSocketErrCb_t) ( void*      pContext,\r
77                                                        uint8_t    nErrCode);\r
78 \r
79 \r
80 /**\r
81 *\ingroup grp_fri_nfc\r
82 *\r
83 * \brief LLCP socket listen callback definition\r
84 */\r
85 typedef void (*pphFriNfc_LlcpTransportSocketListenCb_t) (void*                            pContext,\r
86                                                          phFriNfc_LlcpTransport_Socket_t  *IncomingSocket);\r
87 \r
88 /**\r
89 *\ingroup grp_fri_nfc\r
90 *\r
91 * \brief LLCP socket connect callback definition\r
92 */\r
93 typedef void (*pphFriNfc_LlcpTransportSocketConnectCb_t)  ( void*        pContext,\r
94                                                             uint8_t      nErrCode,\r
95                                                             NFCSTATUS    status);\r
96 \r
97 /**\r
98 *\ingroup grp_fri_nfc\r
99 *\r
100 * \brief LLCP socket disconnect callback definition\r
101 */\r
102 typedef void (*pphFriNfc_LlcpTransportSocketDisconnectCb_t) (void*        pContext,\r
103                                                              NFCSTATUS    status);\r
104 \r
105 /**\r
106 *\ingroup grp_fri_nfc\r
107 *\r
108 * \brief LLCP socket accept callback definition\r
109 */\r
110 typedef void (*pphFriNfc_LlcpTransportSocketAcceptCb_t) (void*        pContext,\r
111                                                          NFCSTATUS    status);\r
112 \r
113 /**\r
114 *\ingroup grp_fri_nfc\r
115 *\r
116 * \brief LLCP socket reject callback definition\r
117 */\r
118 typedef void (*pphFriNfc_LlcpTransportSocketRejectCb_t) (void*        pContext,\r
119                                                          NFCSTATUS    status);\r
120 \r
121 /**\r
122 *\ingroup grp_fri_nfc\r
123 *\r
124 * \brief LLCP socket reception callback definition\r
125 */\r
126 typedef void (*pphFriNfc_LlcpTransportSocketRecvCb_t) (void*     pContext,\r
127                                                        NFCSTATUS status);\r
128 \r
129 /**\r
130 *\ingroup grp_fri_nfc\r
131 *\r
132 * \brief LLCP socket reception with SSAP callback definition\r
133 */\r
134 typedef void (*pphFriNfc_LlcpTransportSocketRecvFromCb_t) (void*       pContext,\r
135                                                            uint8_t     ssap,\r
136                                                            NFCSTATUS   status);\r
137 \r
138 /**\r
139 *\ingroup grp_fri_nfc\r
140 *\r
141 * \brief LLCP socket emission callback definition\r
142 */\r
143 typedef void (*pphFriNfc_LlcpTransportSocketSendCb_t) (void*        pContext,\r
144                                                        NFCSTATUS    status);\r
145 \r
146 \r
147 /*========== STRUCTURES ===========*/\r
148 /**\r
149  * \ingroup grp_fri_nfc_llcp_mac\r
150  * \brief Declaration of a SOCKET type\r
151  */\r
152 struct phFriNfc_LlcpTransport_Socket \r
153 {\r
154    phFriNfc_LlcpTransportSocket_eSocketState_t    eSocket_State;\r
155    phFriNfc_LlcpTransport_eSocketType_t           eSocket_Type;\r
156    phFriNfc_LlcpTransport_sSocketOptions_t        sSocketOption;\r
157    pphFriNfc_LlcpTransportSocketErrCb_t           pSocketErrCb;\r
158 \r
159    /* Remote and local socket info */\r
160    uint8_t                                        socket_sSap;\r
161    uint8_t                                        socket_dSap;\r
162    // TODO: copy service name (could be deallocated by upper layer)\r
163    phNfc_sData_t                                  sServiceName;\r
164    uint8_t                                        remoteRW;\r
165    uint8_t                                        localRW;\r
166    uint16_t                                       remoteMIU;\r
167    uint16_t                                       localMIUX;\r
168    uint8_t                                        index;\r
169 \r
170    /* Information Flags */\r
171    bool_t                                        bSocketRecvPending;\r
172    bool_t                                        bSocketSendPending;\r
173    bool_t                                        bSocketListenPending;\r
174    bool_t                                        bSocketDiscPending;\r
175    bool_t                                        bSocketConnectPending;\r
176    bool_t                                        bSocketAcceptPending;\r
177    bool_t                                        bSocketRRPending;\r
178    bool_t                                        bSocketRNRPending;\r
179 \r
180    /* Buffers */\r
181    phNfc_sData_t                                  sSocketSendBuffer;\r
182    phNfc_sData_t                                  sSocketLinearBuffer;\r
183    phNfc_sData_t*                                 sSocketRecvBuffer;\r
184    uint32_t                                       *receivedLength;\r
185    uint32_t                                       bufferLinearLength;\r
186    uint32_t                                       bufferSendMaxLength;\r
187    uint32_t                                       bufferRwMaxLength;\r
188    bool_t                                         ReceiverBusyCondition;\r
189    bool_t                                         RemoteBusyConditionInfo;\r
190    UTIL_FIFO_BUFFER                               sCyclicFifoBuffer;\r
191    uint32_t                                       indexRwRead;\r
192    uint32_t                                       indexRwWrite;\r
193 \r
194    /* Construction Frame */\r
195    phFriNfc_Llcp_sPacketHeader_t                  sLlcpHeader;\r
196    phFriNfc_Llcp_sPacketSequence_t                sSequence;\r
197    uint8_t                                        socket_VS;\r
198    uint8_t                                        socket_VSA;\r
199    uint8_t                                        socket_VR;\r
200    uint8_t                                        socket_VRA;\r
201 \r
202    /* Callbacks */\r
203    pphFriNfc_LlcpTransportSocketAcceptCb_t        pfSocketAccept_Cb;\r
204    pphFriNfc_LlcpTransportSocketSendCb_t          pfSocketSend_Cb;\r
205    pphFriNfc_LlcpTransportSocketRecvFromCb_t      pfSocketRecvFrom_Cb;\r
206    pphFriNfc_LlcpTransportSocketRecvCb_t          pfSocketRecv_Cb;\r
207    pphFriNfc_LlcpTransportSocketListenCb_t        pfSocketListen_Cb;\r
208    pphFriNfc_LlcpTransportSocketConnectCb_t       pfSocketConnect_Cb;\r
209    pphFriNfc_LlcpTransportSocketDisconnectCb_t    pfSocketDisconnect_Cb;\r
210 \r
211    /* Table of PHFRINFC_LLCP_RW_MAX Receive Windows Buffers */\r
212    phNfc_sData_t                                  sSocketRwBufferTable[PHFRINFC_LLCP_RW_MAX];\r
213 \r
214    /* Pointer a the socket table */\r
215    phFriNfc_LlcpTransport_t                       *psTransport;\r
216    /* Context */\r
217    void                                          *pListenContext;\r
218    void                                          *pAcceptContext;\r
219    void                                          *pRejectContext;\r
220    void                                          *pConnectContext;\r
221    void                                          *pDisonnectContext;\r
222    void                                          *pSendContext;\r
223    void                                          *pRecvContext;\r
224    void                                          *pContext;\r
225 };\r
226 \r
227 /**\r
228  * \ingroup grp_fri_nfc_llcp_mac\r
229  * \brief Declaration of a TRANSPORT Type with a table of PHFRINFC_LLCP_NB_SOCKET_DEFAULT sockets\r
230  *        and a pointer a Llcp layer\r
231  */\r
232 struct phFriNfc_LlcpTransport \r
233 {\r
234    phFriNfc_LlcpTransport_Socket_t       pSocketTable[PHFRINFC_LLCP_NB_SOCKET_MAX];\r
235    phFriNfc_Llcp_t                       *pLlcp;\r
236    bool_t                                bSendPending;\r
237    bool_t                                bRecvPending;\r
238    bool_t                                bDmPending;\r
239    bool_t                                bFrmrPending;\r
240 \r
241    uint8_t                               socketIndex;\r
242 \r
243    /**< Info field of pending FRMR packet*/\r
244    uint8_t                               FrmrInfoBuffer[4];\r
245    phFriNfc_Llcp_sPacketHeader_t         sLlcpHeader;\r
246    phFriNfc_Llcp_sPacketSequence_t       sSequence;\r
247 \r
248   /**< Info field of pending DM packet*/\r
249    phFriNfc_Llcp_sPacketHeader_t         sDmHeader;\r
250    phNfc_sData_t                         sDmPayload;\r
251    uint8_t                               DmInfoBuffer[3];\r
252 \r
253    uint8_t                               LinkStatusError;\r
254 };\r
255 \r
256 /*\r
257 ################################################################################\r
258 ********************** TRANSPORT Interface Function Prototype  *****************\r
259 ################################################################################\r
260 */\r
261 \r
262  /**\r
263 * \ingroup grp_fri_nfc\r
264 * \brief <b>Create a socket on a LLCP-connected device</b>.\r
265 *\r
266 */\r
267 NFCSTATUS phFriNfc_LlcpTransport_Reset (phFriNfc_LlcpTransport_t      *pLlcpSocketTable,\r
268                                         phFriNfc_Llcp_t               *pLlcp);\r
269 \r
270 \r
271 /**\r
272 * \ingroup grp_fri_nfc\r
273 * \brief <b>Close all existing sockets</b>.\r
274 *\r
275 */\r
276 NFCSTATUS phFriNfc_LlcpTransport_CloseAll (phFriNfc_LlcpTransport_t  *pLlcpSocketTable);\r
277 \r
278 \r
279 /**\r
280 * \ingroup grp_lib_nfc\r
281 * \brief <b>Get the local options of a socket</b>.\r
282 *\r
283 * This function returns the local options (maximum packet size and receive window size) used\r
284 * for a given connection-oriented socket. This function shall not be used with connectionless\r
285 * sockets.\r
286 *\r
287 * \param[out] pLlcpSocket           A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
288 * \param[in]  psLocalOptions        A pointer to be filled with the local options of the socket.\r
289 *\r
290 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
291 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
292 *                                            could not be properly interpreted.\r
293 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
294 *                                            a valid type to perform the requsted operation.\r
295 * \retval NFCSTATUS_NOT_INITIALISED          Indicates stack is not yet initialized.\r
296 * \retval NFCSTATUS_SHUTDOWN                 Shutdown in progress.\r
297 * \retval NFCSTATUS_FAILED                   Operation failed.\r
298 */\r
299 NFCSTATUS phFriNfc_LlcpTransport_SocketGetLocalOptions(phFriNfc_LlcpTransport_Socket_t  *pLlcpSocket,\r
300                                                        phLibNfc_Llcp_sSocketOptions_t   *psLocalOptions);\r
301 \r
302 \r
303 /**\r
304 * \ingroup grp_lib_nfc\r
305 * \brief <b>Get the local options of a socket</b>.\r
306 *\r
307 * This function returns the remote options (maximum packet size and receive window size) used\r
308 * for a given connection-oriented socket. This function shall not be used with connectionless\r
309 * sockets.\r
310 *\r
311 * \param[out] pLlcpSocket           A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
312 * \param[in]  psRemoteOptions       A pointer to be filled with the remote options of the socket.\r
313 *\r
314 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
315 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
316 *                                            could not be properly interpreted.\r
317 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
318 *                                            a valid type to perform the requsted operation.\r
319 * \retval NFCSTATUS_NOT_INITIALISED          Indicates stack is not yet initialized.\r
320 * \retval NFCSTATUS_SHUTDOWN                 Shutdown in progress.\r
321 * \retval NFCSTATUS_FAILED                   Operation failed.\r
322 */\r
323 NFCSTATUS phFriNfc_LlcpTransport_SocketGetRemoteOptions(phFriNfc_LlcpTransport_Socket_t*   pLlcpSocket,\r
324                                                         phLibNfc_Llcp_sSocketOptions_t*    psRemoteOptions);\r
325 \r
326 \r
327  /**\r
328 * \ingroup grp_fri_nfc\r
329 * \brief <b>Create a socket on a LLCP-connected device</b>.\r
330 *\r
331 * This function creates a socket for a given LLCP link. Sockets can be of two types : \r
332 * connection-oriented and connectionless. If the socket is connection-oriented, the caller\r
333 * must provide a working buffer to the socket in order to handle incoming data. This buffer\r
334 * must be large enough to fit the receive window (RW * MIU), the remaining space being\r
335 * used as a linear buffer to store incoming data as a stream. Data will be readable later\r
336 * using the phLibNfc_LlcpTransport_Recv function.\r
337 * The options and working buffer are not required if the socket is used as a listening socket,\r
338 * since it cannot be directly used for communication.\r
339 *\r
340 * \param[in]  pLlcpSocketTable      A pointer to a table of PHFRINFC_LLCP_NB_SOCKET_DEFAULT sockets.\r
341 * \param[in]  eType                 The socket type.\r
342 * \param[in]  psOptions             The options to be used with the socket.\r
343 * \param[in]  psWorkingBuffer       A working buffer to be used by the library.\r
344 * \param[out] pLlcpSocket           A pointer to a socket pointer to be filled with a\r
345                                     socket found on the socket table.\r
346 * \param[in]  pErr_Cb               The callback to be called each time the socket\r
347 *                                   is in error.\r
348 * \param[in]  pContext              Upper layer context to be returned in the callback.\r
349 *\r
350 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
351 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
352 *                                            could not be properly interpreted.\r
353 * \retval NFCSTATUS_BUFFER_TOO_SMALL         The working buffer is too small for the MIU and RW\r
354 *                                            declared in the options.\r
355 * \retval NFCSTATUS_INSUFFICIENT_RESOURCES   No more socket handle available.\r
356 * \retval NFCSTATUS_FAILED                   Operation failed.  \r
357 * */\r
358 NFCSTATUS phFriNfc_LlcpTransport_Socket(phFriNfc_LlcpTransport_t                           *pLlcpSocketTable,\r
359                                         phFriNfc_LlcpTransport_eSocketType_t               eType,\r
360                                         phFriNfc_LlcpTransport_sSocketOptions_t*           psOptions,\r
361                                         phNfc_sData_t*                                     psWorkingBuffer,\r
362                                         phFriNfc_LlcpTransport_Socket_t                    **pLlcpSocket,\r
363                                         pphFriNfc_LlcpTransportSocketErrCb_t               pErr_Cb,\r
364                                         void*                                              pContext);\r
365 \r
366 /**\r
367 * \ingroup grp_fri_nfc\r
368 * \brief <b>Close a socket on a LLCP-connected device</b>.\r
369 *\r
370 * This function closes a LLCP socket previously created using phFriNfc_LlcpTransport_Socket.\r
371 * If the socket was connected, it is first disconnected, and then closed.\r
372 *\r
373 * \param[in]  pLlcpSocket                    A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
374 \r
375 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
376 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
377 *                                            could not be properly interpreted.\r
378 * \retval NFCSTATUS_FAILED                   Operation failed.\r
379 */\r
380 NFCSTATUS phFriNfc_LlcpTransport_Close(phFriNfc_LlcpTransport_Socket_t*   pLlcpSocket);\r
381 \r
382 \r
383 /**\r
384 * \ingroup grp_fri_nfc\r
385 * \brief <b>Bind a socket to a local SAP</b>.\r
386 *\r
387 * This function binds the socket to a local Service Access Point.\r
388 *\r
389 * \param[out] pLlcpSocket           A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
390 * \param[in]  pConfigInfo           A port number for a specific socket\r
391 *\r
392 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
393 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
394 *                                            could not be properly interpreted.\r
395 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
396 *                                            a valid type to perform the requsted operation.\r
397 * \retval NFCSTATUS_ALREADY_REGISTERED       The selected SAP is already bound to another\r
398                                              socket.\r
399 * \retval NFCSTATUS_FAILED                   Operation failed.\r
400 */\r
401 NFCSTATUS phFriNfc_LlcpTransport_Bind(phFriNfc_LlcpTransport_Socket_t    *pLlcpSocket,\r
402                                       uint8_t                            nSap);\r
403 \r
404 /**\r
405 * \ingroup grp_fri_nfc\r
406 * \brief <b>Listen for incoming connection requests on a socket</b>.\r
407 *\r
408 * This function switches a socket into a listening state and registers a callback on\r
409 * incoming connection requests. In this state, the socket is not able to communicate\r
410 * directly. The listening state is only available for connection-oriented sockets\r
411 * which are still not connected. The socket keeps listening until it is closed, and\r
412 * thus can trigger several times the pListen_Cb callback.\r
413 *\r
414 *\r
415 * \param[in]  pLlcpSocket        A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
416 * \param[in]  psServiceName      A pointer to a Service Name \r
417 * \param[in]  pListen_Cb         The callback to be called each time the\r
418 *                                socket receive a connection request.\r
419 * \param[in]  pContext           Upper layer context to be returned in\r
420 *                                the callback.\r
421 *\r
422 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
423 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
424 *                                            could not be properly interpreted.\r
425 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state to switch\r
426 *                                            to listening state.\r
427 * \retval NFCSTATUS_FAILED                   Operation failed.\r
428 */\r
429 NFCSTATUS phFriNfc_LlcpTransport_Listen(phFriNfc_LlcpTransport_Socket_t*          pLlcpSocket,\r
430                                         phNfc_sData_t                             *psServiceName,\r
431                                         pphFriNfc_LlcpTransportSocketListenCb_t   pListen_Cb,\r
432                                         void*                                     pContext);\r
433 /**\r
434 * \ingroup grp_fri_nfc\r
435 * \brief <b>Accept an incoming connection request for a socket</b>.\r
436 *\r
437 * This functions allows the client to accept an incoming connection request.\r
438 * It must be used with the socket provided within the listen callback. The socket\r
439 * is implicitly switched to the connected state when the function is called.\r
440 *\r
441 * \param[in]  pLlcpSocket           A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
442 * \param[in]  psOptions             The options to be used with the socket.\r
443 * \param[in]  psWorkingBuffer       A working buffer to be used by the library.\r
444 * \param[in]  pErr_Cb               The callback to be called each time the accepted socket\r
445 *                                   is in error.\r
446 * \param[in]  pAccept_RspCb         The callback to be called when the Accept operation is completed\r
447 * \param[in]  pContext              Upper layer context to be returned in the callback.\r
448 *\r
449 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
450 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
451 *                                            could not be properly interpreted.\r
452 * \retval NFCSTATUS_BUFFER_TOO_SMALL         The working buffer is too small for the MIU and RW\r
453 *                                            declared in the options.\r
454 * \retval NFCSTATUS_FAILED                   Operation failed.\r
455 */\r
456 NFCSTATUS phFriNfc_LlcpTransport_Accept(phFriNfc_LlcpTransport_Socket_t*             pLlcpSocket,\r
457                                         phFriNfc_LlcpTransport_sSocketOptions_t*     psOptions,\r
458                                         phNfc_sData_t*                               psWorkingBuffer,\r
459                                         pphFriNfc_LlcpTransportSocketErrCb_t         pErr_Cb,\r
460                                         pphFriNfc_LlcpTransportSocketAcceptCb_t      pAccept_RspCb,\r
461                                         void*                                        pContext);\r
462 \r
463  /**\r
464 * \ingroup grp_fri_nfc\r
465 * \brief <b>Reject an incoming connection request for a socket</b>.\r
466 *\r
467 * This functions allows the client to reject an incoming connection request.\r
468 * It must be used with the socket provided within the listen callback. The socket\r
469 * is implicitly closed when the function is called.\r
470 *\r
471 * \param[in]  pLlcpSocket           A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
472 * \param[in]  pReject_RspCb         The callback to be called when the Reject operation is completed\r
473 * \param[in]  pContext              Upper layer context to be returned in the callback.\r
474 *\r
475 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
476 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
477 *                                            could not be properly interpreted.\r
478 * \retval NFCSTATUS_FAILED                   Operation failed.\r
479 */\r
480 NFCSTATUS phFriNfc_LlcpTransport_Reject( phFriNfc_LlcpTransport_Socket_t*           pLlcpSocket,\r
481                                             pphFriNfc_LlcpTransportSocketRejectCb_t   pReject_RspCb,\r
482                                             void                                      *pContext);\r
483 /**\r
484 * \ingroup grp_fri_nfc\r
485 * \brief <b>Try to establish connection with a socket on a remote SAP</b>.\r
486 *\r
487 * This function tries to connect to a given SAP on the remote peer. If the\r
488 * socket is not bound to a local SAP, it is implicitly bound to a free SAP.\r
489 *\r
490 * \param[in]  pLlcpSocket           A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
491 * \param[in]  nSap               The destination SAP to connect to.\r
492 * \param[in]  pConnect_RspCb     The callback to be called when the connection\r
493 *                                operation is completed.\r
494 * \param[in]  pContext           Upper layer context to be returned in\r
495 *                                the callback.\r
496 *\r
497 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
498 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
499 *                                            could not be properly interpreted.\r
500 * \retval NFCSTATUS_PENDING                  Connection operation is in progress,\r
501 *                                            pConnect_RspCb will be called upon completion.\r
502 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
503 *                                            a valid type to perform the requsted operation.\r
504 * \retval NFCSTATUS_FAILED                   Operation failed.\r
505 */\r
506 NFCSTATUS phFriNfc_LlcpTransport_Connect( phFriNfc_LlcpTransport_Socket_t*           pLlcpSocket,\r
507                                           uint8_t                                    nSap,\r
508                                           pphFriNfc_LlcpTransportSocketConnectCb_t   pConnect_RspCb,\r
509                                           void*                                      pContext);\r
510 \r
511 /**\r
512 * \ingroup grp_fri_nfc\r
513 * \brief <b>Try to establish connection with a socket on a remote service, given its URI</b>.\r
514 *\r
515 * This function tries to connect to a SAP designated by an URI. If the\r
516 * socket is not bound to a local SAP, it is implicitly bound to a free SAP.\r
517 *\r
518 * \param[in]  pLlcpSocket        A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
519 * \param[in]  psUri              The URI corresponding to the destination SAP to connect to.\r
520 * \param[in]  pConnect_RspCb     The callback to be called when the connection\r
521 *                                operation is completed.\r
522 * \param[in]  pContext           Upper layer context to be returned in\r
523 *                                the callback.\r
524 *\r
525 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
526 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
527 *                                            could not be properly interpreted.\r
528 * \retval NFCSTATUS_PENDING                  Connection operation is in progress,\r
529 *                                            pConnect_RspCb will be called upon completion.\r
530 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
531 *                                            a valid type to perform the requsted operation.\r
532 * \retval NFCSTATUS_NOT_INITIALISED          Indicates stack is not yet initialized.\r
533 * \retval NFCSTATUS_SHUTDOWN                 Shutdown in progress.\r
534 * \retval NFCSTATUS_FAILED                   Operation failed.\r
535 */\r
536 NFCSTATUS phFriNfc_LlcpTransport_ConnectByUri(phFriNfc_LlcpTransport_Socket_t*           pLlcpSocket,\r
537                                               phNfc_sData_t*                            psUri,\r
538                                               pphFriNfc_LlcpTransportSocketConnectCb_t   pConnect_RspCb,\r
539                                               void*                                     pContext);\r
540 \r
541 /**\r
542 * \ingroup grp_lib_nfc\r
543 * \brief <b>Disconnect a currently connected socket</b>.\r
544 *\r
545 * This function initiates the disconnection of a previously connected socket.\r
546 *\r
547 * \param[in]  pLlcpSocket        A pointer to a phFriNfc_LlcpTransport_Socket_t.\r
548 * \param[in]  pDisconnect_RspCb  The callback to be called when the \r
549 *                                operation is completed.\r
550 * \param[in]  pContext           Upper layer context to be returned in\r
551 *                                the callback.\r
552 *\r
553 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
554 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
555 *                                            could not be properly interpreted.\r
556 * \retval NFCSTATUS_PENDING                  Disconnection operation is in progress,\r
557 *                                            pDisconnect_RspCb will be called upon completion.\r
558 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
559 *                                            a valid type to perform the requsted operation.\r
560 * \retval NFCSTATUS_NOT_INITIALISED          Indicates stack is not yet initialized.\r
561 * \retval NFCSTATUS_SHUTDOWN                 Shutdown in progress.\r
562 * \retval NFCSTATUS_FAILED                   Operation failed.\r
563 */\r
564 NFCSTATUS phFriNfc_LlcpTransport_Disconnect(phFriNfc_LlcpTransport_Socket_t*           pLlcpSocket,\r
565                                             pphLibNfc_LlcpSocketDisconnectCb_t         pDisconnect_RspCb,\r
566                                             void*                                      pContext);\r
567 \r
568 /**\r
569 * \ingroup grp_fri_nfc\r
570 * \brief <b>Send data on a socket</b>.\r
571 *\r
572 * This function is used to write data on a socket. This function\r
573 * can only be called on a connection-oriented socket which is already\r
574 * in a connected state.\r
575\r
576 *\r
577 * \param[in]  hSocket            Socket handle obtained during socket creation.\r
578 * \param[in]  psBuffer           The buffer containing the data to send.\r
579 * \param[in]  pSend_RspCb        The callback to be called when the \r
580 *                                operation is completed.\r
581 * \param[in]  pContext           Upper layer context to be returned in\r
582 *                                the callback.\r
583 *\r
584 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
585 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
586 *                                            could not be properly interpreted.\r
587 * \retval NFCSTATUS_PENDING                  Reception operation is in progress,\r
588 *                                            pSend_RspCb will be called upon completion.\r
589 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
590 *                                            a valid type to perform the requsted operation.\r
591 * \retval NFCSTATUS_FAILED                   Operation failed.\r
592 */\r
593 NFCSTATUS phFriNfc_LlcpTransport_Send(phFriNfc_LlcpTransport_Socket_t*             pLlcpSocket,\r
594                                       phNfc_sData_t*                               psBuffer,\r
595                                       pphFriNfc_LlcpTransportSocketSendCb_t        pSend_RspCb,\r
596                                       void*                                        pContext);\r
597 \r
598 /**\r
599 * \ingroup grp_fri_nfc\r
600 * \brief <b>Read data on a socket</b>.\r
601 *\r
602 * This function is used to read data from a socket. It reads at most the\r
603 * size of the reception buffer, but can also return less bytes if less bytes\r
604 * are available. If no data is available, the function will be pending until\r
605 * more data comes, and the response will be sent by the callback. This function\r
606 * can only be called on a connection-oriented socket.\r
607\r
608 *\r
609 * \param[in]  hSocket            Socket handle obtained during socket creation.\r
610 * \param[in]  psBuffer           The buffer receiving the data.\r
611 * \param[in]  pRecv_RspCb        The callback to be called when the \r
612 *                                operation is completed.\r
613 * \param[in]  pContext           Upper layer context to be returned in\r
614 *                                the callback.\r
615 *\r
616 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
617 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
618 *                                            could not be properly interpreted.\r
619 * \retval NFCSTATUS_PENDING                  Reception operation is in progress,\r
620 *                                            pRecv_RspCb will be called upon completion.\r
621 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
622 *                                            a valid type to perform the requsted operation.\r
623 * \retval NFCSTATUS_FAILED                   Operation failed.\r
624 */\r
625 NFCSTATUS phFriNfc_LlcpTransport_Recv( phFriNfc_LlcpTransport_Socket_t*             pLlcpSocket,\r
626                                        phNfc_sData_t*                               psBuffer,\r
627                                        pphFriNfc_LlcpTransportSocketRecvCb_t        pRecv_RspCb,\r
628                                        void*                                        pContext);\r
629 \r
630 \r
631 \r
632  /**\r
633 * \ingroup grp_lib_nfc\r
634 * \brief <b>Read data on a socket and get the source SAP</b>.\r
635 *\r
636 * This function is the same as phLibNfc_Llcp_Recv, except that the callback includes\r
637 * the source SAP. This functions can only be called on a connectionless socket.\r
638\r
639 *\r
640 * \param[in]  pLlcpSocket        A pointer to a LlcpSocket created.\r
641 * \param[in]  psBuffer           The buffer receiving the data.\r
642 * \param[in]  pRecv_RspCb        The callback to be called when the \r
643 *                                operation is completed.\r
644 * \param[in]  pContext           Upper layer context to be returned in\r
645 *                                the callback.\r
646 *\r
647 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
648 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
649 *                                            could not be properly interpreted.\r
650 * \retval NFCSTATUS_PENDING                  Reception operation is in progress,\r
651 *                                            pRecv_RspCb will be called upon completion.\r
652 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
653 *                                            a valid type to perform the requsted operation.\r
654 * \retval NFCSTATUS_NOT_INITIALISED          Indicates stack is not yet initialized.\r
655 * \retval NFCSTATUS_SHUTDOWN                 Shutdown in progress.\r
656 * \retval NFCSTATUS_FAILED                   Operation failed.\r
657 */\r
658 NFCSTATUS phFriNfc_LlcpTransport_RecvFrom( phFriNfc_LlcpTransport_Socket_t                   *pLlcpSocket,\r
659                                            phNfc_sData_t*                                    psBuffer,\r
660                                            pphFriNfc_LlcpTransportSocketRecvFromCb_t         pRecv_Cb,\r
661                                            void                                              *pContext);\r
662 \r
663 /**\r
664 * \ingroup grp_fri_nfc\r
665 * \brief <b>Send data on a socket to a given destination SAP</b>.\r
666 *\r
667 * This function is used to write data on a socket to a given destination SAP.\r
668 * This function can only be called on a connectionless socket.\r
669\r
670 *\r
671 * \param[in]  pLlcpSocket        A pointer to a LlcpSocket created.\r
672 * \param[in]  nSap               The destination SAP.\r
673 * \param[in]  psBuffer           The buffer containing the data to send.\r
674 * \param[in]  pSend_RspCb        The callback to be called when the \r
675 *                                operation is completed.\r
676 * \param[in]  pContext           Upper layer context to be returned in\r
677 *                                the callback.\r
678 *\r
679 * \retval NFCSTATUS_SUCCESS                  Operation successful.\r
680 * \retval NFCSTATUS_INVALID_PARAMETER        One or more of the supplied parameters\r
681 *                                            could not be properly interpreted.\r
682 * \retval NFCSTATUS_PENDING                  Reception operation is in progress,\r
683 *                                            pSend_RspCb will be called upon completion.\r
684 * \retval NFCSTATUS_INVALID_STATE            The socket is not in a valid state, or not of \r
685 *                                            a valid type to perform the requsted operation.\r
686 * \retval NFCSTATUS_NOT_INITIALISED          Indicates stack is not yet initialized.\r
687 * \retval NFCSTATUS_SHUTDOWN                 Shutdown in progress.\r
688 * \retval NFCSTATUS_FAILED                   Operation failed.\r
689 */\r
690 NFCSTATUS phFriNfc_LlcpTransport_SendTo( phFriNfc_LlcpTransport_Socket_t             *pLlcpSocket,\r
691                                          uint8_t                                     nSap,\r
692                                          phNfc_sData_t*                              psBuffer,\r
693                                          pphFriNfc_LlcpTransportSocketSendCb_t       pSend_RspCb,\r
694                                          void*                                       pContext);\r
695 #endif  /*  PHFRINFC_LLCP_TRANSPORT_H    */\r