I recommend that you get an IDE if you don't have one. I recommend WebStorm, but it's only free for a month, then you'll have to pay. Some alternatives are Visual Studio, Aptana, search this forum for others
next you'll go on your command line and navigate to your project directory, mine is C:\projects\tk106\server\src
the next step will walk you through creating your package.json file, it will ask you want you want to call your application file, it defaults to index.js, I call mine server.js, so anywhere you see server.js below, replace it with the name you give your file
type 'npm init'
This will help you create your package.json file which is the package manager for your file. It will ask you a few questions, then create the file.
I believe you said you installed tk102 already, if so, skip this step:
Once the file is created, type 'npm install tk102 --save'
the --save option will be sure to add the dependency into your package.json file
My personal preference is to install nodemon as well, so that my server auto restarts as I make changes
I do that by typing 'npm install nodemon --save-dev'
This will add nodeman as a dependency to your development environment inside your package.json file
if you installed nodemon do the following:
Now open your package.json file
remove the line "main": "server.js",
add this line in the scripts object above test
"start": "NODE_ENV=local ./node_modules/.bin/nodemon server.js",
Depending on what you stated your default node file would be, create that file. I created a file named server.js
Open your server.js file and follow the example from the tk106 repo:
type the following:
------------------------------------------------------------------------------------
'use strict';
var server = require('tk102');
server.createServer({
port: 1337
});
server.on( 'listening', function( listen ) {
console.log('listening on port: ' + listen.port);
});
server.on( 'data', function( raw ) {
console.log( 'Incoming data: '+ raw )
});
server.on( 'track', function( gps ) {
console.log( gps )
});
------------------------------------------------------------------------------------
at this point, you should be able connect your device to your server. if things don't work, then you'll have to dig into the tk102 server source code and update it. it's located in node_modules\tk102\tk102.js
if you attach the manual, I may be able to help further as any errors will probably be in the parser. Hopefully you get something in the console.log( 'Incoming data: '+ raw ) statement
let me know how that goes.
sometimes you may have to stop node from running, in that case I run this on my mac
lsof -n -i :1337
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 1887 alexbostic 14u IPv4 0x7e6cfdb8acf18bf5 0t0 TCP *:hbci (LISTEN)
sudo kill -9 1887
lsof -n -i :1337
npm start