fix serial number on update event
This commit is contained in:
@@ -53,7 +53,7 @@ class NanoDevices extends EventEmitter {
|
|||||||
if (lines[i].length > 0) {
|
if (lines[i].length > 0) {
|
||||||
if (lines[i].startsWith('{'))
|
if (lines[i].startsWith('{'))
|
||||||
// if its a json object
|
// if its a json object
|
||||||
this.emit('nanodevices:update', connected_port.serialNumber, lines[i])
|
this.emit('nanodevices:update', connected_port.port.serialNumber, lines[i])
|
||||||
else console.log('Device: ' + lines[i]) // otherwise just log it
|
else console.log('Device: ' + lines[i]) // otherwise just log it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,9 +104,9 @@ class NanoDevices extends EventEmitter {
|
|||||||
delete this.connected_nano_devices[nano_device.serialNumber!]
|
delete this.connected_nano_devices[nano_device.serialNumber!]
|
||||||
})
|
})
|
||||||
port.on('open', () => {
|
port.on('open', () => {
|
||||||
resolve(nano_device.serialNumber)
|
|
||||||
this.connected_nano_devices[nano_device.serialNumber!] = { port: port }
|
this.connected_nano_devices[nano_device.serialNumber!] = { port: port }
|
||||||
this.emit('nanodevices:connected', nano_device.serialNumber)
|
this.emit('nanodevices:connected', nano_device.serialNumber)
|
||||||
|
resolve(nano_device.serialNumber)
|
||||||
})
|
})
|
||||||
port.on('data', (data) => {
|
port.on('data', (data) => {
|
||||||
const connected_port = this.connected_nano_devices[nano_device.serialNumber!]
|
const connected_port = this.connected_nano_devices[nano_device.serialNumber!]
|
||||||
|
|||||||
Reference in New Issue
Block a user