Fix Card ID display overflow
This commit is contained in:
parent
179cb05cbf
commit
9477f45e58
|
@ -8,6 +8,7 @@ String cardLink(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const
|
|||
String cardBalance(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId);
|
||||
String cardTransaction(WiFiClient* wifi, HTTPClient* http, const String& apiUrl, const String& cardId, const String& amount);
|
||||
String splitString(const String& data, char separator, int index);
|
||||
String cardIdDisplay(const String& id);
|
||||
|
||||
enum e_state {
|
||||
STATE_IDLE,
|
||||
|
|
|
@ -176,7 +176,7 @@ void loop() {
|
|||
for (Reader* reader : readers) {
|
||||
if (reader->isNewCardPresent()) {
|
||||
scannedCardId = reader->getCardUid();
|
||||
lastStatusText = "Card #" + scannedCardId;
|
||||
lastStatusText = cardIdDisplay(scannedCardId);
|
||||
scannedCardReader = reader;
|
||||
state = STATE_TRANSACT_VERIFY;
|
||||
return;
|
||||
|
@ -215,7 +215,7 @@ void loop() {
|
|||
return;
|
||||
}
|
||||
else {
|
||||
lastStatusText = "Card #" + scannedCardId;
|
||||
lastStatusText = cardIdDisplay(scannedCardId);
|
||||
state = STATE_LINK_VERIFY;
|
||||
return;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ void loop() {
|
|||
case STATE_LINK_CARD_RESCAN:
|
||||
if (scannedCardReader->isNewCardPresent()) {
|
||||
if (scannedCardId == scannedCardReader->getCardUid()) {
|
||||
lastStatusText = "Card #" + scannedCardId;
|
||||
lastStatusText = cardIdDisplay(scannedCardId);
|
||||
state = STATE_LINK_VERIFY;
|
||||
return;
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ void loop() {
|
|||
for (Reader* reader : readers) {
|
||||
if (reader->isNewCardPresent()) {
|
||||
scannedCardId = reader->getCardUid();
|
||||
lastStatusText = "Card #" + scannedCardId;
|
||||
lastStatusText = cardIdDisplay(scannedCardId);
|
||||
state = STATE_BALANCE_VERIFY;
|
||||
return;
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ void loop() {
|
|||
tone(PIN_BUZZER, NOTE_NONE, 150);
|
||||
lastStatusText = cardBalance(wifi, http, apiUrl, scannedCardId);
|
||||
if (lastStatusText.startsWith("S:")) {
|
||||
lastStatusText = lastStatusText + ":Card #" + scannedCardId;
|
||||
lastStatusText = lastStatusText + ":" + cardIdDisplay(scannedCardId);
|
||||
state = STATE_RESULT_DISPLAY;
|
||||
} else {
|
||||
tone(PIN_BUZZER, NOTE_CS5, 100);
|
||||
|
@ -292,7 +292,7 @@ void loop() {
|
|||
timer = millis();
|
||||
case STATE_RESULT_SUCCESS:
|
||||
if (cooldownSecondsRemaining(gTimeout, timer) <= 4) {
|
||||
lastStatusText = lastStatusText + ":Card #" + scannedCardId;
|
||||
lastStatusText = lastStatusText + ":" + cardIdDisplay(scannedCardId);
|
||||
state = STATE_RESULT_DISPLAY;
|
||||
}
|
||||
case STATE_RESULT_FAILURE:
|
||||
|
|
|
@ -157,3 +157,12 @@ String cardTransaction(WiFiClient* wifi, HTTPClient* http, const String& apiUrl,
|
|||
}
|
||||
return String("E:Internal Error ") + httpResponseCode;
|
||||
}
|
||||
|
||||
String cardIdDisplay(const String& id){
|
||||
if (id.length() <= 14)
|
||||
return "Card #" + id;
|
||||
else if (id.length() <= 19)
|
||||
return "#" + id;
|
||||
else
|
||||
return "#" + id.substring(0, 16) + "...";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue