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