Fixing issue #5 where door would remain unlocked when user presents a card. Also fixed #6 where F2 was logged unnecessarily.

This commit is contained in:
Will Bradley 2013-03-21 08:21:37 -07:00
parent 8e989ce4a2
commit 055754b484
2 changed files with 38 additions and 28 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Open Source RFID Access Controller - Ethernet Branch * Open Source RFID Access Controller - Ethernet Branch
* *
* 3/11/2013 v0.04 (branch based on upstream 4/3/2011 v1.32) * 3/21/2013 v0.05 (branch based on upstream 4/3/2011 v1.32)
* Will Bradley - will@heatsynclabs.org * Will Bradley - will@heatsynclabs.org
* Short Tie - tie.short@gmail.com * Short Tie - tie.short@gmail.com
* *
@ -100,8 +100,7 @@
#include <PCATTACH.h> // Pcint.h implementation, allows for >2 software interupts. #include <PCATTACH.h> // Pcint.h implementation, allows for >2 software interupts.
/* Static user List - Implemented as an array for testing and access override //-------- begin user config section --------
*/
#define DEBUG 2 // Set to 2 for display of raw tag numbers in log files, 1 for only denied, 0 for never. #define DEBUG 2 // Set to 2 for display of raw tag numbers in log files, 1 for only denied, 0 for never.
@ -112,6 +111,13 @@ const long superUserList[] = { adam, bob, carl}; // Super user table (cannot b
#define PRIVPASSWORD 0x1234 // Console "priveleged mode" password #define PRIVPASSWORD 0x1234 // Console "priveleged mode" password
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);
//-------- end user config section --------
#define DOORDELAY 5000 // How long to open door lock once access is granted. (2500 = 2.5s) #define DOORDELAY 5000 // How long to open door lock once access is granted. (2500 = 2.5s)
#define SENSORTHRESHOLD 100 // Analog sensor change that will trigger an alarm (0..255) #define SENSORTHRESHOLD 100 // Analog sensor change that will trigger an alarm (0..255)
#define NUM_SENSORS 4 // The number of sensors #define NUM_SENSORS 4 // The number of sensors
@ -193,7 +199,7 @@ unsigned long alarmSirenTimer=0; // Keep track of how long alarm h
unsigned long consolefailTimer=0; // Console password timer for failed logins unsigned long consolefailTimer=0; // Console password timer for failed logins
byte consoleFail=0; byte consoleFail=0;
#define numUsers (sizeof(superUserList)/sizeof(long)) //User access array size (used in later loops/etc) #define numUsers (sizeof(superUserList)/sizeof(long)) //User access array size (used in later loops/etc)
#define NUMDOORS (sizeof(doorPin)/sizeof(byte)) #define NUMDOORS (sizeof(doorPin)/sizeof(byte)) //TODO: NUMDOORS isn't used and doorPin isn't defined... remove?
#define numAlarmPins (sizeof(analogsensorPins)/sizeof(byte)) #define numAlarmPins (sizeof(analogsensorPins)/sizeof(byte))
//Other global variables //Other global variables
@ -229,12 +235,6 @@ char logKeys[40]={0};
int logData[40]={0}; int logData[40]={0};
int logCursor=0; int logCursor=0;
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);
// Initialize the Ethernet server library // Initialize the Ethernet server library
// with the IP address and port you want to use // with the IP address and port you want to use
// (port 80 is default for HTTP): // (port 80 is default for HTTP):
@ -339,8 +339,7 @@ void loop() // Main branch, runs over and ov
PROGMEMprintln(client,title); PROGMEMprintln(client,title);
PROGMEMprintln(client,help); PROGMEMprintln(client,help);
} }
else{ else {
int queryStart = readString.indexOf("?");
if(readString.indexOf("?e=") > 0 || readString.indexOf("&e=") > 0) { // login if(readString.indexOf("?e=") > 0 || readString.indexOf("&e=") > 0) { // login
int offset = readString.indexOf("e="); int offset = readString.indexOf("e=");
@ -351,12 +350,13 @@ void loop() // Main branch, runs over and ov
} }
else { else {
client.println("authfail"); client.println("authfail");
break; // we don't need extra errors below; we already know about the authfail.
} }
} }
if(privmodeEnabled==true) { if(privmodeEnabled==true) {
switch(readString[queryStart +1]){ switch(readString[readString.indexOf("?")+1]){
case 's': { // show user case 's': { // show user
int offset = readString.indexOf("?s"); int offset = readString.indexOf("?s");
@ -1067,8 +1067,17 @@ int processTagAccess(long reader, int doorNum) {
log(LOG_ACCESS_GRANTED,reader, doorNum); // Log and unlock door log(LOG_ACCESS_GRANTED,reader, doorNum); // Log and unlock door
alarmState(0); alarmState(0);
armAlarm(0); // Deactivate Alarm armAlarm(0); // Deactivate Alarm
switch(doorNum){
case 1:
door1locktimer=millis();
doorUnlock(doorNum);
break;
case 2:
door2locktimer=millis(); door2locktimer=millis();
doorUnlock(doorNum); // Unlock the door. doorUnlock(doorNum);
break;
}
keypadGranted=1; keypadGranted=1;
break; break;
} }
@ -1082,8 +1091,16 @@ int processTagAccess(long reader, int doorNum) {
alarmState(0); alarmState(0);
armAlarm(0); // Deactivate Alarm armAlarm(0); // Deactivate Alarm
chirpAlarm(1); chirpAlarm(1);
switch(doorNum){
case 1:
door1locktimer=millis(); door1locktimer=millis();
doorUnlock(doorNum); // Unlock the door. doorUnlock(doorNum);
break;
case 2:
door2locktimer=millis();
doorUnlock(doorNum);
break;
}
keypadGranted=1; keypadGranted=1;
} }
else{ else{
@ -1318,7 +1335,7 @@ void log(byte Action, long LongInfo, byte ShortInfo)
break; break;
} }
case LOG_PRIVELEDGE_FAILED: { case LOG_PRIVELEDGE_FAILED: {
addToLog('F',2); addToLog('F',ShortInfo);
break; break;
} }
case LOG_CLEAR_USERS: { case LOG_CLEAR_USERS: {
@ -1558,7 +1575,7 @@ boolean login(long input) {
return true; return true;
} }
else { else {
log(LOG_LOGIN_FAIL,0,0); //log(LOG_LOGIN_FAIL,0,0);
privmodeEnabled=false; privmodeEnabled=false;
if(consoleFail==0) { // Set the timeout for failed logins if(consoleFail==0) { // Set the timeout for failed logins
consolefailTimer=millis(); consolefailTimer=millis();

View File

@ -15,13 +15,6 @@ https://github.com/zyphlar/Open_Access_Control_Ethernet
For the latest version of the UPSTREAM software, visit: For the latest version of the UPSTREAM software, visit:
http://code.google.com/p/open-access-control/ http://code.google.com/p/open-access-control/
Features in Ethernet branch v0.01:
-Extremely rudimentary logging via HTTP using Arduino Ethernet
New features in v1.32:
-Serial console password with bad attempts lockout
-Fixed minor bugs, remove some unused functions
Note: Unpack the libraries (WIEGAND26, DS1307, PCATTACH) into your arduino Note: Unpack the libraries (WIEGAND26, DS1307, PCATTACH) into your arduino
libraries directory. This is usually: libraries directory. This is usually: