npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@matrix-io/matrix-lite-nfc

v0.0.2

Published

> Read and Write to NFC tags with a MATRIX Creator!

Downloads

4

Readme

MATRIX-Lite-NFC-JS

MATRIX Lite NFC JS is an npm package that allows users of varying skill levels to easily program NFC with their MATRIX Creator.

Smartphone Apps For Debugging

Roadmap

  • [x] Reading Info (All tags)
  • [x] Reading Pages (MIFARE Ultralight & NTAG)
  • [x] Writing Page (MIFARE Ultralight & NTAG)
  • [x] Reading NDEF (MIFARE Ultralight & NTAG)
  • [x] Writing NDEF (MIFARE Ultralight & NTAG)

Installation

  1. Install matrix-hal-nfc to use this library.

  2. Download and install the latest version of Node.js, using nvm (Node Version Manager)

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
. ~/.bashrc
nvm install node

mkdir myApp
cd myApp
npm init -y
  1. Install matrix-lite-nfc-js
npm install @matrix-io/matrix-lite-nfc --save

Examples

View the examples folder!

Reference

Import Statement

const nfc = require("@matrix-io/matrix-lite-nfc");

nfc.status

When a read or write function completes, it will return 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.

Starting Read Loop

// Configure what you want to read
let options = {
    rate: 100,   // Read loop speed (Milliseconds)
    // At least 1 read options is required. Less options -> faster reading!
    info: true,  // Generic information for any NFC tag
    pages: true, // All page data
    page: 0,     // A single page(faster than pages)
    ndef: true   // All NDEF data
}

// Start the loop
nfc.read.start(options, (code, tag) => {
    // code: NFC activation status
    // tag : Object with requested NFC data
});

Stopping Read Loop

nfc.read.stop();

nfc.message

An NFC constructor that represents an NDEF message. There are 2 uses for this class.

1. Creating a new NDEF Message

// Create an empty NDEF message
let msg = new 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 an existing NDEF Message

nfc.read.start({ndef:true}, (code, tag) => {
    // You can create a new NDEF message from a scanned tag.
    msg = new nfc.message(tag.ndef.content);

    // Once created, you can read any known NDEF record.
    console.log(msg.getRecords());
    // or
    console.log(msg.getRecord(0));

    // You see the number of records with
    // msg.getRecordCount();
});

nfc.write

Writing to an NFC tag should normally be done inside the read loop.

Writing an NDEF message

let msg = new nfc.message();
msg.addUriRecord("https://community.matrix.one");

nfc.write.message(msg).then((codes)=>{
    // codes.activation : NFC activation status
    // codes.write      : NFC write status
});

Erasing an NDEF message

nfc.write.erase().then((codes)=>{
    // codes.activation : NFC activation status
    // codes.write      : NFC write status
});

Writing to a tag's page (WARNING)

Be careful when writing to a page. You can accidentally lock your NFC tag!

let page_index = 25;            // page you want to overwrite
let page_byte = [48,45,59,21];  // Array of numbers that represents a byte

nfc.write.page(page_index, page_byte).then((code)=>{
    // codes.activation : NFC activation status
    // codes.write      : NFC write status
});

Building Locally For Development

Download the repository.

git clone https://github.com/matrix-io/matrix-lite-nfc-js

Install all dependencies.

npm install

You can now import the module into any .js file.

const nfc = require("./PATH_TO_NFC_JS");

Use the following command when you need to compile any new C++ changes.

npm run build