The nfc.llcp module implements the NFC Forum Logical Link Control Protocol (LLCP) specification and provides a socket interface to use the connection-less and connection-mode transport facilities of LLCP.
Create a new LLCP socket with the given socket type. The socket type should be one of:
nfc.llcp.LOGICAL_DATA_LINKfor best-effort communication using LLCP connection-less PDU exchange
nfc.llcp.DATA_LINK_CONNECTIONfor reliable communication using LLCP connection-mode PDU exchange
nfc.llcp.llc.RAW_ACCESS_POINTfor unregulated LLCP PDU exchange (useful to implement test programs)
LogicalLinkControllerinstance to which this socket belongs. This attribute is read-only.
Resolve a service name into an address. This may involve conversation with the remote service discovery component if the name is hasn’t yet been resolved. The return value is the service access point address that the service name is bound to at the remote device. A zero address indicates that the remote device does not know about the service name requested. The return value is None if communication with the peer device got terminated.
Set the value of the given socket option and return the current value which may have been corrected if it was out of bounds.
Return the value of the given socket option.
Bind the socket to address. The socket must not already be bound. The address may be a service name string, a service access point number, or it may be omitted. If address is a well-known service name the socket will be bound to the corresponding service access point address, otherwise the socket will be bound to the next available service access point address between 16 and 31 (inclusively). If address is a number between 32 and 63 (inclusively) the socket will be bound to that service access point address. If the address argument is omitted the socket will be bound to the next available service access point address between 32 and 63.
Connect to a remote socket at address. Address may be a service name string or a service access point number.
Mark a socket as a socket that will be used to accept incoming connection requests using accept(). The backlog defines the maximum length to which the queue of pending connections for the socket may grow. A backlog of zero disables queuing of connection requests.
Accept a connection. The socket must be bound to an address and listening for connections. The return value is a new socket object usable to send and receive data on the connection.
Send data to the socket. The socket must be connected to a remote socket. Returns a boolean value that indicates success or failure. Failure to send is generally an indication that the socket or connection was closed.
Send data to the socket. The socket should not be connected to a remote socket, since the destination socket is specified by address. Returns a boolean value that indicates success or failure. Failure to send is generally an indication that the socket was closed.
Receive data from the socket. The return value is a string representing the data received. The maximum amount of data that may be returned is determined by the link or connection maximum information unit size.
Receive data from the socket. The return value is a pair (string, address) where string is a string representing the data received and address is the address of the socket sending the data.
Wait for a socket event.
Obtain the address to which the socket is bound. For an unbound socket the returned value is None.
Obtain the address of the peer connected on the socket. For an unconnected socket the returned value is None.
Close the socket. All future operations on the socket object will fail. The remote end will receive no more data Sockets are automatically closed when the logical link controller terminates (gracefully or by link disruption). A connection-mode socket will attempt to disconnect the data link connection (if in connected state).