nfc.snep¶
The nfc.snep module implements the NFC Forum Simple NDEF Exchange Protocol (SNEP) specification and provides a server and client class for applications to easily send or receive SNEP messages.
nfc.snep.SnepServer¶
-
class
nfc.snep.
SnepServer
(llc, service_name='urn:nfc:sn:snep', max_acceptable_length=1048576, recv_miu=1984, recv_buf=15)¶ Bases:
threading.Thread
NFC Forum Simple NDEF Exchange Protocol server
-
process_get_request
(ndef_message)¶ Handle Get requests. This method should be overwritten by a subclass of SnepServer to customize it’s behavior. The default implementation simply returns nfc.snep.NotImplemented.
-
process_put_request
(ndef_message)¶ Process a SNEP Put request. This method should be overwritten by a subclass of SnepServer to customize it’s behavior. The default implementation simply returns nfc.snep.Success.
-
nfc.snep.SnepClient¶
-
class
nfc.snep.
SnepClient
(llc, max_ndef_msg_recv_size=1024)¶ Bases:
object
Simple NDEF exchange protocol - client implementation
-
connect
(service_name)¶ Connect to a SNEP server. This needs only be called to connect to a server other than the Default SNEP Server at
urn:nfc:sn:snep
or if the client wants to send multiple requests with a single connection.
-
close
()¶ Close the data link connection with the SNEP server.
-
get_records
(records=None, timeout=1.0)¶ Get NDEF message records from a SNEP Server.
New in version 0.13.
The
ndef.Record
list given by records is encoded as the request message octets input toget_octets()
. The return value is anndef.Record
list decoded from the response message octets returned byget_octets()
. Same as:import ndef send_octets = ndef.message_encoder(records) rcvd_octets = snep_client.get_octets(send_octets, timeout) records = list(ndef.message_decoder(rcvd_octets))
-
get_octets
(octets=None, timeout=1.0)¶ Get NDEF message octets from a SNEP Server.
New in version 0.13.
If the client has not yet a data link connection with a SNEP Server, it temporarily connects to the default SNEP Server, sends the message octets, disconnects after the server response, and returns the received message octets.
-
put_records
(records, timeout=1.0)¶ Send NDEF message records to a SNEP Server.
New in version 0.13.
The
ndef.Record
list given by records is encoded and then send viaput_octets()
. Same as:import ndef octets = ndef.message_encoder(records) snep_client.put_octets(octets, timeout)
-
put_octets
(octets, timeout=1.0)¶ Send NDEF message octets to a SNEP Server.
New in version 0.13.
If the client has not yet a data link connection with a SNEP Server, it temporarily connects to the default SNEP Server, sends the message octets and disconnects after the server response.
-