MATRIX-Lite-NFC-Py
MATRIX Lite NFC Py is a package that allows users of varying skill levels to easily program NFC with their MATRIX Creator.
Smartphone Apps For Debugging
Roadmap
- Reading Info (All tags)
- Reading Pages (MIFARE Ultralight & NTAG)
- Writing Page (MIFARE Ultralight & NTAG)
- Reading NDEF (MIFARE Ultralight & NTAG)
- Writing NDEF (MIFARE Ultralight & NTAG)
Installation
1. Install MATRIX HAL NFC
https://github.com/matrix-io/matrix-hal-nfc
2. Install PIP3
To call your scripts with python 3, use
python3 YOUR_SCRIPT.py
sudo apt-get install python3-pip
3. Upgrade PIP
python3 -m pip install --upgrade pip
4. Install matrix-lite-nfc-py
sudo python3 -m pip install matrix-lite-nfc
Reference
Import Statement
import matrix_lite_nfc as nfc
nfc.status
When a read or write function completes, it will contain a status code to indicate the result. nfc.Status returns a string of what that number means.
nfc.status(/*number*/)
nfc.read
There can only be one instance of NFC reading. This is a hardware limitation that will not change.
Synchronous Read
A simple read that returns an object with tag data.
nfc.read.scan({
# At least 1 read options is required. Less options -> faster reading!
"info": True, # Generic information for any NFC tag
"pages": True, # All page data
"ndef": True, # A single page(faster than pages)
"page": 0, # All NDEF data
})
Starting Read Loop
A non-blocking loop that passes tag data to a callback.
def read_callback(tag):
if(tag.status == 256):
print("NFC Tag Scanned!")
print(tag)
elif(tag.status == 1024):
print("Nothing Scanned!")
# Configure what you want to read
nfc.read.start({
"rate": 0.5, # Read loop speed (Seconds)
"info": True,
"pages": True,
"ndef": True,
"page": 0,
}, read_callback)
Stopping Read Loop
nfc.read.stop()
nfc.Message
1. Creating a new NDEF Message
# Create an empty NDEF message
msg = nfc.Message()
# Add NDEF Records to message
msg.addUriRecord("https://community.matrix.one")
msg.addUriRecord("tel:+14085551212")
msg.addTextRecord("Hello World")
msg.addTextRecord("Hola Mundo", "es")
msg.addMimeMediaRecord("text/json", '{"answer": 42}')
# You then pass msg into nfc.write.message(msg)
2. Reading a new NDEF Message
# Get NDEF data from scanned tag
tag = nfc.read.scan({"ndef": True})
# Create & print NDEF message
msg = nfc.Message(tag.ndef.content)
print(msg.getRecords())
nfc.write
Writing to an NFC tag should normally be done inside the read loop.
Writing an NDEF message
# Create new message
msg = nfc.Message()
msg.addUriRecord("https://community.matrix.one")
# Write and then Print status codes for activation & writing
print(nfc.write.message(msg))
Erasing an NDEF message
print(nfc.write.erase())
Writing to a tag's page (WARNING)
Be careful when writing to a page. You can accidentally lock your NFC tag!
# arg1: page you want to overwrite
# arg2: Array of numbers that represents a byte
print(nfc.write.page(25, [48,45,59,21]))
Building Locally For Development
Download the repository.
git clone https://github.com/matrix-io/matrix-lite-nfc-py
Install pybind11.
sudo python3 -m pip install pybind11
Compile and install library.
sudo python3 -m pip install ./matrix-lite-nfc-py
Test your changes by importing any of the following libraries into a .py file.
# Direct C++ bindings
import _matrix_hal_nfc as hal_nfc
# Abstractions to _matrix_hal_nfc
import matrix_lite_nfc as nfc
Metadata
Release files for matrix-lite-nfc 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| matrix_lite_nfc-0.0.2.tar.gz | 10.7 kB | Without provenance | Details for matrix_lite_nfc-0.0.2.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| matrix_lite_nfc-0.0.2-cp37-cp37m-linux_armv7l.whl | CPython 3.7 | CPython 3.7 pymalloc | linux armv7l | Details for matrix_lite_nfc-0.0.2-cp37-cp37m-linux_armv7l.whl |
| matrix_lite_nfc-0.0.2-cp37-cp37m-linux_armv6l.whl | CPython 3.7 | CPython 3.7 pymalloc | linux armv6l | Details for matrix_lite_nfc-0.0.2-cp37-cp37m-linux_armv6l.whl |
| matrix_lite_nfc-0.0.2-cp35-cp35m-linux_armv7l.whl | CPython 3.5 | CPython 3.5 pymalloc | linux armv7l | Details for matrix_lite_nfc-0.0.2-cp35-cp35m-linux_armv7l.whl |
| matrix_lite_nfc-0.0.2-cp35-cp35m-linux_armv6l.whl | CPython 3.5 | CPython 3.5 pymalloc | linux armv6l | Details for matrix_lite_nfc-0.0.2-cp35-cp35m-linux_armv6l.whl |
Total release size: 14.7 MB
Release files / matrix_lite_nfc-0.0.2.tar.gz
| Download URL | matrix_lite_nfc-0.0.2.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ada29587661a07e51f3094d6cae081979502133eee35de21903ecb75dd17bd73
|
|
BLAKE2b-256 checksum How to use checksums |
489eeac4ae5ddf3d5c73c8b8ac131b32e0ae4a9791a88104dc47d1143eb6a68b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8
|
Release files / matrix_lite_nfc-0.0.2-cp37-cp37m-linux_armv7l.whl
| Download URL | matrix_lite_nfc-0.0.2-cp37-cp37m-linux_armv7l.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc linux armv7l |
|
SHA-256 checksum How to use checksums |
ea5327a22e9e26a68102c1fd4558c20cbfca58e1865829b5b28f8e0d2d5df469
|
|
BLAKE2b-256 checksum How to use checksums |
a12a2f28a2732bd07f622b03cbea3e44942529d9e3de81079e8af1afcc7a43f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8
|
Release files / matrix_lite_nfc-0.0.2-cp37-cp37m-linux_armv6l.whl
| Download URL | matrix_lite_nfc-0.0.2-cp37-cp37m-linux_armv6l.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc linux armv6l |
|
SHA-256 checksum How to use checksums |
11fae9fc8efa33e699e453ef6b5075a2f9e79677a6769302da0471dfe0164f86
|
|
BLAKE2b-256 checksum How to use checksums |
82a247643d19699e8e1d3e8fcb16c17a7c62cb21b2d5f613d4f41bb49fdf2531
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8
|
Release files / matrix_lite_nfc-0.0.2-cp35-cp35m-linux_armv7l.whl
| Download URL | matrix_lite_nfc-0.0.2-cp35-cp35m-linux_armv7l.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc linux armv7l |
|
SHA-256 checksum How to use checksums |
931b5aa4c141443335123a87a01d19ee15ea8a69d8e74fb901474421b8a4fa0c
|
|
BLAKE2b-256 checksum How to use checksums |
8ae6e5a59da5de86cf99c33bcf28ba6b9f1d4b0df7e0c952d6c89465498c4379
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8
|
Release files / matrix_lite_nfc-0.0.2-cp35-cp35m-linux_armv6l.whl
| Download URL | matrix_lite_nfc-0.0.2-cp35-cp35m-linux_armv6l.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc linux armv6l |
|
SHA-256 checksum How to use checksums |
a876561425980e6adc0849d3b609d34f2425674347f55dba5c91ce3a99758421
|
|
BLAKE2b-256 checksum How to use checksums |
809b0effc4cb5506f4aeb05f7bf2c392d4c66be13bef6d8b74edf328ff067eec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8
|
Security for matrix-lite-nfc 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.