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 for the service name bound at the remote device. The address value 0 indicates that the remote device does not have a service with the requested name. The address value 1 indicates that the remote device has a data link connection service with the requested name that can only be connected by service name. The return value is None when communication with the peer device terminated while waiting for a response.
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. A false value is typically an indication that the socket or connection was closed.
sendto(data, addr, flags=0)¶
Send data to the socket. The socket should not be connected to a remote socket, since the destination socket is specified by addr. 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 bytes object 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 (bytes, 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. Posssible event values are the strings “recv”, “send” and “acks”. Whent the timeout is present and not
None, it should be a floating point number specifying the timeout for the operation in seconds (or fractions thereof). For “recv” or “send” the
Trueif a next
send()operation would be non-blocking. The “acks” event may only be used with a data-link-connection type socket; the call then returns
Trueif the counter of received acknowledgements was greater than zero and decrements the counter by one.
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).