Skip to content

Commit

Permalink
output processed data and matched protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
mwittig committed Mar 6, 2019
1 parent 97f7b61 commit 742847b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
19 changes: 18 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,24 @@ console.log(("connecting to " + serialDevice + " with " + baudrate).green);

board.on("data", (function(_this) {
return function(data) {
return console.log("data: \"".grey + ("" + data).blue + "\"".grey);
return console.log("raw data: \"".grey + ("" + data).blue + "\"".grey);
};
})(this));

board.on("rfReceive", (function(_this) {
return function(event) {
var data;
data = JSON.stringify(event);
data = data.substring(1, data.length - 1);
return console.log("processed: ".grey + ("" + data).blue + "".grey);
};
})(this));

board.on("rf", (function(_this) {
return function(event) {
var data;
data = event.protocol + ": " + JSON.stringify(event.values);
return console.log("matched proto: \"".grey + ("" + data).blue + "\"".grey);
};
})(this));

Expand Down
16 changes: 14 additions & 2 deletions src/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ repl = require 'otaat-repl'
colors = require 'colors'

serialDevice = process.argv[2] or '/dev/ttyUSB0'
baudrate = process.argv[3] or 115200
baudrate = parseInt(process.argv[3]) or 115200

board = new Board("serialport", {serialDevice, baudrate})
console.log "connecting to #{serialDevice} with #{baudrate}".green
board.on "data", (data) => console.log "data: \"".grey + "#{data}".blue + "\"".grey

board.on "data", (data) =>
console.log "raw data: \"".grey + "#{data}".blue + "\"".grey

board.on "rfReceive", (event) =>
data = JSON.stringify(event)
data = data.substring(1, data.length-1)
console.log "processed: ".grey + "#{data}".blue + "".grey

board.on "rf", (event) =>
data = event.protocol + ": " + JSON.stringify(event.values)
console.log "matched proto: \"".grey + "#{data}".blue + "\"".grey

board.connect().then( =>
console.log "connected".green
repl.start({
Expand Down

0 comments on commit 742847b

Please sign in to comment.