+ /* we have a valid username & PIN number */
+ /* either ask for a 2-digit selection, or wait for coins to be entered */
+ /* get the username somehow? */
+ set_msg("ENTER SELECTION OR INSERT COINS ", WRAP_SCROLL);
+ selection = 0;
+ while(1) {
+ if (coin_value) { /* we have coins inserted */
+ int prev_coin = 0;
+ /* alternate between the price and a confirm message */
+ while (coin_value) {
+ if (prev_coin != coin_value) {
+ print_amount(coin_value);
+ append_msg("0: CONFIRM", WRAP_ALTERNATE);
+ prev_coin = coin_value;
+ }
+ keypad_read();
+ if (keypad_pressed()) {
+ switch (last_key) {
+ case KEY_RESET:
+ scroll_msg("PRESS COIN REFUND");
+ while (coin_value);
+ break;
+ case KEY_0:
+ switch (server_credit_account(uid, pin, coin_value)) {
+ case CREDIT_OK:
+ coin_eat();
+ set_msg(" SUCCESS! ", WRAP_NONE);
+ delay(1000);
+ break;
+ case CREDIT_FAIL:
+ set_msg(" FAILED! " "PRESS COIN" " REFUND ",
+ WRAP_ALTERNATE);
+ while (coin_value);
+ break;
+ }
+ break;
+ }
+ }
+ }
+ /* coins were refunded */
+ }
+
+ if (selection) { /* half way through a selection */
+ keypad_read();
+ if (keypad_pressed()) {
+ switch (last_key) {
+ case KEY_RESET:
+ selection = 0;
+ break;
+ case 0:
+ break;
+ default:
+ selection = selection * 10 + (last_key%10);
+ make_request(selection);
+ selection = 0;
+ }
+ }
+ } else { /* else listen for the first key of a selection */
+ keypad_read();
+ if (keypad_pressed()) {
+ switch (last_key) {
+ case KEY_RESET:
+ return;
+ case 0:
+ break;
+ default:
+ selection = last_key%10;
+ }
+ }
+ }
+ }
+}
+
+void load_default_msg() {
+ /* FIXME: want this message to be changeable from the server */
+ set_msg("UNIVERSITY COMPUTER CLUB *** INSERT COINS OR USER-ID *** ",
+ WRAP_SCROLL);
+}
+
+void service_menu() {
+ while (door_open()) { /* don't quit until door is closed */
+
+ }