Skip to content

Instantly share code, notes, and snippets.

@tom-a
Last active May 5, 2019 02:40
Show Gist options
  • Save tom-a/0fa41bafcd674ac3afc2c9b9e388f3d4 to your computer and use it in GitHub Desktop.
Save tom-a/0fa41bafcd674ac3afc2c9b9e388f3d4 to your computer and use it in GitHub Desktop.
const ambient = require('ambient-lib');
const SerialPort = require('serialport');
const port = new SerialPort('/dev/cuaU0');
const Readline = require('@serialport/parser-readline');
const parser = new Readline();
port.pipe(parser);
ambient.connect(00000,'xxxxxxxxxxxxxxxx');
parser.on('data', line => {
ambient.send({d1: line}, (err, res, body) => {
if (err) { console.log(err); }
console.log(res.statusCode);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment