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-systemfamily

v1.1.0

Published

System command family for TCMP Tappies

Downloads

1

Readme

Tappy Communication Messaging Protocol (TCMP) commany family for Tappy system commands and responses.

Installation

Bower

bower install tappy-systemfamily

NPM

npm install @taptrack/tappy-systemfamily

Commands

var SystemFamily = require('tappy-systemfamily');
var Commands = SystemFamily.Commands;

// Request that the Tappy report its hardware version
var = Commands.GetHardwareVersion()

// Request that the Tappy report its firmware version
var = Commands.GetFirmwareVersion()

// Request that the Tappy report its battery level 
var = Commands.GetBattery()

// Request that the Tappy reply with a ping of its own
// Note that while this is usually used for connectivity testing,
// like all commands, it will cause the Tappy to stop doing 
// most long-running  operations, which may or may not be desirable
var = Commands.Ping()

// Set a config parameter on the Tappy both parameters should be values
// that can fit in a single byte
var = Commands.SetConfigItem(configParameter, configValue)

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 SystemFamily = require('tappy-systemfamily');
var Responses = SystemFamily.Responses;

// a config byte was successfully set
var configSuccess = new Responses.ConfigItemSuccess();

// the Tappy received a command with an incorrect CRC
var crcMismatch = new Responses.CrcMismatch();

// response indicating the Tappy's firmware version
var firmwareVersion = new Responses.FirmwareVersion();
firmwareVersion.getMajorVersion();
firmwareVersion.getMinorVersion();

// response indicating the Tappy's hardware version
var hardwareVersion = new Responses.HardwareVersion();
hardwareVersion.getMajorVersion();
hardwareVersion.getMinorVersion();

// response indicating the approximate battery level 
// of the Tappy. If the Tappy doesn't have a battery,
// a level will still be reported, but its value will be
// largely random and should not be used
var batteryLevel = new Responses.BatteryLevel();
// the battery level in percent
batteryLevel.getBatteryLevel();

// a message was recieved, but the format was incorrect
// rendering the tappy unable to process it
var improperFormat = new Responses.ImproperMessageFormat();

// a message was recieved, but the length checksum was incorrect
var lcsMismatch = new Responses.LcsMismatch();

// a message was recieved, but the message claimed length does not
// match the actual frame length
var lenMismatch = new Responses.LengthMismatch();

// reply to a Ping command
var ping = new Responses.Ping();

// an error occured executing a command 
var systemError = new Responses.SystemError();
// retrieve the command family-specific error code as per SystemFamily.ErrorCodes 
systemError.getErrorCode();
// retrieve the internal-use error code 
systemError.getInternalErrorCode();
// retrieve the status reported by the Tappy's NFC Controller
systemError.getReaderStatusCode();
// retrieve the text message describing the error (may be empty string)
systemError.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 System.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(HardwareVersion.Responses.isTypeOf(resolved)) {
        console.log("Hardware 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.