basic commands
This commit is contained in:
parent
853389266f
commit
7e9d7e96ea
1 changed files with 24 additions and 7 deletions
31
src/main.cpp
31
src/main.cpp
|
@ -7,11 +7,15 @@ const unsigned long displayDelay = 1000; // Delay in milliseconds after which th
|
|||
unsigned int bitCount = 0; // Variable to keep track of the bit count
|
||||
unsigned int maxReaderWaitTime = 9000; // Variable to timeout reader after too long of no data.
|
||||
|
||||
void commandLockDoor() {
|
||||
// Add code to lock the door here (e.g., activate a relay, if applicable)
|
||||
Serial.println("DOOR_STATUS: locked");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void commandUnlockDoor() {
|
||||
// Add code to unlock the door here (e.g., deactivate a relay, if applicable)
|
||||
Serial.println("DOOR_STATUS: unlocked");
|
||||
}
|
||||
|
||||
void handleInterrupt(int bitValue) {
|
||||
static unsigned long lastInterruptTime = 0;
|
||||
|
@ -71,11 +75,9 @@ void setup() {
|
|||
digitalWrite(ALARM_PIN, HIGH); // Do not set to low or it will constantly beep.
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void loop() {
|
||||
// Check if new data is available
|
||||
|
||||
|
@ -108,7 +110,7 @@ void loop() {
|
|||
#endif
|
||||
|
||||
String fullCardID = String(facilityID)+":"+String(cardID);
|
||||
Serial.print("FULL-CARD-ID: ");
|
||||
Serial.print("FULL_CARD_ID: ");
|
||||
Serial.println(fullCardID);
|
||||
|
||||
|
||||
|
@ -123,4 +125,19 @@ void loop() {
|
|||
bitCount = 0; // Reset the bit count
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check for commands from the serial interface
|
||||
if (Serial.available() > 0) {
|
||||
String command = Serial.readString();
|
||||
command.trim();
|
||||
|
||||
if (command.equals("unlock")) {
|
||||
commandUnlockDoor();
|
||||
} else if (command.equals("lock")) {
|
||||
commandLockDoor();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue