@lessondesk/marker-protocol
Advanced tools
Comparing version 3.0.6 to 3.0.7
@@ -135,4 +135,4 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
}), | ||
length: function () { | ||
return (this.bytes - 10) / 4; | ||
length: function (parsed) { | ||
return (parsed.bytes - 11) / 4; | ||
} | ||
@@ -313,3 +313,3 @@ }); | ||
Protocol.prototype._transform = function _transform (chunk, encoding, cb) { | ||
//console.log(chunk); | ||
// console.log(chunk); | ||
try { | ||
@@ -355,2 +355,43 @@ var data = PARSER.parse(chunk); | ||
this.removeMarker = function (port, serial) { | ||
// Remove the marker from our list | ||
this$1.markers = this$1.markers.filter(function (marker) { return marker.serial !== serial; }); //Remove marker from the AP list | ||
var header = Buffer.from([0xfd, 0xfd, 0xfd, 0x03, 0x05]); | ||
var payload = Buffer.alloc(4); | ||
payload.writeUInt8(121, 0); | ||
payload.writeUInt8((0x00ff0000 & serial) >> 16, 1); | ||
payload.writeUInt8((0x0000ff00 & serial) >> 8, 2); | ||
payload.writeUInt8(0x000000ff & serial, 3); | ||
var packet = Buffer.concat([header, payload]); | ||
port.write(packet); | ||
}; | ||
this.markerDump = function (port) { | ||
port.write(Buffer.from([0xfd, 0xfd, 0xfd, 0x03, 0x06])); | ||
}; | ||
this.handleApVersionRequest = function (port) { | ||
port.write(Buffer.from([0xfd, 0xfd, 0xfd, 0x03, 0x04])); | ||
}; | ||
this.handleMarkerInfoResponse = function (packet) { | ||
// Add the marker to our list | ||
var ref = packet.data; | ||
var gtin = ref.gtin; | ||
var serial = ref.serial; | ||
this$1.markers.push({ | ||
gtin: gtin, | ||
serial: serial | ||
}); | ||
}; | ||
this.setAmpStateOn = function (port) { | ||
port.write(Buffer.from([0xfd, 0xfd, 0xfd, 0x03, 0x01, 0x01])); | ||
}; | ||
this.setApChannel = function (port, channel) { | ||
port.write(Buffer.from([0xfd, 0xfd, 0xfd, 0x03, channel])); | ||
}; | ||
this.openAccessPoint = function (info) { | ||
@@ -370,2 +411,13 @@ var ref = info.filter(function (device) { return device.manufacturer === "FTDI"; }); | ||
this$1.addMarker(port, packet.data.marker.serial); | ||
this$1.emit("data", packet); | ||
} else if (packet.type === Packets.MARKER_INFO) { | ||
this$1.handleMarkerInfoResponse(packet); | ||
this$1.emit("data", packet); | ||
} else if (packet.type === Packets.MARKER_ADDED) { | ||
var ref = packet.data.marker; | ||
var serial = ref.serial; | ||
this$1.markers.push({ | ||
serial: serial | ||
}); | ||
this$1.emit("data", packet); | ||
} else { | ||
@@ -375,6 +427,6 @@ this$1.emit("data", packet); | ||
}); | ||
this$1.on('list', function () { | ||
console.log('\nReceived a list request...\n'); | ||
this$1.listMarkers(port); | ||
}); | ||
this$1.on('list', function () { return this$1.markerDump(port); }); | ||
this$1.on('remove', function (serial) { return this$1.removeMarker(port, serial); }); | ||
this$1.on('version', function () { return this$1.handleApVersionRequest(port); }); | ||
this$1.on('channel', function (channel) { return this$1.setApChannel(port, channel); }); | ||
}; | ||
@@ -390,2 +442,13 @@ | ||
/** | ||
* [0xFD], [0xFD], [0xFD], [0x01], [0x00] | ||
* |____________________| |____| |____| | ||
* Preamble Flag Data | ||
* | ||
* @param {*} port the serial port interface. | ||
*/ | ||
MarkerProtocol.prototype.setAmpStateOff = function setAmpStateOff (port) { | ||
port.write(Buffer.from([0xfd, 0xfd, 0xfd, 0x03, 0x01, 0x00])); | ||
}; | ||
return MarkerProtocol; | ||
@@ -392,0 +455,0 @@ }(EventEmitter)); |
{ | ||
"name": "@lessondesk/marker-protocol", | ||
"version": "3.0.6", | ||
"version": "3.0.7", | ||
"description": "Lesson Desk Group marker protocol", | ||
@@ -38,4 +38,5 @@ "source": "src/index.js", | ||
"events": "^3.0.0", | ||
"serialport": "^8.0.5", | ||
"stream": "0.0.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
58929
401
5
+ Addedserialport@^8.0.5