asdasdasd

Dependencies:   mbed

Fork of FINAL_PROJECT_4180 by Gedeon Nyengele

Revision:
11:1d7021c0739d
Parent:
10:c3556e27e576
Child:
12:5cb9ffad1ad7
diff -r c3556e27e576 -r 1d7021c0739d main.cpp
--- a/main.cpp	Mon Apr 25 01:57:10 2016 +0000
+++ b/main.cpp	Mon Apr 25 02:38:50 2016 +0000
@@ -14,8 +14,71 @@
 // hash table
 const int MAX_ENTRIES = 100;
 HASH_RECORD records[MAX_ENTRIES];
+int record_index = 0;
+
+enum STATE {STANDBY, ENROLL, AUTH, FP_ENROLL, FP_AUTH, MC_ENROLL, MC_AUTH, FACE_ENROLL, FACE_AUTH, SPEECH_ENROLL,
+            ENROLL_SUCCESS, AUTH_SUCCESS, ENROLL_FAIL, AUTH_FAIL, UNLOCK
+           };
+
+char user_id[4];
+char mag_card_data[250];
+int mc_bytes = 0;
+int temp;
+int temp1;
 
 int main()
 {
-   
+    STATE current_state = STANDBY;
+    while (true) {
+        switch (current_state) {
+            case STANDBY:
+                greeting(&lcd);
+                int input = read_keypad();
+                while (input != 10 && input !=  11) {
+                    wait(0.03);
+                    input = read_keypad();
+                }
+                if (input == 10) current_state = ENROLL;
+                else current_state = AUTH;
+                break;
+
+            case ENROLL:
+                if (get_user_id(user_id)) current_state = FP_ENROLL;
+                else current_state = ENROLL_FAIL;
+                break;
+
+            case FP_ENROLL:
+                if (fp_enroll(&fp)) {
+                    current_state = MC_ENROLL;
+                } else {
+                    current_state = ENROLL_FAIL;
+                }
+                break;
+
+            case MC_ENROLL:
+                read_mag_card(&mag_card, mag_card_data, &mc_bytes);
+                temp = hashcode(mag_card_data, mc_bytes);
+                temp1 = id_to_int(user_id, 4);
+                add_to_table(records, record_index++, temp1, temp);
+                current_state = FACE_ENROLL;                
+                break;
+
+            case FACE_ENROLL:
+                if (face_enroll(user_id, &android)) {
+                    current_state = SPEECH_ENROLL;
+                } else current_state = ENROLL_FAIL;
+                break;
+
+            case SPEECH_ENROLL:
+                if (speech_enroll(user_id, &android)) {
+                    current_state = ENROLL_SUCCESS;
+                } else current_state = ENROLL_FAIL;
+                break;
+
+            case ENROLL_SUCCESS:
+                success_display(&lcd, "ENROLLMENT SUCCESSFUL.");
+                current_state = STANDBY;
+                break;
+        }
+    }
 }