|
@@ -150,13 +150,13 @@ void updateLcd()
|
150
|
150
|
}
|
151
|
151
|
}
|
152
|
152
|
else if (status == LoginInProgress) {
|
153
|
|
- lcd.print(LOGIN_IN_PROGRESS);
|
|
153
|
+ lcd.print(LOGIN_IN_PROGRESS_LABEL);
|
154
|
154
|
}
|
155
|
155
|
else if (status == LoginFailed) {
|
156
|
|
- lcd.print(LOGIN_FAILED);
|
|
156
|
+ lcd.print(LOGIN_FAILED_LABEL);
|
157
|
157
|
}
|
158
|
158
|
else if (status == LoginSuccess) {
|
159
|
|
- lcd.print(LOGIN_SUCCESS);
|
|
159
|
+ lcd.print(LOGIN_SUCCESS_LABEL);
|
160
|
160
|
}
|
161
|
161
|
}
|
162
|
162
|
|
|
@@ -173,16 +173,30 @@ void login(String uid, String password)
|
173
|
173
|
status = LoginInProgress;
|
174
|
174
|
updateLcd();
|
175
|
175
|
|
176
|
|
- delay(LOGIN_FAILED_TIME * 1000);
|
177
|
|
-
|
178
|
176
|
hostCommunication.login(uid, password);
|
179
|
177
|
|
180
|
|
- status = LoginSuccess;
|
181
|
|
- updateLcd();
|
182
|
|
-
|
183
|
|
- delay(LOGIN_FAILED_TIME * 1000);
|
|
178
|
+ HostCommunicationResult res = hostCommunication.read(MAX_LOGIN_TIME * 1000);
|
184
|
179
|
|
185
|
|
- askUidPassword();
|
|
180
|
+ if (!res.isSuccess || res.length != sizeof(SERIAL_PACKET_TYPE_INT)) {
|
|
181
|
+ selfTest();
|
|
182
|
+ return;
|
|
183
|
+ }
|
|
184
|
+ else {
|
|
185
|
+ int loginRes = *(SERIAL_PACKET_TYPE_INT*)res.data;
|
|
186
|
+ if (loginRes == LOGIN_OK) {
|
|
187
|
+ status = LoginSuccess;
|
|
188
|
+ }
|
|
189
|
+ else if (loginRes == LOGIN_FAILED) {
|
|
190
|
+ status = LoginFailed;
|
|
191
|
+ }
|
|
192
|
+ else {
|
|
193
|
+ selfTest();
|
|
194
|
+ return;
|
|
195
|
+ }
|
|
196
|
+ updateLcd();
|
|
197
|
+ delay(LOGIN_FAILED_TIME * 1000);
|
|
198
|
+ askUidPassword();
|
|
199
|
+ }
|
186
|
200
|
}
|
187
|
201
|
|
188
|
202
|
void selfTest()
|