0.2.17 enble reset on reconnect. change resetTimeout to resetInterval for timed reset enable
parent
f132b1d271
commit
8f22017fd1
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@uci/interrupt",
|
"name": "@uci/interrupt",
|
||||||
"main": "src",
|
"main": "src",
|
||||||
"version": "0.2.16",
|
"version": "0.2.17",
|
||||||
"description": "a class for adding interrupt processesing for gpio pins on Raspberry Pi and Similar SBCs",
|
"description": "a class for adding interrupt processesing for gpio pins on Raspberry Pi and Similar SBCs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"single": "node -r esm examples/single",
|
"single": "node -r esm examples/single",
|
||||||
|
|
|
@ -93,16 +93,16 @@ class Interrupt extends Base {
|
||||||
|
|
||||||
log.debug({msg:'new interrupt pin created and watching', num:this.pin_num, status:await this.status() ? 'ready' : 'not ready', pin:this.pin, edge:this.edge,debounce:this.wait})
|
log.debug({msg:'new interrupt pin created and watching', num:this.pin_num, status:await this.status() ? 'ready' : 'not ready', pin:this.pin, edge:this.edge,debounce:this.wait})
|
||||||
|
|
||||||
|
log.debug('setting reconnect listener')
|
||||||
this.socket.mcp.on('reconnected', () => console.log('test listen reconnected'))
|
this.socket.mcp.on('reconnected', () => console.log('test listen reconnected'))
|
||||||
|
this.consumersListen('reconnected', () => {
|
||||||
console.log('setting connect listener')
|
log.debug('reconnected to a socket send a reset request')
|
||||||
this.consumersListen('reconnected', () => console.log('connected to a socket emit a reset'))
|
this.reset()
|
||||||
// await this.reset()
|
})
|
||||||
// })
|
|
||||||
|
|
||||||
this.socket.mcp.emit('reconnected')
|
this.socket.mcp.emit('reconnected')
|
||||||
|
|
||||||
if (this.resetTimeout) setInterval(this.reset.bind(this),this.resetTimeout)
|
if (this.resetInterval) setInterval(this.commands.reset,this.resetInterval)
|
||||||
|
|
||||||
this.pin.watch( function (err,value) {
|
this.pin.watch( function (err,value) {
|
||||||
log.debug('sbc interrupt tripped, value:', value, 'error:', err)
|
log.debug('sbc interrupt tripped, value:', value, 'error:', err)
|
||||||
|
@ -139,7 +139,7 @@ class Interrupt extends Base {
|
||||||
this.emit(this.resetCmd) // emit locally
|
this.emit(this.resetCmd) // emit locally
|
||||||
await this.send(packet)
|
await this.send(packet)
|
||||||
await this.push(packet)
|
await this.push(packet)
|
||||||
log.debug({msg: `interrupt was reset. ready now? ${(await this.status()).ready}`})
|
log.error({msg: `interrupt was forced reset. ready now? ${(await this.status()).ready}`})
|
||||||
return {cmd:'reply', reset:true, ready: (await this.status()).ready}
|
return {cmd:'reply', reset:true, ready: (await this.status()).ready}
|
||||||
}
|
}
|
||||||
return {cmd:'reply', reset:false, ready:true}
|
return {cmd:'reply', reset:false, ready:true}
|
||||||
|
@ -157,9 +157,8 @@ class Interrupt extends Base {
|
||||||
if (this.hook) packet = await this._hookFunc.call(this,packet)
|
if (this.hook) packet = await this._hookFunc.call(this,packet)
|
||||||
log.debug({packet: packet, msg:'interrupt tripped, emit/send/push packet to all connected/listening'})
|
log.debug({packet: packet, msg:'interrupt tripped, emit/send/push packet to all connected/listening'})
|
||||||
this.emit('interrupt',packet) // emit locally
|
this.emit('interrupt',packet) // emit locally
|
||||||
await this.send(packet) // will send a packet via client to any socket
|
this.send(packet) // will send a packet via client to any socket
|
||||||
this.push(packet) // will push on any socket
|
this.push(packet) // will push on any socket
|
||||||
// if (this.resetTimeout) await this.reset() // extra insurance that interrupt got reset
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerHook(func) {
|
registerHook(func) {
|
||||||
|
|
Loading…
Reference in New Issue