Skip to content

6uliver/codie-packet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codie-packet

NPM Version Build Status Coverage Status

Unofficial Node.js library for creating and parsing Codie packets based on Codie BLE API documentation

Install

You can get codie-packet via npm.

$ npm install codie-packet --save

Usage

Forge a packet for Codie:

var CodiePacket = require('codie-packet');

var buffer = CodiePacket.create({
    source: CodiePacket.ENTITY.APP,
    destination: CodiePacket.ENTITY.MCU,
    priority: CodiePacket.PRIORITY.NORMAL,
    sequenceNumber: 1337,
    commandId: CodiePacket.COMMANDS.DRIVE_DISTANCE,
    data: [200, 100, 100]
});

/* Send buffer to the BLE layer */

Parse a packet received from Codie:

var CodiePacket = require('codie-packet');

var buffer = /* Receive buffer from the BLE layer */

var packet = CodiePacket.parse(buffer);

// for example:
packet == {
    source: CodiePacket.ENTITY.MCU,
    destination: CodiePacket.ENTITY.APP,
    priority: CodiePacket.PRIORITY.NORMAL,
    sequenceNumber: 1337,
    commandId: CodiePacket.COMMANDS.DRIVE_DISTANCE,
    data: [0]
};

For detailed description of ENTITY, PRIORITY and COMMANDS constants see Codie BLE API documentation, everything is the same just in UPPER_CASE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published