diff --git a/packages/hal/src/validators/apex/index.ts b/packages/hal/src/validators/apex/index.ts index 463ee06..5d98c03 100644 --- a/packages/hal/src/validators/apex/index.ts +++ b/packages/hal/src/validators/apex/index.ts @@ -48,6 +48,11 @@ export class ApexValidator extends EventEmitter implements BillValidator { constructor(config: ValidatorConfig) { super() this.config = config + // Seed from config, as id003 effectively does by threading config.fiatCode + // into its rs232 config. Nothing in the app calls setFiatCode(), so a + // driver that relies on it alone resolves every credit channel to null and + // rejects every note. setFiatCode() stays available as a later override. + this.fiatCode = config.fiatCode ?? config.rs232.fiatCode ?? null this._throttledError = throttle((err: Error) => this.emit('error', err), 2000) } @@ -76,7 +81,20 @@ export class ApexValidator extends EventEmitter implements BillValidator { this.fsm.on('billsAccepted', () => this.emit('billsAccepted')) this.fsm.on('billsRead', (bill: { denomination: number | null; code: string }) => { if (!bill.denomination) { - console.log('[APEX] Bill rejected: unsupported/unmapped channel') + // Say WHICH of the two causes this is. "unmapped channel" alone reads + // as a hardware/dataset mismatch and sent us looking at DIP switches + // when the real cause was a null fiat code rejecting every note. + if (!this.fiatCode) { + console.error( + '[APEX] Bill rejected: no fiat code set on the driver, so NO channel ' + + 'can resolve to a value. Every note will be returned until this is fixed.' + ) + } else { + console.log( + `[APEX] Bill rejected: channel ${bill.code || '?'} is not mapped in the ` + + `${this.fiatCode} dataset — check the acceptor's configuration card` + ) + } this.rs232?.reject() return } @@ -92,6 +110,13 @@ export class ApexValidator extends EventEmitter implements BillValidator { this.fsm.on('standby', () => this.emit('standby')) this.fsm.on('error', (err: Error) => this.emit('error', err)) + if (!this.fiatCode) { + console.error( + '[APEX] starting with NO fiat code — denomination lookup will return null ' + + 'for every credit channel and the acceptor will reject every note.' + ) + } + this.rs232.open((err) => { if (err) return cb(err) this.rs232!.reset() // start disabled diff --git a/packages/hal/src/validators/ebds/index.ts b/packages/hal/src/validators/ebds/index.ts index 44dd540..52a749b 100644 --- a/packages/hal/src/validators/ebds/index.ts +++ b/packages/hal/src/validators/ebds/index.ts @@ -53,6 +53,11 @@ export class EbdsValidator extends EventEmitter implements BillValidator { constructor(config: ValidatorConfig) { super() this.config = config + // Seed from config, as id003 effectively does by threading config.fiatCode + // into its rs232 config. Nothing in the app calls setFiatCode(), so a + // driver that relies on it alone resolves every credit channel to null and + // rejects every note. setFiatCode() stays available as a later override. + this.fiatCode = config.fiatCode ?? config.rs232.fiatCode ?? null this._throttledError = throttle((err: Error) => this.emit('error', err), 2000) }