fvdm / nodejs-tk102

DEPRECATED - Server for Xexun/Coban TK102 GPS tracker devices - Anyone want to take over this project?
https://www.npmjs.com/package/tk102
The Unlicense
112 stars 50 forks source link

support for GPS103A? #22

Closed mhinostroza closed 3 years ago

mhinostroza commented 8 years ago

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?

fvdm commented 7 years ago

Hi,

Sorry for the late reply, I'm a bit slow with this package.

The ##,imei:8686830534662313142206,A; is a heartbeat message from the device. The good news is your device is working and you are receiving something, but there is no useful data there.

Is this all you received?

If it is only sending heartbeats even after a couple of minutes and you are outside or close to a window, I'm affraid the device could be broken. Like so many of them.

alromh87 commented 7 years ago

Hi, I hope this information is still useful for you.

,imei:8686830534662313142206,A;

is the protocol login and the device expect a resopnse: "LOAD" in order to stablish communication,

ther's also a heartbeat wich should be answered with: "ON"

finally you should get something like:

imei:86868302626XXX0,tracker,161206042348,,F,042345.000,A,1923.7029,N,09913.2257,W,0.00,0

fvdm commented 7 years ago

Oooh that's interesting! Do you have more information about commands you can send?

alromh87 commented 7 years ago

Yes, I'm documenting the protocol at the moment, as soon as I have the information, I will shear it.

There are commands to control engine, change tracking frequency and set geofences among others.

alromh87 commented 7 years ago

In order to send back command can out be done at the events or does it has to be on the library?

fvdm commented 7 years ago

The way it is now the events only receive data, they can not send anything. But I can work something out to make that possible.

naumanahmad17 commented 7 years ago

@alromh87 if you have documented the commands can you please share it.

alromh87 commented 7 years ago

-Hi @naumanahmad17 sorry, I have been bussy with other tasks, I have some basic stuff in spanish I can share with you in case your interested, but wont be able to work on it right now Coban.txt

naumanahmad17 commented 7 years ago

@alromh87 Thanks for file share.yes i will be very glad if can you can please share it with me.

naumanahmad17 commented 7 years ago

@alromh87 Thanks for file share.yes i will be very glad if can you can please share it with me.

bakman2 commented 7 years ago

I am terrible in nodejs but I've got it working.

The tracker responds with a different string than this npm module, and requires a rewrite for the parsing.

What I have done: npm install system-sleep

in tk102.js: add var sleep = require('system-sleep'); to the top. This is to add a 1 second delay after each command.

Replace (use your own imei ofcourse):

    socket.on ('data', function (data) {

      var gps = {};
      var err = null;

      data = data.trim ();
      tk102.event ('data', data);

      if (data !== '') {

        // init
        if(data.substr(0,2)=='##'){

          console.log(data)
          console.log("WRITE LOAD");
          socket.write('LOAD');

          sleep(1*1000); 

          console.log("WRITE ON");
          socket.write('ON');

          sleep(1*1000);
          console.log("SENDING **");
          socket.write('**,imei:864180031021079,B')

        } else {

          console.log('DATA:'+data)
          gps = tk102.parse (data);

          if (gps) {
            tk102.event ('track', gps);
          } else {
            err = new Error ('Cannot parse GPS data from device');
            err.reason = err.message;
            err.input = data;
            err.connection = connection;

            tk102.event ('fail', err);
          }
        }
      }
    });

it will output (using node example.js):

TK102 server is ready
Connected to TK102 server
Sending GPS data string for processing
CTRL+C to exit
##,imei:864180031021079,A;
WRITE LOAD
WRITE ON
SENDING **
DATA:imei:864180031021079,tracker,170805124415,,F,114412.000,A,5208.3051,N,00428.1692,E,0.00,0;

I will try to parse it to a proper format.

Moosjes commented 6 years ago

is there any progress in this? I am also only receiving '##,imei:868683026239156,A;' every few seconds

With the changes proposed by @bakman2 I get the following response:

Event: data '##,imei:868683026239156,A;'

,imei:868683026239156,A;

WRITE LOAD WRITE ON SENDING **

Event: timeout { address: '0.0.0.0', family: 'IPv4', port: 8002, remoteAddress: '83.161.x.x', //real ip changed remotePort: 52446 }

Event: disconnect { address: '0.0.0.0', family: 'IPv4', port: 8002, remoteAddress: '83.161.x.x', // real ip changed remotePort: 52446, hadError: false }

Event: connection { address: '0.0.0.0', family: 'IPv4', port: 8002, remoteAddress: '83.161.x.x', // real ip changed remotePort: 57579 }

Event: data '##,imei:868683026239156,A;'

,imei:868683026239156,A;

WRITE LOAD WRITE ON SENDING **

Event: timeout { address: '0.0.0.0', family: 'IPv4', port: 8002, remoteAddress: '83.161.x.x', // real ip changed remotePort: 57579 }

Event: disconnect { address: '0.0.0.0', family: 'IPv4', port: 8002, remoteAddress: '83.161.x.x', // real ip changed remotePort: 57579, hadError: false }

bakman2 commented 6 years ago

Sleep is working?

fvdm commented 3 years ago

This project is no longer maintained. If anyone wishes to over please tell me in issue #36.