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 🙏

© 2025 – Pkg Stats / Ryan Hefner

octopus-gps-tracking

v1.0.14

Published

Let you work with some GPS trackers that connects through tcp.

Readme

GPS TRACKING (WITH TK103-2 ADAPTER)| Node.js

This module let you easily create listeners for your GPS tracking devices. You can add your custom implementations to handle more protocols.

New GPS Tracker emulator:

We created a brand new gps emulator so you can start testing your app in a breeze. You can signup to save your testing devices.

http://gps-tracking-emulator.meteor.com/

You can check the code of the emulator in this repo.

https://github.com/freshworkstudio/gps-tracking-emulator

v1.0 release

We removed mongoDB dependecy for this package. Now you can use any DB to save the data you receive.

The old documentation is still available in the repository (tag v0.25)

Currently supported models

  • TK103
  • TK103-2

Installation

With package manager npm:

npm install octopus-gps-tracking

DEMO SERVER APP

You can check a basic demo app here

DEMO SERVER WEB APP

You can check a Express + Socket.io + MongoDB + Google Maps Web app to see your devices in realtime here. Also, you can see the live demo here

Usage

Once you have installed the package, you can use it like:

var gps = require("gps-tracking");

var options = {
    'debug'                 : true,
    'port'                  : 8090,
    'device_adapter'        : "TK103_2"
}

var server = gps.server(options,function(device,connection){

    device.on("login_request",function(device_id,msg_parts){

        // Some devices sends a login request before transmitting their position
        // Do some stuff before authenticate the device...

        // Accept the login request. You can set false to reject the device.
        this.login_authorized(true);

    });


    //PING -> When the gps sends their position
    device.on("ping",function(data){

        //After the ping is received, but before the data is saved
        //console.log(data);
        return data;

    });

});

Sending a message to device

server.send_to(device_id, 'powercar 11');

Step by step

  1. Install Node

  2. Create a folder for your project

  3. Copy the example code above in a .js file like server.js

  4. Install the package in the project folder

cd /path/to/my/project
npm install gps-tracking
  1. Run your server
node server.js

Overview

With this package you are going to create a tcp server that listens on a open port of your server/computer for a specific gps device model. For example, you are going to listen on port 8090 for 'TK103 gps-trackers'.

If you want to listen for different kind of trackers, you have to create another tcp server. You can do this in a different node.js program in the same server, but you have to listen in a different port.

So, you can listen on port 8090 for TK103 devices and listen on 8091 for TK102 devices (or any gps-tracker you want)

Options

debug

Enables console.log messages.

    "debug":false,

port

The port to listen to. Where the packages of the device will arrive.

    "port": 8080,

device_adapter

Which device adapter will be used to parse the incoming packets.

    "device_adapter": false,
    // If false, the server will throw an error.

    "device_adapter": "TK103_2"
    // You can create your own adapter.

    //FOR USING A CUSTOM DEVICE ADAPTER
     "device_adapter": require("./my_custom_adapter")

Events

Once you create a server, you can access to the connection and the device object connected. Both objects emits events you can listen on your app.

var server = gps.server(options,function(device,connection){
    //conection = net.createServer(...) object
    //device = Device object
}

connection events

Available events:

  • end
  • data
  • close
  • timeout
  • drain

You can check the documentation of node.js net object here.

//Example:
var server = gps.server(opts,function(device,connection){
    connection.on("data",function(res){
		//When raw data comes from the device
	});
});

Device object events

Every time something connects to the server, a net connection and a new device object will be created. The Device object is your interface to send & receive packets/commands.

var server = gps.server(opts,function(device,connection){
    /*	Available device variables:
		----------------------------
		device.uid -> is setted when the first packet is parsed
		device.name -> you can set a custon name for this device.
		device.ip -> ip of the device
		device.port --> device port
	*/

    /******************************
	LOGIN
	******************************/
	device.on("login_request",function(device_id,msg_parts){
		//Do some stuff before authenticate the device...

		this.login_authorized(true); //Accept the login request.
	});
	device.on("login",function(){
		//this = device
		console.log("Hi! i'm "+this.uid);
	});
	device.on("login_rejected",function(){

	});


	/******************************
	PING - When the gps sends their position
	******************************/
	device.on("ping",function(data){
		//After the ping is received
		//console.log(data);
		console.log("I'm here now: "+gps_data.latitude+", "+gps_data.longitude+");
		return data;
	});


	/******************************
	ALARM - When the gps sends and alarm
	******************************/
	device.on("alarm",function(alarm_code,alarm_data,msg_data){
		console.log("Help! Something happend: "+alarm_code+" ("+alarm_data.msg+")");
		call_me();
	});


	/******************************
	MISC
	******************************/
	device.on("handshake",function(){

	});

});