Vending Machine/Cashless Device Implementation

From Nottinghack Wiki
Jump to navigation Jump to search


The cashless device has been built around a nanode, which is connected using UDP/IP over an Ethernet connection to holly.

There is a board between the Nanode (see Media:VMC-Nanode Schematic.png) and the vending machine which both powers the nanode from the ~34vdc supply, and allows serial communication with the VMC.

The nanode is connected (using software serial) to an RFID reader mounted under the 'H' logo on the outside of the Vending machine. There is also a micro-switch attached to the coin-reject mechanism (to allow any RFID card read to be cleared from memory), and a blue LED above the reader to indicate when a card has been read & recognised.

The diagram below shows the connection between devices:
Vend devices.png

UDP Messages

To keep things simple, the UDP/IP interface to holly is text based; the sequence of messages is shown in the flowchart below:
Vend messages.png

Message details

From To Details
VM Holly AUTH:<RFID serial>
Sent when RFID card first read
Holly VM GRNT:<RFID serial>:<transaction number>
Sent in response to AUTH if the card is known & marked as active in the database.
Holly VM DENY:<RFID serial>
Sent in reply to AUTH if the card is either not know, or marked as expired/canceled.
VM Holly VREQ:<RFID serial>:<transaction number>:<amount>
Sent when a selection is keyed in. <amount> is in pence.
Holly VM VNOK:<RFID serial>:<transaction number>
Sent in response to VREQ if the purchase is permitted (e.g. credit limit won't be exceeded).
Holly VM VDNY:<RFID serial>:<transaction number>
Sent in response to VREQ is the vend should be denied for any reason.
VM Holly VSUC:<RFID serial>:<transaction number>:<position>
Sent after the VMC reports to the nanode that the product has been successfully vended.
VM Holly VFAL:<RFID serial>:<transaction number>
Sent if the VMC reports that the vend failed. ***UNTESTED***. Not sure if our vending machine can/would ever report a failed vend.
VM Holly VCAN:<RFID serial>:<transaction number>
Sent if the coin reject button is pressed. Will record a cancelled vend if an AUTH has been sent, but no VREQ yet received - otherwise it has no effect.
VM Holly INFO:<debug message>
Information message that can be sent at any stage - has no effect other than being written to a log on holly.
Variable Description
<RFID serial> RFID serial number - expected to be 9 digits long
<transaction number> Unique number assigned to the vending machine transaction when an AUTH message is received with an active RFID serial, and must be included in all related messages.
<position> Position in the vending machine as reported by the VMC. Note that this location is mapped to the locations codes displayed in the vending by holly (e.g. 41-31 reported here corresponds to location A1).

Example session

(card presented)
(Selection made)
(Product vended)

Source Code

Source code for the firmware running on the Nanode is in the github repo, the code of the server side component is on Google code (the relevant part is "nh-vend.cpp").