TheThingsNetwork / workshops

Workshops for The Things Network
MIT License
81 stars 31 forks source link

SyntaxError when running ttn-aws-iot #28

Open tonkatsu7 opened 7 years ago

tonkatsu7 commented 7 years ago

Using the sample script from https://www.npmjs.com/package/ttn-aws-iot

'use strict';

const ttnawsiot = require('ttn-aws-iot');

// Replace with your AppEUI and App Access Key 
const appEUI = '<insert AppEUI>';
const appAccessKey = '<insert App Access Key>';

// Replace with your certificates from AWS IoT 
const caCert = 'examples/keys/root-CA.crt';
const clientCert = 'examples/keys/cert.crt';
const privateKey = 'examples/keys/private.key';
const region = 'eu-west-1';

const bridge = new ttnawsiot.Bridge(appEUI, appAccessKey, caCert, clientCert, privateKey, region);

bridge.on('aws-connect', () => {
  console.log('AWS connected');
});

bridge.on('ttn-connect', () => {
  console.log('TTN connected');
});

bridge.on('error', err => {
  console.warn('Error', err);
});

bridge.on('uplink', data => {
  console.log('Uplink', data);
});

And specifying the correct AppEUI, AppKey and generating an appropriate key/pair and downloading AWS root-CA, when I run npm app.js i get...

[ec2-user@ip-172-31-12-65 ttn-aws-iot]$ node --harmony app.js

/home/ec2-user/ttn-aws-iot/app.js:17
bridge.on('aws-connect', () => {
                          ^
SyntaxError: Unexpected token )
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:945:3