Wire HAL drivers to state machine services #19

Closed
opened 2026-06-13 22:02:48 +00:00 by padreug · 0 comments
Owner

Migrated from aiolabs/lamassu-next#19 — opened by @padreug on 2026-01-27.\n\n## Summary

Connect @lamassu/hal drivers to the XState state machine via the ATMServices interface.

Background

The state machine expects services like dispenseCash but currently uses mock implementations. Need to wire real HAL drivers.

Tasks

Bill Validator (ID003)

  • Create HAL service wrapper that initializes Id003
  • Wire validator events to state machine:
    • billsRead → { type: 'BILL_INSERTED', denomination }
    • billsRejected → { type: 'BILL_REJECTED', reason }
    • stackerOpen → handle error state
  • Implement enable/disable control from state machine
  • Handle validator errors gracefully

Bill Dispenser (F56)

  • Create HAL service wrapper that initializes F56Dispenser
  • Implement dispenseCash service:
    dispenseCash: async (amounts) => {
      const notes = amounts.map(a => a.count) // by cassette position
      const result = await dispenser.dispense(notes)
      if (result.error) throw result.error
    }
    
  • Implement waitForBillsRemoved integration
  • Handle dispenser errors (critical - payment received but no cash)

Inventory Management

  • Implement getInventory service from dispenser state
  • Track dispensed bills to update inventory

Acceptance Criteria

  • State machine can accept bills via real validator
  • State machine can dispense bills via real dispenser
  • Errors from hardware propagate to state machine error states

References

  • packages/hal/src/validators/id003/ - Validator driver
  • packages/hal/src/dispensers/f56/ - Dispenser driver
  • packages/state-machine/src/types.ts - ATMServices interface
  • apps/machine/src/stores/atm.ts - Current mock services
> _Migrated from [aiolabs/lamassu-next#19](https://git.atitlan.io/aiolabs/lamassu-next/issues/19) — opened by @padreug on 2026-01-27._\n\n## Summary Connect `@lamassu/hal` drivers to the XState state machine via the `ATMServices` interface. ## Background The state machine expects services like `dispenseCash` but currently uses mock implementations. Need to wire real HAL drivers. ## Tasks ### Bill Validator (ID003) - [ ] Create HAL service wrapper that initializes Id003 - [ ] Wire validator events to state machine: - `billsRead` → `{ type: 'BILL_INSERTED', denomination }` - `billsRejected` → `{ type: 'BILL_REJECTED', reason }` - `stackerOpen` → handle error state - [ ] Implement enable/disable control from state machine - [ ] Handle validator errors gracefully ### Bill Dispenser (F56) - [ ] Create HAL service wrapper that initializes F56Dispenser - [ ] Implement `dispenseCash` service: ```typescript dispenseCash: async (amounts) => { const notes = amounts.map(a => a.count) // by cassette position const result = await dispenser.dispense(notes) if (result.error) throw result.error } ``` - [ ] Implement `waitForBillsRemoved` integration - [ ] Handle dispenser errors (critical - payment received but no cash) ### Inventory Management - [ ] Implement `getInventory` service from dispenser state - [ ] Track dispensed bills to update inventory ## Acceptance Criteria - State machine can accept bills via real validator - State machine can dispense bills via real dispenser - Errors from hardware propagate to state machine error states ## References - `packages/hal/src/validators/id003/` - Validator driver - `packages/hal/src/dispensers/f56/` - Dispenser driver - `packages/state-machine/src/types.ts` - ATMServices interface - `apps/machine/src/stores/atm.ts` - Current mock services
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/bitspire#19
No description provided.