mirror of
https://gitlab.com/fabinfra/fabhardware/fabreader.git
synced 2025-03-13 23:21:44 +01:00
Test CardLost
This commit is contained in:
parent
72c052fc59
commit
e4049af19e
@ -1,11 +1,12 @@
|
||||
## Protocol:
|
||||
READERID is 5 Digits
|
||||
1. Hello: Topic="fabreader", Payload="READERID"
|
||||
1. Start: Topic="fabreader/READERID/startOTA", Payload=NULL
|
||||
1. Start: Topic="fabreader/READERID/startOTA", Payload=UID of Card
|
||||
1. Request: Topic="fabreader/READERID/requestOTA", Payload=256 Bytes APDU Command
|
||||
1. Response: Topic="fabreader/READERID/responseOTA", Payload=256 Bytes APDU Response
|
||||
1. Stop: Topic="fabreader/READERID/stopOTA", Payload=NULL
|
||||
1. Cancel: Topic="fabreader/READERID/cancelOTA", Payload=NULL
|
||||
1. Restart: Topic="fabreader/READERID/restartOTA", Payload=NULL
|
||||
|
||||
## Procedure:
|
||||
After Start Reader sends "Hello".
|
||||
@ -18,3 +19,6 @@ After new Card is on Reader:
|
||||
Repeat Request and Response until:
|
||||
"Stop" <- from Server
|
||||
"Cancel" -> to Server
|
||||
|
||||
If FabReader works as deadmen switch the OTA connection is not stopped and the next check can be started with restartOTA.
|
||||
If DESFire Card uses Random UID the UID changes every new connection, so the connections stays active until the server restartsOTA and performs new OTA.
|
@ -43,13 +43,18 @@ void NFC::deselectCard()
|
||||
|
||||
bool NFC::isCardLost()
|
||||
{
|
||||
Serial.println(rfid->PICC_ReadCardSerial());
|
||||
Serial.println(rfid->PICC_ReadCardSerial());
|
||||
Serial.println(rfid->PICC_ReadCardSerial());
|
||||
return rfid->PICC_ReadCardSerial() && rfid->uid.uidByte != uid.uidByte;
|
||||
MFRC522::StatusCode status = rfid->PICC_Select(&(uid));
|
||||
Serial.printf("PICC_Select: 0x%02x\n", status);
|
||||
|
||||
return status != MFRC522::STATUS_OK;
|
||||
}
|
||||
|
||||
MFRC522::StatusCode NFC::Transceive(byte* command, byte command_len, byte* response, byte response_len)
|
||||
{
|
||||
return rfid->PCD_TransceiveData(command, command_len, response, &response_len, NULL, 0, true);
|
||||
}
|
||||
|
||||
MFRC522::Uid NFC::getUID()
|
||||
{
|
||||
return uid;
|
||||
}
|
@ -19,6 +19,7 @@ class NFC
|
||||
void selectCard();
|
||||
void deselectCard();
|
||||
bool isCardLost();
|
||||
MFRC522::Uid getUID();
|
||||
|
||||
MFRC522::StatusCode Transceive(byte* command, byte command_len, byte* response, byte response_len);
|
||||
};
|
||||
|
@ -21,7 +21,8 @@ void OTAProxy::startOTA()
|
||||
|
||||
char topic[] = "fabreader/00000/startOTA";
|
||||
sprintf(topic, "fabreader/%05d/startOTA", id);
|
||||
mqtt->publish(topic, 0);
|
||||
MFRC522::Uid uid = nfc->getUID();
|
||||
mqtt->publish(topic, uid.uidByte, int(uid.size));
|
||||
}
|
||||
|
||||
void OTAProxy::continueOTA(char* topic, byte* payload, unsigned int length)
|
||||
@ -35,6 +36,9 @@ void OTAProxy::continueOTA(char* topic, byte* payload, unsigned int length)
|
||||
char topic_stopOTA[] = "fabreader/00000/stopOTA";
|
||||
sprintf(topic_stopOTA, "fabreader/%05d/stopOTA", id);
|
||||
|
||||
char topic_restartOTA[] = "fabreader/00000/restartOTA";
|
||||
sprintf(topic_restartOTA, "fabreader/%05d/restartOTA", id);
|
||||
|
||||
if(strcmp(topic, topic_requestOTA))
|
||||
{
|
||||
byte response[APDU_BUFFER_SIZE] = {0};
|
||||
@ -42,12 +46,20 @@ void OTAProxy::continueOTA(char* topic, byte* payload, unsigned int length)
|
||||
|
||||
mqtt->publish(topic_responseOTA, response, APDU_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
if(strcmp(topic, topic_stopOTA))
|
||||
else if(strcmp(topic, topic_stopOTA))
|
||||
{
|
||||
nfc->deselectCard();
|
||||
activeOTA = false;
|
||||
}
|
||||
else if(strcmp(topic, topic_restartOTA))
|
||||
{
|
||||
nfc->deselectCard();
|
||||
if(nfc->hasNewCard())
|
||||
{
|
||||
nfc->selectCard();
|
||||
startOTA();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OTAProxy::cancelOTA()
|
||||
|
@ -83,9 +83,9 @@ void callback(char* topic, byte* payload, unsigned int length)
|
||||
void setup()
|
||||
{
|
||||
config.ID = 1;
|
||||
strcpy(config.WLAN_SSID, "");
|
||||
strcpy(config.WLAN_Password, "");
|
||||
strcpy(config.MQTT_Broker, "");
|
||||
strcpy(config.WLAN_SSID, "SSID");
|
||||
strcpy(config.WLAN_Password, "dodahV3eePeiducaicae");
|
||||
strcpy(config.MQTT_Broker, "10.7.255.233");
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.print("\n\n\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user