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