displaySuccess after reading card
This commit is contained in:
parent
b9be9b84ea
commit
dd86fbf687
1 changed files with 20 additions and 23 deletions
43
the-cup.ino
43
the-cup.ino
|
|
@ -41,8 +41,27 @@ void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
pinMode(LED_PIN, OUTPUT);
|
pinMode(LED_PIN, OUTPUT);
|
||||||
displaySuccess();
|
|
||||||
|
|
||||||
|
reader.PCD_Init(); // Init each MFRC522 card.
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (reader.PICC_IsNewCardPresent() && reader.PICC_ReadCardSerial()) {
|
||||||
|
char reader_uid[32] = "";
|
||||||
|
read_card(reader_uid);
|
||||||
|
send_uid(reader_uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_card(char reader_uid[]) {
|
||||||
|
reader.PICC_HaltA();
|
||||||
|
reader.PCD_StopCrypto1();
|
||||||
|
byte_to_string(reader.uid.uidByte, 4, reader_uid);
|
||||||
|
Serial.println(reader_uid);
|
||||||
|
displaySuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
void send_uid(char reader_uid[]) {
|
||||||
WiFiManager wm;
|
WiFiManager wm;
|
||||||
bool res;
|
bool res;
|
||||||
res = wm.autoConnect("KLUK"); // password protected ap
|
res = wm.autoConnect("KLUK"); // password protected ap
|
||||||
|
|
@ -57,27 +76,6 @@ void setup() {
|
||||||
Serial.println("connected...yeey :)");
|
Serial.println("connected...yeey :)");
|
||||||
displaySuccess();
|
displaySuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.PCD_Init(); // Init each MFRC522 card.
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
|
|
||||||
if (reader.PICC_IsNewCardPresent() && reader.PICC_ReadCardSerial()) {
|
|
||||||
char reader_uid[32] = "";
|
|
||||||
read_card(reader_uid);
|
|
||||||
send_uid(reader_uid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_card(char reader_uid[]) {
|
|
||||||
reader.PICC_HaltA();
|
|
||||||
reader.PCD_StopCrypto1();
|
|
||||||
byte_to_string(reader.uid.uidByte, 4, reader_uid);
|
|
||||||
Serial.println(reader_uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
void send_uid(char reader_uid[]) {
|
|
||||||
auto client = std::make_unique<BearSSL::WiFiClientSecure>();
|
auto client = std::make_unique<BearSSL::WiFiClientSecure>();
|
||||||
|
|
||||||
client->setInsecure();
|
client->setInsecure();
|
||||||
|
|
@ -104,7 +102,6 @@ void send_uid(char reader_uid[]) {
|
||||||
|
|
||||||
https.end();
|
https.end();
|
||||||
Serial.print("[HTTPS] ended...\n");
|
Serial.print("[HTTPS] ended...\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void byte_to_string(byte array[], unsigned int len, char buffer[]) {
|
void byte_to_string(byte array[], unsigned int len, char buffer[]) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue