Git Product home page Git Product logo

nodejs-tk102's Introduction

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

nodejs-tk102's People

Contributors

fvdm avatar sergions80 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodejs-tk102's Issues

Package is deprecated

Hey guys,

After 6 years, 4 bricked TK-102’s, a TK-102B and a TK-103, I’m stepping out of this project. The cost of those cheap trackers is actually pretty high when you count the replacements and amount of time you have to invest to get it working in a useful way. It appears only the first batches of TK-102’s have a consistent data format while everything that came after is just random. Even the bidirectional communication is far from reliable. It’s also becoming really difficult to distinguish between the original and the fake devices. Some are even too cheap to be good for the workers; you can see the rush job when you take it apart. Soldered only one strand of the too short antenna wire, for example. One bad bounce on the ground it breaks, then the tracker has no cell reception anymore.

To cut the story short, I have recently switched over to a Tractive GPS tracker which is doing more than everything I intended this Node package for, but without the trouble of coding it myself. Personally I no longer have a need for this package anymore. Combined with the backlog and low quality hardware, I’m loosing motivation to keep it maintained.

It was an interesting ride, I learned a lot about GPS tech and hardware diversity, but the people who are still using the ‘tk102’ package deserve a coder who’s dedicated to make it all work.

If someone wishes to take over this repo and the package on npm, please let me know here.

Support TK102-2

Adding support for TK102-2 trackers.

  • Battery voltage
  • Altitude
  • Num satellites
  • Cell ID
  • MNC/MCC codes
  • LAC code

Error handling

Implement proper error handling with Error instances.

question about methods to secure

I'm working with something similar and you mention this has "no security built in". I wanted to ask what techniques would even be possible to limit other users from uploading.

I can see the following helping by limiting uploads by IMEI, IP or other unique identifiers, does anything else exist?

support for GPS103A?

when I connect my device GPS103A just answer me this.

Logs:
ubuntu-0 Event: data
ubuntu-0 '##,imei:8686830534662313142206,A;'
ubuntu-0 Event: track
ubuntu-0 '##,imei:8686830534662313142206,A;'
ubuntu-0 Event: timeout
ubuntu-0 { address: '0.0.0.0',
ubuntu-0 family: 'IPv4',
ubuntu-0 port: 5001,
ubuntu-0 remoteAddress: '132.184.84.145',
ubuntu-0 remotePort: 52399 }

some help?

Trace: { [Error: uncaught exception]

Hello,
i tried your server, but i get often this error ?

Trace: { [Error: uncaught exception]
error:
{ [Error: Socket error]
reason: 'Socket error',
socket:
{ _connecting: false,
_handle: null,
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_maxListeners: 10,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
onend: null,
destroyed: true,
bytesRead: 26,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
server: [Object],
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 1431944307470,
_monotonicStartTime: 16494237665,
pipe: [Function],
addListener: [Function: addListener],
on: [Function: addListener],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true },
settings: { ip: '0.0.0.0', port: 5030, connections: 10, timeout: 10 } } }
at process.tk102.createServer.tk102.settings.(anonymous function) (/srv/tk102-gw/daemon/tk102.js:79:11)
at process.emit (events.js:95:17)
at process._fatalException (node.js:301:26)

can you help me ?

don't parse GPS data TK102b !

Hello I buy a GPS tracker on Amazon but I did not expect it to be so complicated.

But we will say that we like it in the computer!

I followed launching in first demo.js and I simply received the IMEI of my tracker

Event: connection
{address: '0.0.0.0',
  family: 'IPv4',
  port: 1337,
  remoteAddress: '37 .171.230.59 ',
  remotePort: 63500}

Event: data
(087079484741BP00352887079484741HSOP47) '
DATA: (087079484741BP00352887079484741HSOP47)

Event: fail
{Error: Can not parse GPS data from device
    at Socket. <anonymous> (/root/gpsAl/node_modules/tk102/tk102.js:174:19)
    at emitOne (events.js: 96: 13)
    at Socket.emit (events.js: 188: 7)
    at readableAddChunk (_stream_readable.js: 176: 18)
    at Socket.Readable.push (_stream_readable.js: 134: 10)
    at TCP.onread (net.js: 559: 20)
  reason: 'Can not parse GPS data from device',
  input: '(087079484741BP00352887079484741HSOP47)',
  connection:
   {address: '0.0.0.0',
     family: 'IPv4',
     port: 1337,
     remoteAddress: '37 .171.230.59 ',
     remotePort: 63500}}

By analyzing the issues I have therefore tried a resolution by adding a library "time-sleep" and using the exemple.js

By launching the code I received this:

DATA(087079484741BR00190406V4314.0199N00533.1265E009.1190937000.00,00000000L00000000)

I find it positive but I try by all means to decrypt this frame but I find only this documentation on the internet that does not bring me much.

it's been days that I'm looking for solutions help me!

Unreadable data

I tried using this source to parse data from a tk102 device. The received data is always unreadable, for Example 1:
connected
UH� t"3�T

UH� t"3�T

xx 04���[��<�R�w�3vQ

Example 2:

63.143.78.70 wrote:
UH� t"'�

63.143.78.67 wrote:
UH� t"'�

63.143.78.69 wrote:
UH� t"(A

63.143.78.65 wrote:
UH� t"(A

63.143.78.67 wrote:
UH� t"(A

63.143.78.67 wrote:
UH� t")P�

63.143.78.70 wrote:
UH� t")P�

63.143.78.68 wrote:
UH� t"*b

63.143.78.68 wrote:
UH� t"*b

63.143.78.68 wrote:
UH� t"*b

63.143.78.66 wrote:
UH� t"+s�

63.143.78.69 wrote:
UH� t"+s�

63.143.78.65 wrote:
UH� t"+s�

63.143.78.70 wrote:
UH� t"-�

63.143.78.65 wrote:
UH� t"-�

63.143.78.67 wrote:
UH� t".$0

63.143.78.67 wrote:
UH� t".$0

63.143.78.69 wrote:
UH� t".$0

63.143.78.70 wrote:
UH� t"/5�

63.143.78.65 wrote:
UH� t"/5�

63.143.78.65 wrote:
UH� t"/5�

63.143.78.66 wrote:
UH� t"0

63.143.78.67 wrote:
UH� t"0

63.143.78.69 wrote:
UH� t"0

63.143.78.70 wrote:
UH� t"1

63.143.78.65 wrote:
UH� t"1

63.143.78.70 wrote:
UH� t"1

63.143.78.69 wrote:
UH� t"3

63.143.78.66 wrote:
UH� t"3

63.143.78.69 wrote:
UH� t"3

Support for TK-102 clones

Hello,

Thank you for a great library! This is rather question (or two), than issue.

Does this library supports TK-102 clones or only original Xexun one? Difference is quite basic.

Original Xexun (and some limited number of clones) can send datagram via both HTTP and UDP. Most clones supports only UDP. So, my first question is -- can this library be used to listen to UDP datagrams?

Original Xexun (and some clones) broadcast datagrams, including all the information (geo, battery etc.) at once, without asking server for anything. Listening to such trafic is fairly easily.

Most clones are much harder in this area (Chineese got bored, so added this?). For example, my TK-102 clone only sends some "binary-grabage-welcome-data" (I can provide examples) and then waits for proper reply sent back from the server. If reply comes out, only then it sends geo data. If there is no reply at all or reply from the server is incorrect, it breaks connections and sends out nothing else.

So, my second question is -- does this library supports such reply-required listening?

If any of my question is answered "no", is there any change, this library will support such traffic / listening / TK clones in future releases?

Cheers,
Trejder

Add chaining

This would allow simple implementation in other code, example:

require('tk102').createServer({port:1337}).on('track', storeData)

Unreadable data

Got a other TK102 fake. What can I deliver to decode this? (packet trace? other logging?)
Looks like a homebrew sockets implementation to me...

Event: data
'(087076826183BP00HSO)'

Event: fail
{ Error: Cannot parse GPS data from device
at Socket. (/var/www/tk102/node_modules/tk102/tk102.js:152:17)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
reason: 'Cannot parse GPS data from device',
input: '(087076826183BP00HSO)',
connection:
{ address: '0.0.0.0',
family: 'IPv4',
port: 5000,
remoteAddress: 'x.x.x.x',
remotePort: 38267 } }

Not an Issue - Newby Question

-"node" installed: node version: v0.8.20
-downloaded and installed(make/make install): nodesjs-tk102

I execute the following command: node tk102.js

I get no error message or indication that anything is running..
(using nmap, netstat..I don't see any listening ports)

How can I check the running status?
Any pointers on this?

Support for TK103?

Will you consider support for TK103 units?

These were purchased from http://www.amazon.com/Real-Time-Portable-GPS-Tracker/dp/B001FYQO3W?ie=UTF8&psc=1&redirect=true&ref_=oh_aui_detailpage_o04_s00 and seem to use TK103, which is decodable by Traccar via port 5002. Follows format as listed in https://raw.githubusercontent.com/tananaev/traccar/master/tools/test-integration.py.

Incoming data: (027043828342BR00160419A4402.8913N09138.2201W000.60051110.000000000000L00000000)
{ [Error: Cannot parse GPS data from device]
  reason: 'Cannot parse GPS data from device',
  input: '(027043828342BR00160419A4402.8913N09138.2201W000.60051110.000000000000L00000000)',
  connection:
   { address: '0.0.0.0',
     family: 'IPv4',
     port: 1337,
     remoteAddress: '172.56.X.Y',
     remotePort: 37867 } }
Incoming data: (027043828342BP00000027043828342HSO)
{ [Error: Cannot parse GPS data from device]
  reason: 'Cannot parse GPS data from device',
  input: '(027043828342BP00000027043828342HSO)',
  connection:
   { address: '0.0.0.0',
     family: 'IPv4',
     port: 1337,
     remoteAddress: '172.56.X.Y',
     remotePort: 37867 } }

Licence

The project appears to be missing a licence. I've got several similar trackers. I'd like to participate, especially if you chose the Apache 2.0 licence.

Please, change fixGeo function

My tracker sent longitude as 06900.9999 if first sign is 0, parseInt thinks that 'radix = 8' (octal)
Please, change in fixGeo function from:
var degrees = parseInt( one.replace( minutes, '' ) )
to:
var degrees = parseInt( one.replace( minutes, '' ), 10 )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.