NXP NFC Reader Library v4.040.05.011646

Modules | Macros | Functions
NFCForum-LLCP
Link Abstraction Layer

This Component implements the NFCForum Logical Link Control Protocol (LLCP) version 1.1. More...

Collaboration diagram for NFCForum-LLCP:

## Modules
| Component : Software
| Implementation of NFCForum Logical Link Control Protocol (LLCP) 1.1.

## Macros
#define | PHLN_LLCP_MAGIC_NUM_BYTE1 0x46
| LLCP Magic Byte-1. More...
#define | PHLN_LLCP_MAGIC_NUM_BYTE2 0x66
| LLCP Magic Byte-2. More...
#define | PHLN_LLCP_MAGIC_NUM_BYTE3 0x6D
| LLCP Magic Byte-3. More...

## Functions
phStatus_t | phlnLlcp_Activate (void *pDataParams, uint8_t *pRemoteGnrlBytes, uint8_t bRemoteGnrBytesLen, uint8_t bDevType)
| Activates the LLCP layer link by checking General Bytes content of ATR_REQ/ATR_RES. More...
phStatus_t | phlnLlcp_Deactivate (void *pDataParams)
| Deactivate the LLCP layer link. More...
phStatus_t | phlnLlcp_WaitForActivation (void *pDataParams)
| Wait for LLCP Activation Event from Reader Library Thread. More...
phStatus_t | phlnLlcp_Transport_Socket_Init (void *pDataParams, phlnLlcp_Transport_Socket_t *psSocket, phlnLlcp_Transport_Socket_Type_t eSocketType, uint8_t *pSocketRxBuffer, uint32_t dwSocketRxBufferSize)
| Initializes a new socket. More...
phStatus_t | phlnLlcp_Transport_Socket_Register (void *pDataParams, phlnLlcp_Transport_Socket_t *pSocket, phlnLlcp_Transport_Socket_Type_t eSocketType, uint8_t bLsap, uint8_t *pUri)
| Register a socket at the SAP manager. More...
phStatus_t | phlnLlcp_Transport_Socket_WaitForConnection (void *pDataParams, phlnLlcp_Transport_Socket_t *pServerSocket, phlnLlcp_Transport_Socket_t *pConnServerSocket)
| WaitForConnection is a Blocking call used by a Connection-oriented Server socket waiting for an incoming client connection on the registered pServerSocket. More...
phStatus_t | phlnLlcp_Transport_Socket_Connect (void *pDataParams, phlnLlcp_Transport_Socket_t *pClientSocket, uint8_t bDsap)
| Connect is a Blocking call used by a Connection-oriented client socket to connect to a remote server with a DSAP given with bDsap. More...
phStatus_t | phlnLlcp_Transport_Socket_ConnectViaUri (void *pDataParams, phlnLlcp_Transport_Socket_t *pClientSocket, uint8_t *pUri)
| ConnectViaUri is a Blocking call used by a Connection-oriented client socket to connect to a remote server with a Uniform Resource Identifier (URI) given with pUri. More...
phStatus_t | phlnLlcp_Transport_Socket_Receive (void *pDataParams, phlnLlcp_Transport_Socket_t *psSocket)
| Receive is a Blocking call used to receive data on a socket. More...
phStatus_t | phlnLlcp_Transport_Socket_Send (void *pDataParams, phlnLlcp_Transport_Socket_t *pClientSocket, uint8_t *pTxBuffer, uint32_t dwTxBufferSize, uint16_t wFrameOpt)
| Send is a Blocking call used to send data on a Connection-oriented socket. More...
phStatus_t | phlnLlcp_Transport_Socket_DiscoverServices (void *pDataParams, phlnLlcp_Transport_Socket_t *pSocket, uint8_t bNumber, uint8_t bSNBuffSize, uint8_t *psServiceNameList, uint8_t *pSapList)
| Get SAP of remote services using their URIs (Uniform Resource Identifier). More...
phStatus_t | phlnLlcp_Transport_Socket_SendTo (void *pDataParams, phlnLlcp_Transport_Socket_t *pClientSocket, uint8_t bDsap, uint8_t *pTxBuffer, uint32_t dwTxBufferSize, uint16_t wFrameOpt)
| SendTo is a used to send data on a Connection-less socket. More...
phStatus_t | phlnLlcp_Transport_Socket_Disconnect (void *pDataParams, phlnLlcp_Transport_Socket_t *pClientSocket)
| Disconnect is a Blocking call used to close a Connection-oriented socket and its related data link. More...
phStatus_t | phlnLlcp_Transport_Socket_Unregister (void *pDataParams, phlnLlcp_Transport_Socket_t *pSocket)
| Unregister a socket from the SAP Manager. More...
phStatus_t | phlnLlcp_DeInit (void *pDataParams)
| DeInit is used to release all the acquired resources and reset internal parameters of LLCP. More...

## LLCP Socket States
#define | PHLN_LLCP_SOCKET_WAITONCONN 0x01
| Socket is blocked on new remote connection. More...
#define | PHLN_LLCP_SOCKET_CONN_PEND 0x02
| Status indicates Connect PDU to be sent. More...
#define | PHLN_LLCP_SOCKET_DISC_PEND 0x04
| Status indicates Disconnect PDU to be sent. More...
#define | PHLN_LLCP_SOCKET_DISC 0x10
| Received a Disconnect/Disconnect Mode(DM) PDU. More...
#define | PHLN_LLCP_SOCKET_INFO_EX 0x20
| Information Exchange. More...
#define | PHLN_LLCP_SOCKET_INFO_SEND_EX 0x40
| Send Information and update after next Packet is received. More...
#define | PHLN_LLCP_SOCKET_SNL 0x60
| SNL Exchange. More...

## LLCP specific error codes.
Note Do not change the macro values.
#define | PH_ERR_LLCP_PDU_TX_SEQ_ERR 0x81
| Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Receive. More...
#define | PH_ERR_LLCP_PDU_RX_SEQ_ERR 0x82
| Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Send. More...
#define | PH_ERR_LLCP_DEACTIVATED 0x83
| Status code returned by phlnLlcp_Activate when LLCP is deactivated by calling phlnLlcp_Deactivate The phlnLlcp_Deactivate function can only be called from another task while LLCP flow is active in one task. More...
#define | PH_ERR_LLCP_PDU_INFO_ERR 0x84
| Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Receive. More...
#define | PH_ERR_PEER_DISCONNECTED 0x85
| Returned by phlnLlcp_Activate function when the peer sends DISC PDU over default LLCP Link Management i.e., Local SAP = 0 and Remote SAP = 0. More...
#define | PH_ERR_LLCP_PDU_FRMR 0x86
| Returned by phlnLlcp_Activate function when the peer sends Frame Reject (FRMR) PDU over default LLCP link management i.e., Local SAP = 0 and Remote SAP = 0.
#define | PH_ERR_LLCP_PDU_INVALID 0x88
| Status notified to the end point. More...
#define | PH_ERR_LLCP_PDU_INFO_PER 0x8C
| Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Receive, phlnLlcp_Transport_Socket_Send, phlnLlcp_Transport_Socket_Connect. More...
#define | PH_ERR_LLCP_SOCKET_REGISTERED 0x8D
| Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Register. More...
#define | PH_ERR_LLCP_SOCKET_NOT_REGISTERED 0x8E
| Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Unregister. More...
#define | PH_ERR_LLCP_SAP_EXCEEDED 0x8F
| Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Register. More...
#define | PH_ERR_LLCP_SOCKET_REGISTER_FAILED 0x87
| Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Register. More...

## Mandatory Byte length of ATR_REQ and ATR_RES
#define | PHLN_LLCP_ATR_REQ_MIN_LEN 16U
| Used to locate General Bytes Start Position in the received ATR_REQ. More...
#define | PHLN_LLCP_ATR_RES_MIN_LEN 17U
| Used to locate General Bytes Start Position in the received ATR_RES. More...

## Type-Length-Value (TLV) Parameters
Below macros can be used by the Application developer to validate Type field which specifies the parameter type, the Length field which specifies the length of the value, and the Value field which contains the actual data.
#define | PHLN_LLCP_TLV_TYPE_VERSION 0x01
| Type Field value in Version TLV. More...
#define | PHLN_LLCP_TLV_TYPE_MIUX 0x02
| Type Field value in MIUX (Maximum Information Unit Extension) TLV. More...
#define | PHLN_LLCP_TLV_TYPE_WKS 0x03
| Type Field value in WKS (Well-Known Service List) TLV. More...
#define | PHLN_LLCP_TLV_TYPE_LTO 0x04
| Type Field value in LTO (Link Time-Out) TLV. More...
#define | PHLN_LLCP_TLV_TYPE_RW 0x05
| Type Field value in RW (Receive Window Size) TLV. More...
#define | PHLN_LLCP_TLV_TYPE_SN 0x06
| Type Field value in SN (Service Name) TLV. More...
#define | PHLN_LLCP_TLV_TYPE_OPT 0x07
| Type Field value in OPT (Option) TLV. More...
#define | PHLN_LLCP_TLV_TYPE_SDREQ 0x08
| Type Field value in SDREQ (Service Discovery Request) TLV. More...
#define | PHLN_LLCP_TLV_TYPE_SDRES 0x09
| Type Field value in SDRES (Service Discovery Response) TLV. More...
#define | PHLN_LLCP_TLV_LENGTH_VERSION 0x01
| Length Field value in Version TLV. More...
#define | PHLN_LLCP_TLV_LENGTH_MIUX 0x02
| Length Field value in MIUX Maximum Information Unit Extension) TLV. More...
#define | PHLN_LLCP_TLV_LENGTH_WKS 0x02
| Length Field value in WKS (Well-Known Service List) TLV. More...
#define | PHLN_LLCP_TLV_LENGTH_LTO 0x01
| Length Field value in LTO (Link Time-Out) TLV. More...
#define | PHLN_LLCP_TLV_LENGTH_RW 0x01
| Length Field value in RW (Receive Window Size) TLV. More...
#define | PHLN_LLCP_TLV_LENGTH_OPT 0x01
| Length Field value in OPT (Option) TLV. More...
#define | PHLN_LLCP_TLV_LENGTH_SDRES 0x02
| Length Field value in SDRES TLV. More...
#define | PHLN_LLCP_TLV_MIUX_MASK ( 1 << 0x01 )
| Mask used to set MIUX in 'bAvailableTlv' of phlnLlcp_LMDataParams_t of Local Link. More...
#define | PHLN_LLCP_TLV_WKS_MASK ( 1 << 0x02 )
| Mask used to set WKS in 'bAvailableTlv' of phlnLlcp_LMDataParams_t of Local Link. More...
#define | PHLN_LLCP_TLV_LTO_MASK ( 1 << 0x03 )
| Mask used to set LTO in 'bAvailableTlv' of phlnLlcp_LMDataParams_t of Local Link. More...
#define | PHLN_LLCP_TLV_OPT_MASK ( 1 << 0x04 )
| Mask used to set OPT in 'bAvailableTlv' of phlnLlcp_LMDataParams_t of Local Link. More...
#define | PHLN_LLCP_TLV_VERSION_VALUE 0x11
| Major version number is 1, Minor version number is 1. More...

## Maximum Information Unit (MIU).
Default value of MIU is 248 and HAL Rx Buffer should be approximately around 260bytes or more. This value is chosen for better Performance as MAC will support Frame size of 254Bytes. Restriction: NxpNfcRdlib cannot support MIU more than HAL Rx Buffer size.
#define | PHLN_LLCP_MIU 248
| Maximum number of bytes in the information field of an LLC PDU that the local LLC is able to receive. More...
#define | PHLN_LLCP_TLV_MIUX_VALUE (PHLN_LLCP_MIU - 128)
| MIUX (Maximum Information Unit Extension) = Maximum Information Unit (MIU) - 128. More...

## SYMM timeout as the percentage of LLCP link time out(LTO) / MAC time out(TO).
User can change this value based on requirement. NOTE : High value will impact LLCP performance.
#define | PHLN_LLCP_SYMM_VALUE 10

## Receive Window size of LLCP
Receive window size of one indicates that the local LLC will acknowledge every I PDU before accepting additional I PDUs. This is fixed as per design and cannot be changed.
#define | PHLN_LLCP_TLV_RW_VALUE 0x01

## LLCP Device Type.
Indicates either NFC Forum Initiator OR Target. NOTE : DO NOT CHANGE THE MACRO AS IT IS TIED WITH LLCP LOGIC.
#define | PHLN_LLCP_INITIATOR 0
#define | PHLN_LLCP_TARGET 1

## LLCP De-Aggregation.
Indicates whether LLCP stack supports dispatching the Aggregated LLC PDUs according to each PDUs destination and Source Service Access Point (SSAP) Address. If LLCP don't need to handle De-Aggregation then PHLN_LLCP_AGF flag can be set to zero. In which case code for De-Aggregation will not be complied.
#define | PHLN_LLCP_AGF 1

## Disconnected Mode Reasons
These are sent as part of Disconnected Mode (DM) PDU reason field. Refer LLCP1.1 specification section 4.3.8 table 4.
#define | PHLN_LLCP_PDU_DM_DISC 0x00
| Indicates the Logical Link Control (LLC) has received a DISC PDU and is now logically disconnected from the data link connection. More...
#define | PHLN_LLCP_PDU_DM_NO_CONN 0x01
| Indicates the LLC has received a connection-oriented PDU but the target service access point has no active connection. More...
#define | PHLN_LLCP_PDU_DM_NO_SAP 0x02
| Indicates the remote LLC has received a CONNECT PDU and there is no service bound to the specified target service access point. More...
#define | PHLN_LLCP_PDU_DM_CONN_REJ 0x03
| Indicates the remote LLC has processed a CONNECT PDU and the request to connect was rejected by the service layer. More...
#define | PHLN_LLCP_PDU_DM_SAP_REJ 0x10
| Indicates the LLC will permanently not accept any CONNECT PDUs with the same target service access point address. More...
#define | PHLN_LLCP_PDU_DM_ANY_REJ 0x11
| Indicates the LLC will permanently not accept any CONNECT PDUs with any target service access point address. More...
#define | PHLN_LLCP_PDU_DM_TEMP_SAP_REJ 0x20
| Indicates the LLC will temporarily not accept any CONNECT PDUs with the specified target service access point address. More...
#define | PHLN_LLCP_PDU_DM_TEMP_ANY_REJ 0x21
| Indicates the LLC will temporarily not accept any CONNECT PDUs with any target service access point address. More...

## Detailed Description

This Component implements the NFCForum Logical Link Control Protocol (LLCP) version 1.1.

Limitations:

1. LLCP will not perform any handling of MAC (18092) chaining feature as this requires an additional buffer for LLCP to perform this task. LLCP will use MAC chaining feature using HAL receive buffer. To handle N times of MAC chaining using HAL Rx buffer, size of the HAL Rx buffer provided by the application should be N+1 times the Frame Size. So to increase MIU of LLCP, both socket buffer and HAL Rx buffer size needs to be increase proportionately.
Example: If HAL Rx Buffer Size = 1024Bytes. Then MAC chaining of 3 Frames of 254 bytes (762Bytes) can be achieved with LLCP.

2. In target mode, if remote peer sends CONNECT PDU immediately after ATR_RES is sent by RdLib Stack and if application LLCP Server task could not register socket before CONNECT PDU is received then DM PDU will be transmitted by RdLib LLCP Stack and connection will not be established with application LLCP Server. In this case either FreeRTOS timer task priority should be lower than any other task in system (which is defined in FreeRTOSConfig.h in FreeRTOS project) or the remote peer should send CONNECT PDU once again to establish connection with application LLCP Server.

This layer follows a multi-threaded RTOS based design using one reader library task and one LLCP Server/Client application task. Reader Library Task calls phlnLlcp_Activate API to establish Logical Link Connection on which Connection-Oriented or Connection-Less packets can be exchanged.

A pictorial representation of Reader Library task and LLCP Server Application task used to communicate with Peer LLCP Client is as shown below.

A pictorial representation of Reader Library task and LLCP Client Application task used to communicate with Peer LLCP Server is as shown below.

## Macro Definition Documentation

## § PHLN_LLCP_SOCKET_WAITONCONN

#define PHLN_LLCP_SOCKET_WAITONCONN 0x01

Socket is blocked on new remote connection.

## § PHLN_LLCP_SOCKET_CONN_PEND

#define PHLN_LLCP_SOCKET_CONN_PEND 0x02

Status indicates Connect PDU to be sent.

## § PHLN_LLCP_SOCKET_DISC_PEND

#define PHLN_LLCP_SOCKET_DISC_PEND 0x04

Status indicates Disconnect PDU to be sent.

## § PHLN_LLCP_SOCKET_DISC

#define PHLN_LLCP_SOCKET_DISC 0x10

Received a Disconnect/Disconnect Mode(DM) PDU.

## § PHLN_LLCP_SOCKET_INFO_EX

#define PHLN_LLCP_SOCKET_INFO_EX 0x20

Information Exchange.

## § PHLN_LLCP_SOCKET_INFO_SEND_EX

#define PHLN_LLCP_SOCKET_INFO_SEND_EX 0x40

Send Information and update after next Packet is received.

## § PHLN_LLCP_SOCKET_SNL

#define PHLN_LLCP_SOCKET_SNL 0x60

SNL Exchange.

## § PH_ERR_LLCP_PDU_TX_SEQ_ERR

#define PH_ERR_LLCP_PDU_TX_SEQ_ERR 0x81

Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Receive.

This means the PDU destined to this SAP contained an invalid send sequence number N(S).

## § PH_ERR_LLCP_PDU_RX_SEQ_ERR

#define PH_ERR_LLCP_PDU_RX_SEQ_ERR 0x82

Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Send.

This means the PDU destined to this SAP contained an invalid receive sequence number N(R).

## § PH_ERR_LLCP_DEACTIVATED

#define PH_ERR_LLCP_DEACTIVATED 0x83

Status code returned by phlnLlcp_Activate when LLCP is deactivated by calling phlnLlcp_Deactivate The phlnLlcp_Deactivate function can only be called from another task while LLCP flow is active in one task.

This error is also returned to end points if they are blocked on any of link management operations like Send, Receive, WaitForConnection, Connect.

## § PH_ERR_LLCP_PDU_INFO_ERR

#define PH_ERR_LLCP_PDU_INFO_ERR 0x84

Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Receive.

This means the PDU destined to this SAP contained an incorrect or unexpected information field or length of data received is more than socket MIU.

## § PH_ERR_PEER_DISCONNECTED

#define PH_ERR_PEER_DISCONNECTED 0x85

Returned by phlnLlcp_Activate function when the peer sends DISC PDU over default LLCP Link Management i.e., Local SAP = 0 and Remote SAP = 0.

In active mode during LLCP link de-activation if peer device did not respond or if there is an error from lower layers then this error code is returned. Since this happens during LLCP de-activation procedure the earlier data exchange/SNEP PUT has likely succeeded.

## § PH_ERR_LLCP_PDU_INVALID

#define PH_ERR_LLCP_PDU_INVALID 0x88

Status notified to the end point.

This means the PDU destined to this SAP is not well formed (W Flag) or invalid. This is returned by phlnLlcp_Transport_Socket_Receive function.

## § PH_ERR_LLCP_PDU_INFO_PER

#define PH_ERR_LLCP_PDU_INFO_PER 0x8C

Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Receive, phlnLlcp_Transport_Socket_Send, phlnLlcp_Transport_Socket_Connect.

This means the remote peer rejected the PDU with an information field that is not permitted for the PDU TYPE

## § PH_ERR_LLCP_SOCKET_REGISTERED

#define PH_ERR_LLCP_SOCKET_REGISTERED 0x8D

Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Register.

This means a socket which is already registered at SAP manager is trying to register once again.

## § PH_ERR_LLCP_SOCKET_NOT_REGISTERED

#define PH_ERR_LLCP_SOCKET_NOT_REGISTERED 0x8E

Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Unregister.

This means a socket which is passed as an argument is not registered at SAP manager.

## § PH_ERR_LLCP_SAP_EXCEEDED

#define PH_ERR_LLCP_SAP_EXCEEDED 0x8F

Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Register.

This means all the available SAP that can be allocated for clients are exceeded (i.e. Max 31).

## § PH_ERR_LLCP_SOCKET_REGISTER_FAILED

#define PH_ERR_LLCP_SOCKET_REGISTER_FAILED 0x87

Status notified to the end point as a return code of phlnLlcp_Transport_Socket_Register.

This means LLCP is not active and socket cannot be registered with SAP manager.

## § PHLN_LLCP_MAGIC_NUM_BYTE1

#define PHLN_LLCP_MAGIC_NUM_BYTE1 0x46

LLCP Magic Byte-1.

## § PHLN_LLCP_MAGIC_NUM_BYTE2

#define PHLN_LLCP_MAGIC_NUM_BYTE2 0x66

LLCP Magic Byte-2.

## § PHLN_LLCP_MAGIC_NUM_BYTE3

#define PHLN_LLCP_MAGIC_NUM_BYTE3 0x6D

LLCP Magic Byte-3.

## § PHLN_LLCP_ATR_REQ_MIN_LEN

#define PHLN_LLCP_ATR_REQ_MIN_LEN 16U

Used to locate General Bytes Start Position in the received ATR_REQ.

## § PHLN_LLCP_ATR_RES_MIN_LEN

#define PHLN_LLCP_ATR_RES_MIN_LEN 17U

Used to locate General Bytes Start Position in the received ATR_RES.

## § PHLN_LLCP_TLV_TYPE_VERSION

#define PHLN_LLCP_TLV_TYPE_VERSION 0x01

Type Field value in Version TLV.

## § PHLN_LLCP_TLV_TYPE_MIUX

#define PHLN_LLCP_TLV_TYPE_MIUX 0x02

Type Field value in MIUX (Maximum Information Unit Extension) TLV.

## § PHLN_LLCP_TLV_TYPE_WKS

#define PHLN_LLCP_TLV_TYPE_WKS 0x03

Type Field value in WKS (Well-Known Service List) TLV.

## § PHLN_LLCP_TLV_TYPE_LTO

#define PHLN_LLCP_TLV_TYPE_LTO 0x04

Type Field value in LTO (Link Time-Out) TLV.

## § PHLN_LLCP_TLV_TYPE_RW

#define PHLN_LLCP_TLV_TYPE_RW 0x05

Type Field value in RW (Receive Window Size) TLV.

## § PHLN_LLCP_TLV_TYPE_SN

#define PHLN_LLCP_TLV_TYPE_SN 0x06

Type Field value in SN (Service Name) TLV.

## § PHLN_LLCP_TLV_TYPE_OPT

#define PHLN_LLCP_TLV_TYPE_OPT 0x07

Type Field value in OPT (Option) TLV.

## § PHLN_LLCP_TLV_TYPE_SDREQ

#define PHLN_LLCP_TLV_TYPE_SDREQ 0x08

Type Field value in SDREQ (Service Discovery Request) TLV.

## § PHLN_LLCP_TLV_TYPE_SDRES

#define PHLN_LLCP_TLV_TYPE_SDRES 0x09

Type Field value in SDRES (Service Discovery Response) TLV.

## § PHLN_LLCP_TLV_LENGTH_VERSION

#define PHLN_LLCP_TLV_LENGTH_VERSION 0x01

Length Field value in Version TLV.

## § PHLN_LLCP_TLV_LENGTH_MIUX

#define PHLN_LLCP_TLV_LENGTH_MIUX 0x02

Length Field value in MIUX Maximum Information Unit Extension) TLV.

## § PHLN_LLCP_TLV_LENGTH_WKS

#define PHLN_LLCP_TLV_LENGTH_WKS 0x02

Length Field value in WKS (Well-Known Service List) TLV.

## § PHLN_LLCP_TLV_LENGTH_LTO

#define PHLN_LLCP_TLV_LENGTH_LTO 0x01

Length Field value in LTO (Link Time-Out) TLV.

## § PHLN_LLCP_TLV_LENGTH_RW

#define PHLN_LLCP_TLV_LENGTH_RW 0x01

Length Field value in RW (Receive Window Size) TLV.

## § PHLN_LLCP_TLV_LENGTH_OPT

#define PHLN_LLCP_TLV_LENGTH_OPT 0x01

Length Field value in OPT (Option) TLV.

## § PHLN_LLCP_TLV_LENGTH_SDRES

#define PHLN_LLCP_TLV_LENGTH_SDRES 0x02

Length Field value in SDRES TLV.

## § PHLN_LLCP_TLV_MIUX_MASK

#define PHLN_LLCP_TLV_MIUX_MASK ( 1 << 0x01 )

Mask used to set MIUX in 'bAvailableTlv' of phlnLlcp_LMDataParams_t of Local Link.

## § PHLN_LLCP_TLV_WKS_MASK

#define PHLN_LLCP_TLV_WKS_MASK ( 1 << 0x02 )

Mask used to set WKS in 'bAvailableTlv' of phlnLlcp_LMDataParams_t of Local Link.

## § PHLN_LLCP_TLV_LTO_MASK

#define PHLN_LLCP_TLV_LTO_MASK ( 1 << 0x03 )

Mask used to set LTO in 'bAvailableTlv' of phlnLlcp_LMDataParams_t of Local Link.

## § PHLN_LLCP_TLV_OPT_MASK

#define PHLN_LLCP_TLV_OPT_MASK ( 1 << 0x04 )

Mask used to set OPT in 'bAvailableTlv' of phlnLlcp_LMDataParams_t of Local Link.

## § PHLN_LLCP_TLV_VERSION_VALUE

#define PHLN_LLCP_TLV_VERSION_VALUE 0x11

Major version number is 1, Minor version number is 1.

Indicating NFCForum LLPC 1.1 Specification.

## § PHLN_LLCP_MIU

#define PHLN_LLCP_MIU 248

Maximum number of bytes in the information field of an LLC PDU that the local LLC is able to receive.

## § PHLN_LLCP_TLV_MIUX_VALUE

#define PHLN_LLCP_TLV_MIUX_VALUE (PHLN_LLCP_MIU - 128)

MIUX (Maximum Information Unit Extension) = Maximum Information Unit (MIU) - 128.

## § PHLN_LLCP_PDU_DM_DISC

#define PHLN_LLCP_PDU_DM_DISC 0x00

Indicates the Logical Link Control (LLC) has received a DISC PDU and is now logically disconnected from the data link connection.

## § PHLN_LLCP_PDU_DM_NO_CONN

#define PHLN_LLCP_PDU_DM_NO_CONN 0x01

Indicates the LLC has received a connection-oriented PDU but the target service access point has no active connection.

## § PHLN_LLCP_PDU_DM_NO_SAP

#define PHLN_LLCP_PDU_DM_NO_SAP 0x02

Indicates the remote LLC has received a CONNECT PDU and there is no service bound to the specified target service access point.

## § PHLN_LLCP_PDU_DM_CONN_REJ

#define PHLN_LLCP_PDU_DM_CONN_REJ 0x03

Indicates the remote LLC has processed a CONNECT PDU and the request to connect was rejected by the service layer.

## § PHLN_LLCP_PDU_DM_SAP_REJ

#define PHLN_LLCP_PDU_DM_SAP_REJ 0x10

Indicates the LLC will permanently not accept any CONNECT PDUs with the same target service access point address.

## § PHLN_LLCP_PDU_DM_ANY_REJ

#define PHLN_LLCP_PDU_DM_ANY_REJ 0x11

Indicates the LLC will permanently not accept any CONNECT PDUs with any target service access point address.

## § PHLN_LLCP_PDU_DM_TEMP_SAP_REJ

#define PHLN_LLCP_PDU_DM_TEMP_SAP_REJ 0x20

Indicates the LLC will temporarily not accept any CONNECT PDUs with the specified target service access point address.

## § PHLN_LLCP_PDU_DM_TEMP_ANY_REJ

#define PHLN_LLCP_PDU_DM_TEMP_ANY_REJ 0x21

Indicates the LLC will temporarily not accept any CONNECT PDUs with any target service access point address.

## Function Documentation

## § phlnLlcp_Activate()

phStatus_t phlnLlcp_Activate | ( | void * | pDataParams,
|  | uint8_t * | pRemoteGnrlBytes,
|  | uint8_t | bRemoteGnrBytesLen,
|  | uint8_t | bDevType
| ) |  |

Activates the LLCP layer link by checking General Bytes content of ATR_REQ/ATR_RES.

Posts LLCP Activation event to threads blocked for this event in a call to phlnLlcp_WaitForActivation API.
Then this API starts processing the Message Queue and signals corresponding Semaphores in the phlnLlcp_Transport_Socket_t.
socket structure to Threads blocking on specific events to occur.
Runs until:

1. Another thread calls phlnLlcp_Deactivate.
2. LLCP connection is closed by the other peer using DISC PDU.
3. LTO (Link Timeout) occurs due to peer device not in range/responding.
4. External RF Field OFF occurred if activated in Passive Target Mode.
5. Another thread calls phhalHw_AsyncAbort.
6. Any exit scenario or error from below MAC layer.
   Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_Sw_Init().
   Note: If FRMR is received on DSAP and SSAP equal to 0 or an invalid PDU is received on DSAP and SSAP equal to zero, LLCP link (DSSAP and SSAP equal to 0) is disconnected and peer need to re-establish the connection as per NFC Forum LLCP Specification 1.1, sec 5.6.4.5.

Returns
  Status code

Return values

  PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
  PH_ERR_INVALID_PARAMETER | MAC restrictions are not obeyed (Example, DID is set in ATR_REQ).
  PH_ERR_PROTOCOL_ERROR | Invalid TLV/Version mismatch/bad contents in ATR or Peer device didn't handle MAC restrictions.
  PH_ERR_PEER_DISCONNECTED | Peer Sent DISC_PDU(LSap=0,DSap=0).
  PH_ERR_LLCP_DEACTIVATED | Another task/thread calls phlnLlcp_Deactivate.
  PH_ERR_RESOURCE_ERROR | Message Queue is unavailable or OSAL returned error.
  PH_ERR_LLCP_PDU_FRMR | Received FRMR on LSAP = 0 and RSAP = 0 received from remote peer, MAC link de-activation procedure will not be done by LLCP.
  PH_ERR_LLCP_PDU_INVALID | Received Invalid PDU over LSAP = 0 and RSAP = 0 or received AGF on LSAP and RSAP other than zero, MAC link de-activation procedure will not be done by LLCP.
  PH_ERR_EXT_RF_ERROR | External RF Field OFF from HAL.
  PH_ERR_ABORTED | Peer Device did not respond for LTO time or when User aborts by calling phhalHw_AsyncAbort. This code is pre-pended with HAL Component code.
  PH_ERR_USE_CONDITION | If underlying MAC Components are not part of Build.
  Other | Depending on underlying component.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pRemoteGnrlBytes | Pointer to remote general bytes received in ATR REQ/RES.
  [in] | bRemoteGnrBytesLen | Length of general bytes received in ATR REQ/RES.
  [in] | bDevType | Device type PHLN_LLCP_INITIATOR or PHLN_LLCP_TARGET.

## § phlnLlcp_Deactivate()

phStatus_t phlnLlcp_Deactivate | ( | void * | pDataParams | ) |

Deactivate the LLCP layer link.

This API should be called from different thread which will post DISC PDU (with LSAP = 0 and RSAP = 0) to Message Queue.
This message is dequeued by the phlnLlcp_Activate API which is running in the Reader Library Thread.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
  PH_ERR_RESOURCE_ERROR | Message Queue is unavailable or OSAL returned error.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.

## § phlnLlcp_WaitForActivation()

phStatus_t phlnLlcp_WaitForActivation | ( | void * | pDataParams | ) |

Wait for LLCP Activation Event from Reader Library Thread.

This should be the first API called by Server/Client Thread before calling any other API. This will wait on LLCP Activated Event which will
be posted by the phlnLlcp_Activate API once LLCP Link is established after Link Activation Procedure as defined in NFCForum LLCP 1.1 specification section 5.2.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
  PH_ERR_IO_TIMEOUT | No LLCP Activate Event detected and Timeout occurred.
  PH_ERR_RESOURCE_ERROR | Message Queue is unavailable or OSAL returned error.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.

## § phlnLlcp_Transport_Socket_Init()

phStatus_t phlnLlcp_Transport_Socket_Init | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | psSocket,
|  | phlnLlcp_Transport_Socket_Type_t | eSocketType,
|  | uint8_t * | pSocketRxBuffer,
|  | uint32_t | dwSocketRxBufferSize
| ) |  |

Initializes a new socket.

Socket type is one of:

- PHLN_LLCP_TRANSPORT_CONNECTIONLESS
- PHLN_LLCP_TRANSPORT_SERVER_CONNECTIONORIENTED
- PHLN_LLCP_TRANSPORT_CLIENT_CONNECTIONORIENTED
  Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID
     PH_ERR_INVALID_PARAMETER | Invalid input parameters.
     PH_ERR_RESOURCE_ERROR | Message Queue is unavailable or OSAL returned error.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | psSocket | Pointer to Socket allocated by the Application.
  [in] | eSocketType | Type of Socket to be Initialized, indicating the End Point.
  [in] | pSocketRxBuffer | Pointer to Rx Buffer allocated by the Application to corresponding Socket.
  [in] | dwSocketRxBufferSize | Length of the Rx Buffer.

## § phlnLlcp_Transport_Socket_Register()

phStatus_t phlnLlcp_Transport_Socket_Register | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | pSocket,
|  | phlnLlcp_Transport_Socket_Type_t | eSocketType,
|  | uint8_t | bLsap,
|  | uint8_t * | pUri
| ) |  |

Register a socket at the SAP manager.

If Socket type is Connection-oriented server, bLsap and/or pUri have to be provided.
If Socket type is Connection-oriented client, ignores bLsap and pUri parameter but a random SAP will be generated and assigned to the Socket.
If Socket type is Connection-less, bLsap and/or pUri parameters have to be provided.
If this API is called before event is posted by phlnLlcp_Activate or while main LLCP task is performing phlnLlcp_DeInit, then PH_ERR_LLCP_SOCKET_REGISTER_FAILED will be returned.

Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init()
   NOTE: bLsap value should not be '0' or '1' as these are reserved SAP used internally by LLCP.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
  PH_ERR_INVALID_PARAMETER | Invalid input parameters.
  PH_ERR_LLCP_SAP_EXCEEDED | Exceeded available number of Client SAPs that can be registered.
  PH_ERR_LLCP_SOCKET_REGISTERED | Socket is already registered with SAP Manager.
  PH_ERR_LLCP_SOCKET_REGISTER_FAILED | Socket cannot be registered as LLCP is not active or some other registered socket is associated with the passed Lsap value.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pSocket | Pointer of Socket to be Registered.
  [in] | eSocketType | Type Socket to be used.
  [in] | bLsap | Local SAP address.
  [in] | pUri | Pointer of Uniform Resource Identifier (URI). NULL terminated URI string should be provided.

## § phlnLlcp_Transport_Socket_WaitForConnection()

phStatus_t phlnLlcp_Transport_Socket_WaitForConnection | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | pServerSocket,
|  | phlnLlcp_Transport_Socket_t * | pConnServerSocket
| ) |  |

WaitForConnection is a Blocking call used by a Connection-oriented Server socket waiting for an incoming client connection on the registered pServerSocket.

pConnServerSocket is an Initialized but not Registered socket. It will be filled with the remote/connected Client information once a remote socket has established a connection.
pConnServerSocket socket has to be used then for further communication (send/receive).
NOTE: If pConnServerSocket is NULL then pServerSocket is used for further communication with the connected Remote Client and no further clients can establish connection with the Server.
If pConnServerSocket is a valid Initialized socket then once a connection with Remote Client is established, a new thread needs to be created by the Application to continue
communication with the Connected Remote Client and the current thread can listen for a new Client Connection over next Initialized pConnServerSocket socket.
Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init() with pServerSocket
3. phlnLlcp_Transport_Socket_Register() with pServerSocket
4. phlnLlcp_Transport_Socket_Init() with pConnServerSocket
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
     PH_ERR_INVALID_PARAMETER | Invalid input parameters.
     PH_ERR_RESOURCE_ERROR | OSAL returned error.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pServerSocket | Pointer of Server socket.
  [in] | pConnServerSocket | Pointer of Connection Server socket.

## § phlnLlcp_Transport_Socket_Connect()

phStatus_t phlnLlcp_Transport_Socket_Connect | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | pClientSocket,
|  | uint8_t | bDsap
| ) |  |

Connect is a Blocking call used by a Connection-oriented client socket to connect to a remote server with a DSAP given with bDsap.

This API will post Connect PDU to Message Queue, phlnLlcp_Activate API will send this PDU to remote peer.
Waits until CC PDU is received and Semaphore is signaled by the phlnLlcp_Activate.
Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init() with pClientSocket
3. phlnLlcp_Transport_Socket_Register() with pClientSocket
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
     PH_ERR_INVALID_PARAMETER | Invalid input parameters.
     PH_ERR_RESOURCE_ERROR | OSAL returned error.
     PH_ERR_LLCP_PDU_INFO_PER | PDU with an information field that is not permitted.
     PH_ERR_LLCP_DEACTIVATED | Connect was not successful, received DM PDU as selected server using Destination SAP does not exist on Remote Peer.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pClientSocket | Pointer of Client socket.
  [in] | bDsap | Address of Destination SAP to which Client has to connect.

## § phlnLlcp_Transport_Socket_ConnectViaUri()

phStatus_t phlnLlcp_Transport_Socket_ConnectViaUri | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | pClientSocket,
|  | uint8_t * | pUri
| ) |  |

ConnectViaUri is a Blocking call used by a Connection-oriented client socket to connect to a remote server with a Uniform Resource Identifier (URI) given with pUri.

This API will post Connect PDU to Message Queue, phlnLlcp_Activate API will send this PDU to remote peer.
Waits until CC PDU is received and Semaphore is signaled by the phlnLlcp_Activate.
Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init() with pClientSocket
3. phlnLlcp_Transport_Socket_Register() with pClientSocket
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
     PH_ERR_INVALID_PARAMETER | Invalid input parameters.
     PH_ERR_RESOURCE_ERROR | OSAL returned error.
     PH_ERR_LLCP_PDU_INFO_PER | PDU with an information field that is not permitted.
     PH_ERR_LLCP_DEACTIVATED | Connect was not successful, received DM PDU as selected server using Destination SAP does not exist on Remote Peer.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pClientSocket | Pointer of Client socket.
  [in] | pUri | Pointer to URI of Destination SAP to which Client has to connect. NULL terminated URI string should be provided.

## § phlnLlcp_Transport_Socket_Receive()

phStatus_t phlnLlcp_Transport_Socket_Receive | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | psSocket
| ) |  |

Receive is a Blocking call used to receive data on a socket.

Can be used by any socket type. Function blocks until dwRxBufferSize bytes have been received or an error occurred.
Once Data is received on the Socket, User need to set 'fReady' flag of the respective Socket to 'True' in-order to receive next Packet. If the fReady flag is not True then the Link Management will send Receiver Not Ready (RNR) PDU to the remote SAP if it receives an Information PDU for this end point.

Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init() with pServerSocket
3. phlnLlcp_Transport_Socket_Register() with pServerSocket
4. phlnLlcp_Transport_Socket_Init() with pConnServerSocket
5. phlnLlcp_Transport_Socket_WaitForConnection()
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
     PH_ERR_INVALID_PARAMETER | Invalid input parameters.
     PH_ERR_RESOURCE_ERROR | OSAL returned error.
     PH_ERR_PEER_DISCONNECTED | Peer sent DISC PDU over Socket Link.
     PH_ERR_LLCP_DEACTIVATED | Local LLC shut down.
     PH_ERR_LLCP_PDU_TX_SEQ_ERR | Received Information PDU (I-PDU) with Sequence error.
     PH_ERR_LLCP_PDU_INFO_ERR | Received Information length is greater than MIU.
     PH_ERR_LLCP_PDU_INVALID | Invalid PDU received.
     PH_ERR_LLCP_PDU_INFO_PER | PDU with an information field that is not permitted.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | psSocket | Pointer of the socket.

## § phlnLlcp_Transport_Socket_Send()

phStatus_t phlnLlcp_Transport_Socket_Send | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | pClientSocket,
|  | uint8_t * | pTxBuffer,
|  | uint32_t | dwTxBufferSize,
|  | uint16_t | wFrameOpt
| ) |  |

Send is a Blocking call used to send data on a Connection-oriented socket.

Function blocks until complete buffer has been sent out and a RR PDU is received by phlnLlcp_Activate which will signal the Semaphore.
wOption can be one of:

- PH_TRANSMIT_DEFAULT

wOption can be combined with:

- PH_TRANSMIT_BUFFERED_BIT
- PH_TRANSMIT_LEAVE_BUFFER_BIT

Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init()
3. phlnLlcp_Transport_Socket_Register()
4. phlnLlcp_Transport_Socket_Connect()
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_SUCCESS_INFO_RECEIVED | Received I-PDU in response to I-PDU. phlnLlcp_Transport_Socket_Receive need not be called to Receive next Packet as Socket Buffer already contains the received Data.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
     PH_ERR_INVALID_PARAMETER | Invalid input parameters.
     PH_ERR_UNSUPPORTED_COMMAND | In-case Socket is other than PHLN_LLCP_TRANSPORT_SERVER_CONNECTIONORIENTED or PHLN_LLCP_TRANSPORT_CLIENT_CONNECTIONORIENTED Socket Type.
     PH_ERR_RESOURCE_ERROR | OSAL returned error.
     PH_ERR_TX_NAK_ERROR | Received RNR PDU as Remote LLCP is busy. Application can Re-send once again if required.
     PH_ERR_PEER_DISCONNECTED | Received DISC PDU from the Remote LLCP.
     PH_ERR_LLCP_DEACTIVATED | Local LLC shut down.
     PH_ERR_LLCP_PDU_RX_SEQ_ERR | Received RR/RNR PDU with sequence error.
     PH_ERR_LLCP_PDU_INFO_PER | PDU with an information field that is not permitted.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pClientSocket | Pointer of Client Socket.
  [in] | pTxBuffer | Pointer of Buffer to be Transmitted.
  [in] | dwTxBufferSize | Length of the Buffer to be Transmitted.
  [in] | wFrameOpt | Option parameter.

## § phlnLlcp_Transport_Socket_DiscoverServices()

phStatus_t phlnLlcp_Transport_Socket_DiscoverServices | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | pSocket,
|  | uint8_t | bNumber,
|  | uint8_t | bSNBuffSize,
|  | uint8_t * | psServiceNameList,
|  | uint8_t * | pSapList
| ) |  |

Get SAP of remote services using their URIs (Uniform Resource Identifier).

This function sends SDP queries to the remote peer to get the SAP address for a given service name. The queries are sent in a single LLC packet. If list of URI's cannot fit into single packet then this API needs to be called multiple times. Only one task can call this API at a time. If this API is called by different tasks simultaneously then PH_ERR_USE_CONDITION error will be returned. As mentioned in LLCP specification, a SAP of 0 means that the service name has not been found which is indicated in the parameter pnSapList.

Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init()
3. phlnLlcp_Transport_Socket_Register()
4. phlnLlcp_Transport_Socket_DiscoverServices()
5. phlnLlcp_Transport_Socket_Connect() can be called with the Discovery SAP.

Returns
  Status code

Return values

  PH_ERR_SUCCESS | Operation successful.
  PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
  PH_ERR_INVALID_PARAMETER | Invalid input parameters.
  PH_ERR_RESOURCE_ERROR | OSAL returned error.
  PH_ERR_PEER_DISCONNECTED | Received DISC PDU from the Remote LLCP.
  PH_ERR_LLCP_DEACTIVATED | Local LLC shut down.
  PH_ERR_USE_CONDITION | More than one client has simultaneously called this API.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pSocket | Pointer of Socket.
  [in] | bNumber | Number of Service Names and SAP list.
  [in] | bSNBuffSize | Length of Service Name (SN) Buffer Size containing Length and String of URI.
  [in] | psServiceNameList | The list of the Service names to discover. First Byte contains length of SN followed by respective SN Bytes. Followed by next SN Length.
  [out] | pSapList | The list of the corresponding SAP numbers (one byte each), in the same order as the service names list.

## § phlnLlcp_Transport_Socket_SendTo()

phStatus_t phlnLlcp_Transport_Socket_SendTo | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | pClientSocket,
|  | uint8_t | bDsap,
|  | uint8_t * | pTxBuffer,
|  | uint32_t | dwTxBufferSize,
|  | uint16_t | wFrameOpt
| ) |  |

SendTo is a used to send data on a Connection-less socket.

Sends data to a remote socket on DSAP Address using bDsap parameter. Delivery of data is not guaranteed. Function blocks until the UI PDU is transmitted by the main LLCP task.
wOption can be one of:

- PH_TRANSMIT_DEFAULT

wOption can be combined with:

- PH_TRANSMIT_BUFFERED_BIT
- PH_TRANSMIT_LEAVE_BUFFER_BIT

Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init()
3. phlnLlcp_Transport_Socket_Register()
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
     PH_ERR_INVALID_PARAMETER | Invalid input parameters.
     PH_ERR_UNSUPPORTED_COMMAND | In-case Socket is other than PHLN_LLCP_TRANSPORT_CONNECTIONLESS Socket Type.
     PH_ERR_RESOURCE_ERROR | Message Queue is unavailable or OSAL returned error.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pClientSocket | Pointer of Client Socket.
  [in] | bDsap | Destination SAP to which Data needs to be sent.
  [in] | pTxBuffer | Pointer of Buffer to be Transmitted.
  [in] | dwTxBufferSize | Length of the Buffer to be Transmitted.
  [in] | wFrameOpt | Option parameter.

## § phlnLlcp_Transport_Socket_Disconnect()

phStatus_t phlnLlcp_Transport_Socket_Disconnect | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | pClientSocket
| ) |  |

Disconnect is a Blocking call used to close a Connection-oriented socket and its related data link.

This API will post DISC PDU to Message Queue with respective Local SAP and Remote SAP, phlnLlcp_Activate API will send this PDU to remote peer.
Waits until DM PDU is received and Semaphore is signaled by the phlnLlcp_Activate.
Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init()
3. phlnLlcp_Transport_Socket_Register()
4. phlnLlcp_Transport_Socket_Connect()
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
     PH_ERR_INVALID_PARAMETER | Invalid input parameters.
     PH_ERR_RESOURCE_ERROR | OSAL returned error.
     PH_ERR_LLCP_DEACTIVATED | Local LLC shut down.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pClientSocket | Pointer of Client Socket.

## § phlnLlcp_Transport_Socket_Unregister()

phStatus_t phlnLlcp_Transport_Socket_Unregister | ( | void * | pDataParams,
|  | phlnLlcp_Transport_Socket_t * | pSocket
| ) |  |

Unregister a socket from the SAP Manager.

This API needs to be called on all the Initialized sockets to deallocate Semaphores allocated to it by the respective Threads even in case of Error scenarios.
If a socket is Registered with SAP then this API will De-Register with the SAP Manager.

- Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_WaitForActivation()
2. phlnLlcp_Transport_Socket_Init()
3. phlnLlcp_Transport_Socket_Register()
4. phlnLlcp_Transport_Socket_Connect() or phlnLlcp_Transport_Socket_WaitForConnection()
5. phlnLlcp_Transport_Socket_Send() or phlnLlcp_Transport_Socket_Receive()
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
     PH_ERR_INVALID_PARAMETER | Invalid input parameters.

Parameters

  [in] | pDataParams | Pointer to this layer's parameter structure.
  [in] | pSocket | Pointer of Socket to be Unregistered.

## § phlnLlcp_DeInit()

phStatus_t phlnLlcp_DeInit | ( | void * | pDataParams | ) |

DeInit is used to release all the acquired resources and reset internal parameters of LLCP.

This API should be called immediately after phlnLlcp_Activate API, irrespective of the return status.
Sequence of functions that needs to be called prior to this API are as below:

1. phlnLlcp_Sw_Init().
2. phlnLlcp_Activate().
   Returns
     Status code
   Return values

     PH_ERR_SUCCESS | Operation successful.
     PH_ERR_INVALID_DATA_PARAMS | Invalid Component ID.
     Other | Depending on underlying component.