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:
|
## Protocol:
|
||||||
READERID is 5 Digits
|
READERID is 5 Digits
|
||||||
1. Hello: Topic="fabreader", Payload="READERID"
|
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. Request: Topic="fabreader/READERID/requestOTA", Payload=256 Bytes APDU Command
|
||||||
1. Response: Topic="fabreader/READERID/responseOTA", Payload=256 Bytes APDU Response
|
1. Response: Topic="fabreader/READERID/responseOTA", Payload=256 Bytes APDU Response
|
||||||
1. Stop: Topic="fabreader/READERID/stopOTA", Payload=NULL
|
1. Stop: Topic="fabreader/READERID/stopOTA", Payload=NULL
|
||||||
1. Cancel: Topic="fabreader/READERID/cancelOTA", Payload=NULL
|
1. Cancel: Topic="fabreader/READERID/cancelOTA", Payload=NULL
|
||||||
|
1. Restart: Topic="fabreader/READERID/restartOTA", Payload=NULL
|
||||||
|
|
||||||
## Procedure:
|
## Procedure:
|
||||||
After Start Reader sends "Hello".
|
After Start Reader sends "Hello".
|
||||||
@ -17,4 +18,7 @@ After new Card is on Reader:
|
|||||||
|
|
||||||
Repeat Request and Response until:
|
Repeat Request and Response until:
|
||||||
"Stop" <- from Server
|
"Stop" <- from Server
|
||||||
"Cancel" -> to 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()
|
bool NFC::isCardLost()
|
||||||
{
|
{
|
||||||
Serial.println(rfid->PICC_ReadCardSerial());
|
MFRC522::StatusCode status = rfid->PICC_Select(&(uid));
|
||||||
Serial.println(rfid->PICC_ReadCardSerial());
|
Serial.printf("PICC_Select: 0x%02x\n", status);
|
||||||
Serial.println(rfid->PICC_ReadCardSerial());
|
|
||||||
return rfid->PICC_ReadCardSerial() && rfid->uid.uidByte != uid.uidByte;
|
return status != MFRC522::STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MFRC522::StatusCode NFC::Transceive(byte* command, byte command_len, byte* response, byte response_len)
|
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);
|
return rfid->PCD_TransceiveData(command, command_len, response, &response_len, NULL, 0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
MFRC522::Uid NFC::getUID()
|
||||||
|
{
|
||||||
|
return uid;
|
||||||
}
|
}
|
@ -18,7 +18,8 @@ class NFC
|
|||||||
bool hasNewCard();
|
bool hasNewCard();
|
||||||
void selectCard();
|
void selectCard();
|
||||||
void deselectCard();
|
void deselectCard();
|
||||||
bool isCardLost();
|
bool isCardLost();
|
||||||
|
MFRC522::Uid getUID();
|
||||||
|
|
||||||
MFRC522::StatusCode Transceive(byte* command, byte command_len, byte* response, byte response_len);
|
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";
|
char topic[] = "fabreader/00000/startOTA";
|
||||||
sprintf(topic, "fabreader/%05d/startOTA", id);
|
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)
|
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";
|
char topic_stopOTA[] = "fabreader/00000/stopOTA";
|
||||||
sprintf(topic_stopOTA, "fabreader/%05d/stopOTA", id);
|
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))
|
if(strcmp(topic, topic_requestOTA))
|
||||||
{
|
{
|
||||||
byte response[APDU_BUFFER_SIZE] = {0};
|
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);
|
mqtt->publish(topic_responseOTA, response, APDU_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
else if(strcmp(topic, topic_stopOTA))
|
||||||
if(strcmp(topic, topic_stopOTA))
|
|
||||||
{
|
{
|
||||||
nfc->deselectCard();
|
nfc->deselectCard();
|
||||||
activeOTA = false;
|
activeOTA = false;
|
||||||
}
|
}
|
||||||
|
else if(strcmp(topic, topic_restartOTA))
|
||||||
|
{
|
||||||
|
nfc->deselectCard();
|
||||||
|
if(nfc->hasNewCard())
|
||||||
|
{
|
||||||
|
nfc->selectCard();
|
||||||
|
startOTA();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OTAProxy::cancelOTA()
|
void OTAProxy::cancelOTA()
|
||||||
|
@ -83,9 +83,9 @@ void callback(char* topic, byte* payload, unsigned int length)
|
|||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
config.ID = 1;
|
config.ID = 1;
|
||||||
strcpy(config.WLAN_SSID, "");
|
strcpy(config.WLAN_SSID, "SSID");
|
||||||
strcpy(config.WLAN_Password, "");
|
strcpy(config.WLAN_Password, "dodahV3eePeiducaicae");
|
||||||
strcpy(config.MQTT_Broker, "");
|
strcpy(config.MQTT_Broker, "10.7.255.233");
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.print("\n\n\n");
|
Serial.print("\n\n\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user