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

@taptrack/tappy-type4family

v1.1.0

Published

Type 4 command family for TCMP Tappies

Downloads

5

Readme

Tappy Communication Messaging Protocol (TCMP) commany family for commands and responses that specifically interact with Type 4 tags.

Installation

Bower

bower install tappy-type4family

NPM

npm install @taptrack/tappy-type4family

Commands

var Type4Family = require('tappy-type4family');
var Commands = Type4Family.Commands;

// Send an Application Protocol Data Unit (APDU) 
// to a Type 4 tag
var cmd = new Commands.TransceiveApdu(apdu)

// Request that the Tappy poll for a Type 4 tag using
// Type B modulation
cmd = new Commands.DetectType4B(timeout)

// Request that the Tappy poll for a Type 4 tag using Type B 
// modulation and having a specific Application Family Idefntifer (AFI)
cmd = new Commands.DetectType4BSpecificAfi(timeout, afi)

// Request that the Tappy poll for a Type 4 tag using 
// Type A modulation
cmd = new Commands.DetectType4(timeout)

// Request that the Tappy report the version of the 
// Type 4 family that it supports
cmd = new Commands.GetLibraryVersion()

Responses

Note, you should only manually construct responses as below for testing purposes. in practise, please use the resolver described later to convert raw tcmp messages received from the tappy into their corresponding concrete response types with the payloads parsed appropriately.

var Type4Family = require('tappy-type4family');
var Responses = Type4Family.Responses;

// the tag was successfully sent an APDU and replied
var apduResp = new Responses.ApduTransceiveSuccessful();
// retrieve the apdu the tag responded with
apduResp.getApdu();

// a type 4b tag was detected
var type4BDetected = new Responses.Type4BDetected();
// get the tag's ATTRIB
type4BDetected.getAttrib();
// get the tag's ATQB
type4BDetected.getAtqb();

// a type 4a tag was detected
var type4Detected = new Responses.Type4Detected();
// get the tag's UID
type4Detected.getUid();
// get the tag's ATS
type4Detected.getAts();

// an error occured when the Tappy was in the process
// of detecting a tag such as when a tag is removed from
// the Tappy's range part way through detection
var type4PollingError = new Responses.Type4PollingError();

// Tag polling finished without any tag being detected
var type4Timeout = new Responses.Type4Timeout();

// the version of the library 
var libVersion = new Responses.Type4LibraryVersion();
libVersion.getMajorVersion();
libVersion.getMinorVersion();

// an error occured executing a command 
var type4Error = new Responses.Type4Error();
// retrieve the command family-specific error code as per Type4Family.ErrorCodes 
type4Error.getErrorCode();
// retrieve the internal-use error code 
type4Error.getInternalErrorCode();
// retrieve the status reported by the Tappy's NFC Controller
type4Error.getReaderStatusCode();
// retrieve the text message describing the error (may be empty string)
type4Error.getErrorMessage();

Resolver

While you can manually resolve raw TCMP messages received from the Tappy using getCommandFamily(), getCommandCode(), getPayload(), and parsePayload(), it is much more convenient to use the built-in resolvers and isTypeOf().

var resolver = new Type4Family.Resolver();

// first check to see if the family matches this can be used to multiplex 
// multiple resolvers from different families
if(resolver.checkFamily(responseMsg) {
    // resolution will throw if the command family doesn't match, so it is
    // advisable to check that first. additionally, resolution will return
    // null if there is no matching command code in the library
    var resolved = resolver.resolveResponse(responseMsg);
    if(Type4Family.Responses.Type4LibraryVersion.isTypeOf(resolved)) {
        console.log("Library version v"+resolved.getMajorVersion()+"."+resolved.getMinorVersion());
    }
}

There is a corresponding resolveCommand for commands in case you are storing commands in a raw form. Note that commands and responses have overlapping commandCode space, so keep track of whether the message was sent to the Tappy or received from it and use the appropriate resolution function.