Browse Source

added login result display

develop
Robin Thoni 8 years ago
parent
commit
33f4ee1dd7
1 changed files with 31 additions and 1 deletions
  1. 31
    1
      main.ino

+ 31
- 1
main.ino View File

25
 #define SELF_TEST_ERROR_LABEL "Error: "
25
 #define SELF_TEST_ERROR_LABEL "Error: "
26
 #define UID_LABEL "UID:"
26
 #define UID_LABEL "UID:"
27
 #define PWD_LABEL "PWD:"
27
 #define PWD_LABEL "PWD:"
28
+#define LOGIN_IN_PROGRESS "Login..."
29
+#define LOGIN_FAILED "Login failed"
30
+#define LOGIN_SUCCESS "Access granted"
31
+
28
 #define UID_MAX_LEN 12
32
 #define UID_MAX_LEN 12
29
 #define PWD_MAX_LEN 12
33
 #define PWD_MAX_LEN 12
30
 String uid;
34
 String uid;
32
 enum Status {
36
 enum Status {
33
     Uid,
37
     Uid,
34
     Password,
38
     Password,
35
-    SelfTest
39
+    SelfTest,
40
+    LoginInProgress,
41
+    LoginFailed,
42
+    LoginSuccess
36
 };
43
 };
37
 Status status = Uid;
44
 Status status = Uid;
38
 
45
 
39
 #define MAX_IDLE_TIME 20
46
 #define MAX_IDLE_TIME 20
40
 unsigned long lastActivity = 0;
47
 unsigned long lastActivity = 0;
48
+
49
+#define LOGIN_FAILED_TIME 2
50
+
41
 #define SELF_TEST_INTERVAL 60
51
 #define SELF_TEST_INTERVAL 60
42
 #define SELF_TEST_ERROR_INTERVAL 2
52
 #define SELF_TEST_ERROR_INTERVAL 2
43
 #define MAX_SELF_TEST_TIME 5
53
 #define MAX_SELF_TEST_TIME 5
155
             lcd.print(lastSelfTestResult);
165
             lcd.print(lastSelfTestResult);
156
         }
166
         }
157
     }
167
     }
168
+    else if (status == LoginInProgress) {
169
+        lcd.print(LOGIN_IN_PROGRESS);
170
+    }
171
+    else if (status == LoginFailed) {
172
+        lcd.print(LOGIN_FAILED);
173
+    }
174
+    else if (status == LoginSuccess) {
175
+        lcd.print(LOGIN_SUCCESS);
176
+    }
158
 }
177
 }
159
 
178
 
160
 void askUidPassword()
179
 void askUidPassword()
167
 
186
 
168
 void login(String uid, String password)
187
 void login(String uid, String password)
169
 {
188
 {
189
+    status = LoginInProgress;
190
+    updateLcd();
191
+
192
+    delay(LOGIN_FAILED_TIME * 1000);
193
+
170
     Serial.println(uid);
194
     Serial.println(uid);
171
     Serial.println(password);
195
     Serial.println(password);
196
+
197
+    status = LoginSuccess;
198
+    updateLcd();
199
+
200
+    delay(LOGIN_FAILED_TIME * 1000);
201
+
172
     askUidPassword();
202
     askUidPassword();
173
 }
203
 }
174
 
204
 

Loading…
Cancel
Save