Using Raspberry Pi Zero W + Iphone and trying to move succesfull blynk control with index.js from global to local server ( I followed Anna’s instructions ) …trying for 2 days and still cant figure what is wrong…Here is what I am doing…Please help…
For global server it works fine…I open 1 terminal window and type
export PATH=$PATH:/opt/nodejs/bin/
unset NODE_PATH
blynk-client ‘codeforglobalserver’
Then I open a second terminal window and type node index.js. It works fine…click button and led changes…
Then close both terminal windows, open a new terminal window to launch local server and type:
java -jar server-0.41.13-java8.jar -dataFolder /home/pi/Blynk
Then open a second terminal window, edit index.js as below
From:
var AUTH = ‘codeforglobalserver’;
var blynk = new Blynk.Blynk(AUTH);
To:
var AUTH = ‘codeforLOCALserver’;
var blynk = new Blynk.Blynk(AUTH, options = { connector : new Blynk.TcpClient( options = { addr:”192.168.1.14”, port:8080 } ) });
I get the error message below:
/home/pi/my-project/index.js:7
var blynk = new Blynk.Blynk(AUTH, options = { connector : new Blynk.TcpClient( options = { addr:”192.168.1.14”, port:8080 } ) });
^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
The index.js file is :
var Blynk = require('blynk-library');
var Gpio = require('onoff').Gpio;
var led = new Gpio(23, 'out');
var AUTH = ‘code for local server’;
var blynk = new Blynk.Blynk(AUTH, options = { connector : new Blynk.TcpClient( options = { addr:”192.168.1.14”, port:8080 } ) });
var v1 = new blynk.VirtualPin(1);
v1.on('write', function(param) {
if (param[0] == '1'){
led.writeSync(1);
} else {
led.writeSync(0);
}
console.log('V1:', param[0]);
});
What am I doing wrong ? Almost giving up on blynk….