-->
Page 1 of 1

ESP websocket - sending more than one variable value

PostPosted: Tue Feb 16, 2016 2:41 pm
by Focak
Hello to all,

I need help with testing esp websocket .
I tried AdySan websocket: https://github.com/AdySan/WittyCloudTes ... yCloudTest ,
i working fast and stabile when sending one variable value in websocket response:



case WStype_TEXT:

switch(payload[0]){

case 'l': case 'L': // Request LDR
LDRvalue = analogRead(LDR);
delay(5);
webSocket.sendTXT(0,LDRvalue);
break;

I would like to send multiple variable values in websocket response . How it is possible ?
For example in case receiving "l" reply is :

webSocket.sendTXT(0,LDRvalue); sending only one variable value .
How I can send multiple values in response ?

Re: ESP websocket - sending more than one variable value

PostPosted: Mon Feb 22, 2016 12:52 am
by AbdouRetro
why hasn't anybody replied, I am facing the same problem. I am thinking of sending the variables together and parsing them on the other side with substring.
what do you think of that ?

Re: ESP websocket - sending more than one variable value

PostPosted: Mon Feb 22, 2016 12:34 pm
by danbicks
Hi,

You may consider building a string first with data then send the whole string. I hope this example gives you some guidance.

case 'l': case 'L': // Request LDR
LDRvalue = analogRead(LDR);
delay(5);

String MyPayload;
MyPayload = "Transmitted Data: "; // Here we build payload string!
MyPayload += "LDR Value: ";
MyPayload += (LDRvalue);

webSocket.sendTXT(0,MyPayload);
break;

Regards

Dans