Updating version, fixing minor issues with URL commands and logging

This commit is contained in:
Will Bradley 2013-03-11 23:44:27 -07:00
parent d028054ad8
commit 8e989ce4a2

View File

@ -1,7 +1,7 @@
/* /*
* Open Source RFID Access Controller - Ethernet Branch * Open Source RFID Access Controller - Ethernet Branch
* *
* 2/9/2013 v0.03 (branch based on upstream 4/3/2011 v1.32) * 3/11/2013 v0.04 (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
* *
@ -79,8 +79,7 @@
* s=alarm sensor (# zone) * s=alarm sensor (# zone)
* t=alarm trained (#=sensor value) * t=alarm trained (#=sensor value)
* T=alarm triggered (0) * T=alarm triggered (0)
* U=unlocked door (1=door1, 2=door2, # card num) * U=unlocked door (1=door1, 2=door2)
* u=second half of card
* Z=user db cleared (0) * Z=user db cleared (0)
* z=log cleared (0) * z=log cleared (0)
* Log Format: * Log Format:
@ -225,7 +224,7 @@ unsigned long keypadValue=0;
boolean privmodeEnabled = false; // Switch for enabling "priveleged" commands boolean privmodeEnabled = false; // Switch for enabling "priveleged" commands
// Log buffer // Log buffer
int logLevel=0; int logLevel=2;
char logKeys[40]={0}; char logKeys[40]={0};
int logData[40]={0}; int logData[40]={0};
int logCursor=0; int logCursor=0;
@ -499,8 +498,12 @@ void loop() // Main branch, runs over and ov
chirpAlarm(1); chirpAlarm(1);
PROGMEMprintln(client,lockboth); PROGMEMprintln(client,lockboth);
} }
printStatus(client);
} }
else { // not unlocking a specific door; unlock all.
PROGMEMprintln(client,lockboth);
lockall();
}
printStatus(client);
break; break;
} }
case '1': { // disarm case '1': { // disarm
@ -592,6 +595,9 @@ void loop() // Main branch, runs over and ov
} }
break; break;
} }
case '9': {
printStatus(client);
}
default: {} default: {}
} // End switch on query letter } // End switch on query letter
} // End Calls that require authentization } // End Calls that require authentization
@ -661,17 +667,6 @@ void loop() // Main branch, runs over and ov
} }
} }
/* Set optional "failsafe" time to lock up every night.
*/
ds1307.getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); // Get the current date/time
if(hour==23 && minute==59 && door1Locked==false){
doorLock(1);
door1Locked==true;
log(LOG_LOCK,0,BEDTIME);
}
// Notes: RFID polling is interrupt driven, just test for the reader1Count value to climb to the bit length of the key // Notes: RFID polling is interrupt driven, just test for the reader1Count value to climb to the bit length of the key
// change reader1Count & reader1 et. al. to arrays for loop handling of multiple reader output events // change reader1Count & reader1 et. al. to arrays for loop handling of multiple reader output events
@ -1216,9 +1211,11 @@ void lockall() { //Lock down all doors. Can also be run per
void log(byte Action, long LongInfo, byte ShortInfo) void log(byte Action, long LongInfo, byte ShortInfo)
{ {
ds1307.getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); ds1307.getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
if(logLevel < 2) {
addToLog('H',hour); addToLog('H',hour);
addToLog('M',minute); addToLog('M',minute);
addToLog('E',second); addToLog('E',second);
}
switch(logLevel) { switch(logLevel) {
// Most Verbose Logging level. // Most Verbose Logging level.
@ -1227,16 +1224,20 @@ void log(byte Action, long LongInfo, byte ShortInfo)
case LOG_CHIME: { // Chime case LOG_CHIME: { // Chime
//PROGMEMprintln(doorChimeMessage); //PROGMEMprintln(doorChimeMessage);
} }
case LOG_ALARM_ZONE: { // Log Alarm zone events - ShortInfo is zone case LOG_ALARM_ARMED: { //log Alarm Armed - ShortInof is alarm level
addToLog('s',ShortInfo); addToLog('A',ShortInfo);
break;
}
case LOG_CHECK_USER: {
addToLog('c', ShortInfo);
break; break;
} }
case LOG_ALARM_STATE: { // Log Alarm State - ShortInfo is alarm level case LOG_ALARM_STATE: { // Log Alarm State - ShortInfo is alarm level
addToLog('m',ShortInfo); addToLog('m',ShortInfo);
break; break;
} }
case LOG_ALARM_ARMED: { //log Alarm Armed - ShortInof is alarm level case LOG_ALARM_ZONE: { // Log Alarm zone events - ShortInfo is zone
addToLog('A',ShortInfo); addToLog('s',ShortInfo);
break; break;
} }
case LOG_HARDWARE_TEST: { case LOG_HARDWARE_TEST: {
@ -1249,9 +1250,8 @@ void log(byte Action, long LongInfo, byte ShortInfo)
// Verbose Logging level. // Verbose Logging level.
case 1: { case 1: {
switch(Action) { switch(Action) {
case LOG_ACCESS_GRANTED: { // Log Access Granted event - LongInfo is user, ShortInfo door number case LOG_SUPERUSER: { // Log superuser card used - ShortInfo is the SuperUser number
addToLog('G',LongInfo%divisor); addToLog('Q',ShortInfo);
addToLog('g',LongInfo/divisor);
break; break;
} }
case LOG_TAG_PRESENT: { // Log Tag Presented event - LongInfo is user, ShortInfo door number case LOG_TAG_PRESENT: { // Log Tag Presented event - LongInfo is user, ShortInfo door number
@ -1259,11 +1259,14 @@ void log(byte Action, long LongInfo, byte ShortInfo)
addToLog('r',LongInfo/divisor); addToLog('r',LongInfo/divisor);
break; break;
} }
case LOG_CHECK_USER: { case LOG_LOGIN_SUCCESS: {
addToLog('c', ShortInfo); addToLog('S',0);
break;
}
case LOG_CLEAR_LOG: {
addToLog('z',0);
break; break;
} }
default: {} default: {}
} }
} }
@ -1271,6 +1274,11 @@ void log(byte Action, long LongInfo, byte ShortInfo)
// Queit Logging level. // Queit Logging level.
case 2: { case 2: {
switch(Action) { switch(Action) {
case LOG_ACCESS_GRANTED: { // Log Access Granted event - LongInfo is user, ShortInfo door number
addToLog('G',LongInfo%divisor);
addToLog('g',LongInfo/divisor);
break;
}
case LOG_ACCESS_DENIED: { // Log Access Denied event - LongInfo is user, ShortInfo door number case LOG_ACCESS_DENIED: { // Log Access Denied event - LongInfo is user, ShortInfo door number
addToLog('D',LongInfo%divisor); addToLog('D',LongInfo%divisor);
addToLog('d',LongInfo/divisor); addToLog('d',LongInfo/divisor);
@ -1282,28 +1290,18 @@ void log(byte Action, long LongInfo, byte ShortInfo)
break; break;
} }
case LOG_UNLOCK: { // Log unlock event - LongInfo is user, ShortInfo is door case LOG_UNLOCK: { // Log unlock event - LongInfo is user, ShortInfo is door
addToLog('U',LongInfo%divisor); addToLog('U',ShortInfo);
addToLog('u',LongInfo/divisor);
break; break;
} }
case LOG_LOCK: { // Log lock event - ShortInfo is door number case LOG_LOCK: { // Log lock event - ShortInfo is door number
addToLog('L',ShortInfo); addToLog('L',ShortInfo);
break; break;
} }
case LOG_LOGIN_SUCCESS: {
addToLog('S',0);
break;
}
case LOG_SUPERUSER: { // Log superuser card used - ShortInfo is the SuperUser number
addToLog('Q',ShortInfo);
break;
}
case LOG_ALARM_TRAIN: { case LOG_ALARM_TRAIN: {
//PROGMEMprintln(alarmtrainMessage); //PROGMEMprintln(alarmtrainMessage);
addToLog('t',LongInfo/divisor); // Log training of sensor values - LongInfo is sensor average, ShortInfo is sensor number addToLog('t',LongInfo/divisor); // Log training of sensor values - LongInfo is sensor average, ShortInfo is sensor number
break; break;
} }
default: {} default: {}
} }
} }
@ -1347,10 +1345,6 @@ void log(byte Action, long LongInfo, byte ShortInfo)
addToLog('F',1); addToLog('F',1);
break; break;
} }
case LOG_CLEAR_LOG: {
addToLog('z',0);
break;
}
case LOG_LOCKED_OUT_USER: { // log Locked out user attempted access, LongInfo user, ShortInfo usermask case LOG_LOCKED_OUT_USER: { // log Locked out user attempted access, LongInfo user, ShortInfo usermask
addToLog('f',ShortInfo); addToLog('f',ShortInfo);
break; break;