Got ethernet server and basic commands working

This commit is contained in:
Will Bradley 2012-08-19 00:43:28 -07:00
parent 84e9dd1a03
commit b04cd73df9

View File

@ -180,6 +180,7 @@ PCATTACH pcattach; // Software interrupt library
const prog_uchar rebootMessage[] PROGMEM = {"AccessControlSystemRebooted"}; const prog_uchar rebootMessage[] PROGMEM = {"AccessControlSystemRebooted"};
const prog_uchar doorChimeMessage[] PROGMEM = {"FrontDoorOpened"}; const prog_uchar doorChimeMessage[] PROGMEM = {"FrontDoorOpened"};
const prog_uchar doorsunlockedMessage[] PROGMEM = {"AllDoorsUnlocked"};
const prog_uchar doorslockedMessage[] PROGMEM = {"AllDoorsRelocked"}; const prog_uchar doorslockedMessage[] PROGMEM = {"AllDoorsRelocked"};
const prog_uchar alarmtrainMessage[] PROGMEM = {"AlarmTrainingPerformed."}; const prog_uchar alarmtrainMessage[] PROGMEM = {"AlarmTrainingPerformed."};
const prog_uchar privsdeniedMessage[] PROGMEM = {"AccessDeniedPrivelegedModeIsNotEnabled"}; const prog_uchar privsdeniedMessage[] PROGMEM = {"AccessDeniedPrivelegedModeIsNotEnabled"};
@ -285,14 +286,54 @@ void loop() // Main branch, runs over and ov
if (c == '\n' && currentLineIsBlank) { if (c == '\n' && currentLineIsBlank) {
// send a standard http response header // send a standard http response header
client.println("HTTP/1.1 200 OK"); client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html"); client.println("Cache-Control: no-store\r\nContent-Type: text/html");
client.println(); client.println();
if(readString.indexOf('?') > 0) { if(readString.indexOf("?hi") > 0) {
client.println("hello!"); client.println("hi");
} }
if(readString.indexOf("?s") > 0) {
int offset = readString.indexOf("?s");
char usernum[3] = {readString[offset+2],readString[offset+3],readString[offset+4]};
// output status client.print("m");
client.println(usernum);
}
/*
if(readString.indexOf("?m") > 0) {
client.println("m"); // modify user <num> <usermask> <tagnumber>
}
if(readString.indexOf("?a") > 0) {
client.println("a"); // all users
}
if(readString.indexOf("?r") > 0) {
client.println("r"); // remove user <num>
}
if(readString.indexOf("?o") > 0) {
client.println("o"); // open <door#>
}
*/
if(readString.indexOf("?u") > 0) {
unlockall();
client.println("u");
}
if(readString.indexOf("?l") > 0) {
lockall();
chirpAlarm(1);
client.println("l");
}
/*
if(readString.indexOf("?1") > 0) {
client.println("1"); // disarm
}
if(readString.indexOf("?2") > 0) {
client.println("2"); // arm
}
if(readString.indexOf("?3") > 0) {
client.println("3"); // train
}
*/
if(readString.indexOf("?9") > 0) {
client.println("<pre>"); client.println("<pre>");
client.print("Alarm armed:"); client.print("Alarm armed:");
client.println(alarmArmed,DEC); client.println(alarmArmed,DEC);
@ -307,7 +348,10 @@ void loop() // Main branch, runs over and ov
client.print("Door 2 locked:"); client.print("Door 2 locked:");
client.println(door2Locked); client.println(door2Locked);
client.println("</pre>"); client.println("</pre>");
client.println("<a href="); }
if(readString.indexOf("?e") > 0) {
client.println("e");
}
break; break;
} }
@ -981,6 +1025,16 @@ byte dp=1;
Serial.println(" locked"); Serial.println(" locked");
} }
void unlockall() {
doorUnlock(1);
doorUnlock(2);
alarmState(0);
armAlarm(4);
door1Locked=false;
door2Locked=false;
chirpAlarm(3);
PROGMEMprintln(doorsunlockedMessage);
}
void lockall() { //Lock down all doors. Can also be run periodically to safeguard system. void lockall() { //Lock down all doors. Can also be run periodically to safeguard system.
digitalWrite(DOORPIN1, LOW); digitalWrite(DOORPIN1, LOW);
@ -1525,15 +1579,8 @@ if(inCount==0) {
case 'u': { case 'u': {
if(privmodeEnabled==true) { if(privmodeEnabled==true) {
alarmState(0); // Set to door chime only/open doors unlockall();
armAlarm(4);
doorUnlock(1);
doorUnlock(2);
door1Locked=false;
door2Locked=false;
chirpAlarm(3);
} }
else{logprivFail();} else{logprivFail();}
break; break;
} }