Moving code to ethernet but not sure if this is the right way to do it
This commit is contained in:
parent
b04cd73df9
commit
54e33ef79a
|
@ -292,14 +292,13 @@ void loop() // Main branch, runs over and ov
|
||||||
if(readString.indexOf("?hi") > 0) {
|
if(readString.indexOf("?hi") > 0) {
|
||||||
client.println("hi");
|
client.println("hi");
|
||||||
}
|
}
|
||||||
if(readString.indexOf("?s") > 0) {
|
if(readString.indexOf("?s") > 0) { // list user
|
||||||
int offset = readString.indexOf("?s");
|
int offset = readString.indexOf("?s");
|
||||||
char usernum[3] = {readString[offset+2],readString[offset+3],readString[offset+4]};
|
char usernum[4] = {readString[offset+2],readString[offset+3],readString[offset+4],'\0'};
|
||||||
|
|
||||||
client.print("m");
|
client.print("s");
|
||||||
client.println(usernum);
|
client.println(usernum);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if(readString.indexOf("?m") > 0) {
|
if(readString.indexOf("?m") > 0) {
|
||||||
client.println("m"); // modify user <num> <usermask> <tagnumber>
|
client.println("m"); // modify user <num> <usermask> <tagnumber>
|
||||||
}
|
}
|
||||||
|
@ -312,7 +311,6 @@ void loop() // Main branch, runs over and ov
|
||||||
if(readString.indexOf("?o") > 0) {
|
if(readString.indexOf("?o") > 0) {
|
||||||
client.println("o"); // open <door#>
|
client.println("o"); // open <door#>
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
if(readString.indexOf("?u") > 0) {
|
if(readString.indexOf("?u") > 0) {
|
||||||
unlockall();
|
unlockall();
|
||||||
client.println("u");
|
client.println("u");
|
||||||
|
@ -350,7 +348,9 @@ void loop() // Main branch, runs over and ov
|
||||||
client.println("</pre>");
|
client.println("</pre>");
|
||||||
}
|
}
|
||||||
if(readString.indexOf("?e") > 0) {
|
if(readString.indexOf("?e") > 0) {
|
||||||
client.println("e");
|
char pass[5] = {readString[offset+2],readString[offset+3],readString[offset+4],readString[offset+5],'\0'};
|
||||||
|
|
||||||
|
login(strtoul(pass,NULL,16));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1443,6 +1443,45 @@ void dumpUser(byte usernum) // Return
|
||||||
else Serial.println("Bad user number!");
|
else Serial.println("Bad user number!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void login(long input) {
|
||||||
|
logDate();
|
||||||
|
if((consoleFail>=5) && (millis()-consolefailTimer<300000)) // Do not allow priv mode if more than 5 failed logins in 5 minute
|
||||||
|
{
|
||||||
|
PROGMEMprintln(privsAttemptsMessage);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (input == PRIVPASSWORD)
|
||||||
|
{
|
||||||
|
consoleFail=0;
|
||||||
|
PROGMEMprintln(privsenabledMessage);
|
||||||
|
privmodeEnabled=true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PROGMEMprintln(privsdisabledMessage);
|
||||||
|
privmodeEnabled=false;
|
||||||
|
if(consoleFail==0) { // Set the timeout for failed logins
|
||||||
|
consolefailTimer=millis();
|
||||||
|
}
|
||||||
|
consoleFail++; // Increment the login failure counter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showUser(char* input) {
|
||||||
|
|
||||||
|
if(privmodeEnabled==true) {
|
||||||
|
Serial.print("UserNum:");
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.print("Usermask:");
|
||||||
|
Serial.print(" ");
|
||||||
|
Serial.println("TagNum:");
|
||||||
|
dumpUser(atoi(input));
|
||||||
|
//Serial.println(); // commented out due to dumpUser always printing a line -WB 7-7-2011
|
||||||
|
}
|
||||||
|
else{logprivFail();}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Displays a serial terminal menu system for
|
/* Displays a serial terminal menu system for
|
||||||
* user management and other tasks
|
* user management and other tasks
|
||||||
|
@ -1494,29 +1533,8 @@ if(inCount==0) {
|
||||||
|
|
||||||
|
|
||||||
case 'e': { // Enable "privileged" commands at console
|
case 'e': { // Enable "privileged" commands at console
|
||||||
logDate();
|
login(strtoul(cmdString[1],NULL,16));
|
||||||
|
break;
|
||||||
if((consoleFail>=5) && (millis()-consolefailTimer<300000)) // Do not allow priv mode if more than 5 failed logins in 5 minute
|
|
||||||
{
|
|
||||||
PROGMEMprintln(privsAttemptsMessage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (strtoul(cmdString[1],NULL,16) == PRIVPASSWORD)
|
|
||||||
{
|
|
||||||
consoleFail=0;
|
|
||||||
PROGMEMprintln(privsenabledMessage);
|
|
||||||
privmodeEnabled=true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PROGMEMprintln(privsdisabledMessage);
|
|
||||||
privmodeEnabled=false;
|
|
||||||
if(consoleFail==0) { // Set the timeout for failed logins
|
|
||||||
consolefailTimer=millis();
|
|
||||||
}
|
|
||||||
consoleFail++; // Increment the login failure counter
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1542,18 +1560,9 @@ if(inCount==0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 's': { // List user
|
case 's': { // List user
|
||||||
if(privmodeEnabled==true) {
|
showUser(cmdString[1]);
|
||||||
Serial.print("UserNum:");
|
break;
|
||||||
Serial.print(" ");
|
|
||||||
Serial.print("Usermask:");
|
|
||||||
Serial.print(" ");
|
|
||||||
Serial.println("TagNum:");
|
|
||||||
dumpUser(atoi(cmdString[1]));
|
|
||||||
//Serial.println(); // commented out due to dumpUser always printing a line -WB 7-7-2011
|
|
||||||
}
|
|
||||||
else{logprivFail();}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'd': { // Display current time
|
case 'd': { // Display current time
|
||||||
|
|
Loading…
Reference in New Issue
Block a user