Skip to content

Commit 0daad7a

Browse files
author
Jaroslav Vysoky
committed
force input codes, structure repairing in arduino sketch
1 parent 57477d9 commit 0daad7a

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

access_system.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,12 @@ def loop():
134134
f.write(stime() + " service" + "\n")
135135
elif command.startswith("hardOPEN") or command.startswith("softOPEN"):
136136
f.write(stime() + " " + command + "\n")
137-
elif command.startswith("test"):
137+
elif command.startswith("test") or command.startswith("input"):
138138
f.write(stime() + " " + command + "\n")
139139
ser_port.write(command + "\n")
140+
elif command.startswith("send"):
141+
f.write(stime() + " " + command + "\n")
142+
ser_port.write(command[4:] + "\n")
140143
elif command[0] in "kc":
141144
# validate keyboard or card code
142145
f.write(stime() + " validate " + command + " - ")

wiegand_arduino_raspi.ino

+16-9
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ void loop() {
5555
else if (command.startsWith("test")) {
5656
testCodes(command.substring(4));
5757
}
58+
else if (command.startsWith("input")) {
59+
prefix = command.substring(5, 6);
60+
inCode = command.substring(6);
61+
wholeCode = true;
62+
}
5863
}
5964
if(wg.available())
6065
{
@@ -78,29 +83,31 @@ void loop() {
7883
inCode = String(wg.getCode(),HEX);
7984
wholeCode = true;
8085
}
81-
//Serial.print(prefix + inCode);
82-
if (wholeCode) {
83-
String prac = "";
84-
prac = prefix + inCode;
85-
if (testCodes(prac)) {
86-
keyUnlock(keylockPin, openMillis);
87-
inCode = "";
88-
wholeCode = false;
89-
}
86+
}
87+
//Serial.print(prefix + inCode);
88+
if (wholeCode) {
89+
String prac = "";
90+
prac = prefix + inCode;
91+
if (testCodes(prac)) {
92+
keyUnlock(keylockPin, openMillis);
93+
inCode = "";
94+
wholeCode = false;
9095
}
9196
}
9297
}
9398

9499
void keyUnlock(byte pin, int time) {
95100
digitalWrite(pin, LOW);
96101
digitalWrite(monitorPin, HIGH);
102+
Serial.println("UNLOCKED...");
97103
delay(time);
98104
// if code is in web codes too - kill open command
99105
while (Serial.available()) {
100106
byte inByte = Serial.read();
101107
}
102108
digitalWrite(pin, HIGH) ;
103109
digitalWrite(monitorPin, LOW);
110+
Serial.println("LOCKED...");
104111
}
105112

106113
void listCodes() {

0 commit comments

Comments
 (0)