Registry / iot / ndeflib

ndeflib

JSON →
library0.3.3pypypi✓ verified 79d ago

NFC Data Exchange Format (NDEF) decoder and encoder for Python. Version 0.3.3, low release cadence. Supports creation, parsing, and serialization of NDEF messages used in NFC tags and peer-to-peer communication.

pip install ndeflib
INSTALL
IMPORT
SIG · NDEFLIB
N
ndeflib
iotpythonv0.3.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Record
from ndef import Record
from ndef import Message
TextRecord
from ndef import TextRecord
UriRecord
from ndef import UriRecord

Create an NDEF message with a text record, encode to bytes, then decode back.

from ndef import Message, Record, make_text_record # Create a text record record = make_text_record('Hello, NFC!', encoding='utf-8') # Create a message with the record message = Message(record) # Encode to bytes encoded = message.to_bytes() print('Encoded:', encoded.hex()) # Decode from bytes decoded = Message.from_bytes(encoded) for record in decoded: print('Record type:', record.type) print('Record payload:', record.data)
Debug
Known issues
gotchaThe package provides a high-level 'ndef' module, not 'ndeflib'. Importing 'ndeflib' directly gives you a different namespace with lower-level helpers.
fix
Use 'import ndef' or 'from ndef import ...' instead of 'import ndeflib'.
affects: all
deprecatedThe 'make_tnf_method' function in ndeflib is deprecated. Use create_record_with_type instead.
fix
Use create_record_with_type from ndef.rec tools or use ndef.make functions.
affects: 0.3.x
breakingIn version 0.3.0, the Message class changed from a list subclass to a custom sequence. Iterating over Message still works, but direct indexing may return different types.
fix
Use 'for record in message:' or convert to list with list(message).
affects: 0.3.0+
gotchaRecord.data might be bytes or str depending on type. Text records decode payload to str only if encoding is known.
fix
Check record.type and handle payload accordingly. Use record.data.decode('utf-8') for text records if needed.
affects: all
Upgrade
Version history
0.3.3latest on PyPI · released May 27, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
26 hits · last 30 days
node
22
Resources
ndeflib — pip install ndeflib · libregistry