Time Tracker

= Overview =

Teensy, with the following things attached:

*Laser input
*Text LCD
*RFID Reader
*TP-Link router

Usage flow:

#User swipes RFID,
#rfid & odometer are both logged to the internets
#The server returns if the user is authorized
#laser is enabled
#During cutting, the time counts up
#User swipes RFID
#rfid & odometer value are both logged to the internets
#laser is disabled

= Source Code =

RFID Laser Odometer source code can be found here: [https://github.com/atom-bomb/laser-rfid https://github.com/atom-bomb/laser-rfid]

= Authentication =

All calls must contain ‘ts’ and ‘hash’. ts is a unix timestamp. hash is calculated as follows:

query_string = "cmd=login&rfid=ABCDEF01234&odometer=464123&ts=1345669414"; //example
key = "mYsEcReTkEy"; // example
hash = sha256(query_string + key);
query_string += "&hash=" + hash;

= Commands =

== login ==

=== Inputs ===

*rfid – the rfid value read from the key
*odometer – the current odometer value

=== Outputs ===

Either:

*true|Remaining Time|Remaining Balance|Message|Rate|Name
*false|Remaining Time|Remaining Balance|Message

Three values separated by | symbol. “Remaining Time” is in seconds, “Remaining Balance” is in dollars. Eg: “true|895|7.46” or “false|0|-17.24”. Message will be “OK” or an error message explaining why the person can’t be lasering right now (invalid RFID, not a member, hasn’t taken laser class, etc). “rate” is dollars per minute of cutting time, like “0.30”. “name” is the name of the person logged in

=== Logic ===

*Checks if someone is already logged in. If so, automatically call logout command with the given odometer value (see below)
*Logs the inputs to a log file (just in case). Converts rfid to userid, looks up their remaining balance in the DB. Stores the userID somewhere, for when they log out.

=== Calculating Remaining Time ===

*If the user is in a specific list of ‘investors’, remaining time = dollars * 4 * 60 seconds.
*If the user is an AMT member, remaining time = dollars * 2 * 60 seconds.
*Else, remaining time = dollars * 60 seconds.

== logout ==

=== Input ===

*odometer – the current odometer value

=== Output ===

Either

*true|OK
*false|Some Message

=== Logic ===

*Logs the inputs to a log file (just in case). Checks the userID of the currently logged in user (stored somewhere). Subtracts the two odometer values, adds the time used to the user’s account. Subtract the corresponding amount of money from their balance (basically use the opposite of the ‘remaining time’ algorithm above)

= Payment =

*Need a page where I can manually input a rfid or email or userid, and a dollar amount, and it adds that amount to their account.
*Later: Hook up to paypal API, automatically add payments to account balances.

*”’Category:”'[[Category:Laser]] [[Category:Laser Upkeep]]

Leave a Reply

Your email address will not be published. Required fields are marked *