• This repository has been archived on 19/Jul/2021
  • Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    JavaScript
  • License
    The Unlicense
  • Created over 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DEPRECATED - Server for Xexun/Coban TK102 GPS tracker devices - Anyone want to take over this project?

TK102 GPS server - DEPRECATED

This package is no longer being maintained.


Receive and parse GPS data from Xexun TK102 trackers.

The Xexun TK102 is a GPS device that can send coordinates over TCP to a server via GPRS. This Node.js script creates a TCP server that listens for GPRMC data, parse it and send the data to your post-process function. The parsed data is provided in a clean easy to use object, so you can easily store it in a database or push to a websocket server, etc.

Example

var server = require ('tk102');

// start server
server.createServer ({
  port: 1337
});

// incoming data, i.e. update a map
server.on ('track', function (gps) {
  updateMap (gps.geo.latitude, gps.geo.longitude);
});

Prepare device

Assuming your simcard has enough SMS and data credits and the TK102 is configured for your provider's APN, simply send adminip123456 IP PORT where obviously IP is the server's IP, PORT is the port to listen on and 123456 is your admin password. :) It cannot take hostnames as it has no dns features on board.

Activate sending coordinates: t030s003n123456

This tells the device to send its location AFTER each 30 seconds and no more than 3 times. 30 seconds is the minimum. Send t030s***n123456 to go on for infinity.

  • s (seconds) can also be m (minutes) or h (hours)
  • To end tracking send notn123456

Installation

Stable: npm install tk102

Develop: npm install fvdm/nodejs-tk102#develop

Settings

name type default description
ip string 0.0.0.0 Listen on IP, 0.0.0.0 is all IPs
port integer 0 Listen on port, 0 is random (see listening event)
connections integer 10 Maximum simultaneous connections
timeout integer 10 Idle time out in seconds
server.createServer ({
  ip: '1.2.3.4',
  port: 0
});

Events

The server emits the following events about the server status and incoming GPS pushes.

track

( gpsObject )

The data push from the device.

server.on ('track', function (gps) {
  { raw: '1203301642,0031698765432,GPRMC,144219.000,A,5213.0327,N,00516.7759,E,0.63,179.59,300312,,,A*6D,F,imei:123456789012345,123',
    datetime: '2012-03-30 16:42',
    phone: '0031698765432',
    gps: { date: '2012-03-30', time: '14:42:19.000', signal: 'full', fix: 'active' },
    geo: { latitude: 52.130326, longitude: 5.167759, bearing: 179 },
    speed: { knots: 0.63, kmh: 1.167, mph: 0.725 },
    imei: '123456789012345' }
})
property description
raw the input string without trailing whitespace
datetime the device 24h clock
phone the admin phonenumber that initiated this tracking
imei device IMEI
gps information about the GPS signal
geo geographical position and direction
speed travel speed

gpsObject.gps

property description
date date as received from GPS
time time in 24h UTC as received from GPS
signal signal strength, either full or low
fix GPS fix, either active or invalid

gpsObject.geo

property description
latitude position latitude
longitude position longitude
bearing direction in degrees

gpsObject.speed

property description
knots speed in knots per hour (original)
kmh speed in kilometer per hour
mph speed in miles per hour

data

( rawString )

The raw unprocessed inbound data.

server.on ('data', function (raw) {
  console.log ('Incoming data: '+ raw);
});

listening

( listeningObject )

Very useful to find out random port (0).

server.on ('listening', function (listen) {
  // listen = { port: 56751, family: 2, address: '0.0.0.0' }
});

connection

( socket )

Emitted when a connection is established with the server, includes the socket basics.

server.on ('connection', function (socket) {
  console.log ('Connection from '+ socket.remoteAddress);
});

disconnect

( socket )

Emitted when a connection is ended, includes the socket basics.

server.on ('disconnect', function (socket) {
  console.log ('Disconnected device '+ socket.remoteAddress);
});

timeout

( socket )

Emitted when a connection expires, includes the socket basics.

server.on ('timeout', function (socket) {
  console.log ('Time-out from '+ socket.remoteAddress);
});

fail

( Error )

Emitted when data cannot be parsed. Useful for debugging device issues.

Error is an instanceof Error with .stack trace.

server.on ('fail', function (err) {
  console.log (err);
});

error

( Error )

Emitted when a server related error occured.

Error is an instanceof Error with .stack trace.

Messages

error description
Server error Catch server failures
Socket error Catch communication failures
IP or port not available This catches EADDRNOTAVAIL errors
server.on ('error', function (err) {
  console.log (err);
});

log

( name, data )

Emitted on any of the above events. Useful for debugging and logging.

argument type description
name string Event name, i.e. track
value mixed Data from the event
server.on ('log', function (name, value) {
  console.log ('Event: ' + name);
  console.log (value);
});

Notes

There is no security built in, anyone could push data to your server.

The parsed object is based on a lot of testing in the field and incomplete documentation, I hope I got it right. There are many variations of the TK102 tracker available with each different data formats. It may be possible your device or even mine is one of the clones and incompatible with this module.

If you can, please provide multiple responses from the data event in a Github issue (public) or contact me directly, your data is handled confidentially. Preferably leave the device tracking with an interval of 30 seconds or less for about 3 to 5 minutes outdoors or near a window. This way I can figure out the data format and various states the tracker reports about itself to the server.

Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to https://unlicense.org

Author

Franklin | Buy me a coffee

More Repositories

1

nodejs-foscam

Remote control, view and config a Foscam or compatible IP camera
JavaScript
125
star
2

nodejs-youtube

Access public YouTube data feeds from your Node.js apps
JavaScript
100
star
3

speedtest

Simple bandwidth test in browser javascript
HTML
64
star
4

nodejs-geoip2ws

Maxmind GeoIP2 Web Services for Node.js
JavaScript
47
star
5

nodejs-gtmetrix

Node.js module for the GTmetrix API to run and access tests
JavaScript
41
star
6

nodejs-piwik

Access a Matomo (Piwik) API from node.js
JavaScript
38
star
7

nodejs-searchitunes

Lightweight node.js module to quickly search Apple's iTunes Store for music, movies, apps, etc.
JavaScript
29
star
8

nodejs-haveibeenpwned

API methods for HaveIBeenPwnd.com (unofficial)
JavaScript
17
star
9

nodejs-ns-api

Unofficial NodeJS module for Nederlandse Spoorwegen API
JavaScript
17
star
10

nodejs-dnsimple

REPO MOVED TO DNSIMPLE, see url:
JavaScript
16
star
11

nodejs-osx-photostream

Process new photos in real-time with iCloud PhotoStream on OSX
JavaScript
14
star
12

nodejs-passdock

PassDock API methods for iOS Wallet (PassBook)
JavaScript
13
star
13

dnsimple-php

DNSimple PHP class
PHP
12
star
14

nodejs-spark

Read and control your Spark Core with node.js :)
JavaScript
10
star
15

nodejs-europeana

Unofficial Node.js module for the Europeana API. Search and lookup art in various archives across Europe.
JavaScript
10
star
16

nodejs-fibonacci

Return any (big) fibonacci number
JavaScript
10
star
17

nodejs-cloudsight

Unofficial Node.js module for the CloudSight image recognition API
JavaScript
7
star
18

nodejs-toonapp

Eneco Toon module for node.js
JavaScript
6
star
19

nodejs-vnstat-dumpdb

Node.js wrapper for vnStat --dumpdb, with error handling and the same output structure on each system
JavaScript
6
star
20

nodejs-bolcom

[DEPRECATED] Unofficial node.js wrapper for the bol.com API
JavaScript
5
star
21

nodejs-geolocation

Google Maps Geolocation API for Node.js (unofficial)
JavaScript
3
star
22

FoscamTouch

Touch frontend for Foscam/Tenvis network camera
JavaScript
3
star
23

nodejs-requestbin

RequestBin module for node.js
JavaScript
3
star
24

nodejs-openkvk

Unofficial Openkvk.nl module for Node.js
JavaScript
2
star
25

nodejs-toonapi

Node.js package for Eneco/Quby Toon API (unofficial)
JavaScript
2
star
26

nodejs-ssldecoder

Node.js module to check your domain SSL/TLS setup with SSL Decoder.org (unofficial)
JavaScript
2
star
27

nodejs-planetos

Access the Planet OS API with your Node.js app (unofficial)
JavaScript
2
star
28

nodejs-skyhook

IP location lookup with Skyhook Hyperlocal IP
JavaScript
1
star
29

nodejs-messagebird

node.js module for MessageBird API
1
star
30

nodejs-readcsv

Parse CSV file with format detection
JavaScript
1
star
31

nodejs-brothermfc

Access Brother MFC web UI details with node.js. Only tested with MFC-J4710DW
JavaScript
1
star
32

nodejs-bitonic

Unofficial API wrapper for Bitonic.nl
JavaScript
1
star
33

nodejs-dotest

Yet another unit test runner for Node.js
JavaScript
1
star
34

fvdm.github.com

HTML
1
star
35

pusher-php

PHP function for Pusherapp.com
PHP
1
star
36

snippets

Bits and pieces in various languages
PHP
1
star
37

nodejs-politieapi

Access the Politie Open data API with Node.js (unofficial)
JavaScript
1
star
38

nodejs-gamepad

OSX PS3 gamepad experiment with node.js
JavaScript
1
star