Is it possible to use tabs or blank spaces in client.print or client.println functions?
I have seen where people have done it with success but my server seems to be ignoring any spaces between printed variables.
I am using the latest Firefox browser.
I am trying to use them in the logged in/display data section.
Code below:
EthernetClient client = server.available(); //Checks for Available Client
if (client) { //Execute if a Client is Connected
PreviousMillis = millis();
Serial.println("new client"); //Display Client Connection Message in Serial Monitor
boolean currentLineIsBlank = true; //HTTP Request Ends with a Blank LIne
while (client.connected()) { //Execute While Client is Connected
if (client.available()) { //Execute if Client is Connected and Available
char ClientInfo = client.read(); //Assign Client Information to Variable
Serial.write(ClientInfo); //Display Client Information in Serial Monitor
OnlineButton+= ClientInfo;
if (ClientInfo == '\n' && currentLineIsBlank) { //Execute if the Current Line is Blank
while(client.available()) { //Execute While Client is Available
char IDPass = client.read(); //Assign Next "POST" Character to Variable
Serial.write(IDPass); //Display POST Information in Serial Monitor
IDBuffer+= IDPass; //Assign Complete POST Information to Buffer Variable
}
IDBuffer.replace("_","");
IDBuffer.replace("=","");
IDBuffer.replace("&", ":");
counter = IDBuffer.length();
counter = counter + 1;
IDBuffer.toCharArray(OnlineEncodeBuffer,counter);
IDBuffer = "";
for(int x = 0; x <counter ; x++){
EncodeBuffer = OnlineEncodeBuffer[x];
Encode();
IDBuffer = IDBuffer + EncodeBuffer;;
EncodeBuffer = 0;
}
while(counter != 0){
counter--;
OnlineEncodeBuffer[counter] = 0;
}
//=================================================
//=============== Web Page Display Header =========
//=================================================
client.println("HTTP/1.1 200 OK"); //
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
//=================================================
//=============== Main Login ======================
//=================================================
if (ValidID == 0) { //Execute if not Logged in
client.print ("<form method=post>"); //Begin Form Method,Post
client.print ("User ID:"); //Display User ID Label on Page
client.print ("
"); //Line Break
client.print ("<input type=username name=_ size=25>"); //User ID Input Box Setup
client.print ("
"); //Line Break
client.print ("Password:"); //Display Password Label on Page
client.print ("
"); //Line Break
client.print ("<input type=password name=_ size=25>"); //Password Input Box Setup
client.print ("
"); //Line Break
client.print (" <input type=submit value=Login>"); //Submission Button Setup
client.print ("</form>"); //End From
if (IDBuffer != "" && ValidID == 0) {
LoginFile = SD.open("Login.txt");
if (LoginFile) {
while (LoginFile.available()) { //Executes if Log File is not Empty
GetID = LoginFile.read(); //Assign Login File Information to Variable
if (index < 99) { //Execute if String is Less Than Constant
inData[index] = GetID ; //Assign Next Variable to Current Index NUmber
index++; // Increment Where to Write Next
inData[index] = '\0'; //Null Terminate the String
} //End of Variable Assignment
IDFromFile = IDFromFile + GetID;
} //End of While Loop
if (IDFromFile.indexOf(IDBuffer)>=0) {
Serial.println("Logged In");
ValidID = 1;
client.print("<meta http-equiv=\"refresh\" content=\"0\">"); //Instant Page Refresh
}
else {
Serial.println("Invalid Login");
client.print ("Invalid ID Please Try Again"); //Display Password Label on Page
ValidID = 0;
client.print("<meta http-equiv=\"refresh\" content=\"0\">"); //Instant Page Refresh
}
} //End of File Open
else{
Serial.write("Login File Failed to Open");
}
LoginFile.close(); //Close Login File
digitalWrite(W5200_CS,HIGH); //Disconnect Ethernet Chip
SendLogtoMain(); //Send Data to Main Brain
}
else { //Execute if Data File is not Open
Serial.println("Login Entry Failed");
}
digitalWrite(SDCARD_CS,HIGH); //Disconnect SD Card
} //End of Buffer Null Check
IDBuffer = ""; //Clear User Input
// =================================================
// =============== Logged In/Display Data ==========
// =================================================
if (ValidID == 1) { //Execute if Logged In
client.print ("
"); //Line Break
client.println("<input type=button value=Send_Report onmousedown=location.href='/?Send4;'>");
client.print ("
"); //Line Break
if (OnlineButton.indexOf(SendButton)>=0 && ReportSent == 0){
client.flush();
client.println("<meta http-equiv=refresh content=1;URL='//192.168.1.177/'>");
client.print ("
"); //Line Break
ReportSent = 1;
}
if (MainAlarm == HIGH){
client.print ("Alert Alarm Is Active!!"); //Display New User ID Label on Page
client.print ("
"); //Line Break
}
if (DeadModule == HIGH){
client.print ("Alert A Module is Dead!!"); //Display New User ID Label on Page
client.print ("
"); //Line Break
}
client.println("<meta http-equiv=\"refresh\" content=\"5\">"); //Refresh Page Every 5 Seconds
//Setup Header Here with client.print("\t"); or client.println("\t")
for (int nodeAddress = START_NODE; nodeAddress <= NODE_MAX; nodeAddress++) { // we are starting from Node address 2
Wire.requestFrom(nodeAddress, PAYLOAD_SIZE); // request data from node#
if(Wire.available() == PAYLOAD_SIZE) { // if data size is avaliable from nodes
for (int i = 0; i < PAYLOAD_SIZE; i++) nodePayload[i] = Wire.read(); // get nodes data
for (int j = 0; j < PAYLOAD_SIZE; j++) client.println(nodePayload[j]); // print nodes data
client.println("
"); //Line Break
}
}
delay(NODE_READ_DELAY);
}
//=================================================
//=============== End Server Client Connection ====
//=================================================
client.println("</html>"); //End HTML
break; //Disconnect from "While Client Connected" Loop
}
if (ClientInfo == '\n') { //Execute if Next Line is Blank
currentLineIsBlank = true; //Set New Line Variable to True
}
else if (ClientInfo != '\r') { //Executre if New Line
currentLineIsBlank = false; //Set New Line Variable to False
}
}
}
delay(200); //.2 Second Delay
client.stop(); //Close Connection to Client
Serial.println("client disonnected"); //Display Client Disconnected Message in Serial Monitor
Serial.println("ValidID: "); //Display Id Variable Label in Serial Monitor
Serial.println(ValidID); //Display Current ID Varialbe in Serial Monitor
} //End Of Client
if (OnlineButton.indexOf(SendButton)>=0 && ReportSent == 0){
//digitalWrite(22, HIGH);
client.flush();
delay(3000);
ValidID = 0;
//digitalWrite(22, LOW);
}
CurrentMillis = millis (); //Assign Current Millis to CurrentMillis
if (CurrentMillis - PreviousMillis > 30000) {//Execute if Designated Time has passed
ValidID = 0;
ReportSent = 0;
OnlineButton = "";
}
}
Any assistance would be greatly appreciated