Hello,
I am sending bits from one ESP as client to the other ESP as server.
This is working but I can't figure out how to access specific data in an array.
For example, I send from the client to the server
// val12 is an on/ off switch
Serial.println(val12);
client.println(val12);
client.println('d');
and access the value of val12 correctly here:
WiFiClient client = server.available();
if (client) {
if (client.connected()) {
String request12 = client.readStringUntil('d');
request12 = request12.charAt(0);
delay(10);
Serial.println("val12 is " + request12);
Similarly, I do the same with the next byte, receiving the correct value as follows:
// Client sends val13
Serial.println(val13);
client.println(val13);
client.println('f');
// Server receives val13
WiFiClient client = server.available();
if (client) {
if (client.connected()) {
String request12 = client.readStringUntil('d');
request12 = request12.charAt(0);
delay(10);
Serial.println("val12 is " + request12);
String request13 = client.readStringUntil('f');
request13 = request13.charAt(2);
delay(10);
Serial.println("val13 is " + request13);
All seems good until I try to access the NEXT byte.
//Client sends val14 to server
Serial.println(val14);
client.println(val14);
client.println('r'); // send the data
Receives
String request14 = client.readStringUntil('r');
request14 = request14.charAt(4);
delay(10);
Serial.println("val14 is " + request14);
It seems logical that request14 = request14.charAt(4); would be the correct sequence, but this yields nothing. Trying 5,6,7,8 in place of 4 also yields nothing.
Removing the line request14 = request14.charAt(4); altogether provides the correct value of the switch, so I know it's in the array.
Question:
What is the size of the data being sent? It is all in String format.
Is the size different from 'd' to "d"?
What is the logical place for val14 to be putting its data?
Thanks in advance.