fix(hal): implement onLeaveConnected for ID003 validator initialization

The ID003 FSM was stuck in the PowerUp state because leaving the
Connected state never emitted 'ready'. This is the trigger for the
denomination/reset initialization chain.

Added onLeaveState() method that emits 'ready' when leaving Connected,
matching the original lamassu-machine behavior (onleaveConnected).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-02-25 17:01:50 -05:00
commit bb73e13e48

View file

@ -58,6 +58,7 @@ export class Id003Fsm extends EventEmitter {
const from = this._state
this.clearStateTimeout()
console.log('FSM: %s [ %s -> %s ]', event ?? 'transition', from, to)
this.onLeaveState(from)
this._state = to
this.onEnterState(to, from, data)
}
@ -75,13 +76,18 @@ export class Id003Fsm extends EventEmitter {
}, TRANSIENT_TIMEOUT)
}
private onLeaveState(state: string): void {
if (state === 'Connected') {
this.emit('ready')
}
}
private onEnterState(state: string, from: string, data?: unknown): void {
switch (state) {
case 'PowerUp':
this.emit('powerUp')
break
case 'Connected':
// Will emit 'ready' on leave
break
case 'Denominations':
this.emit('denominations')