-->
Page 2 of 3

Re: Interperting data with WebSocketServer

PostPosted: Fri Feb 12, 2016 7:40 pm
by primateio
Ok, I decided that anything worth doing is worth doing right, so I went ahead and took your advice martinayotte and went with JSON. It works amazingly. Now I can send all sorts of data. Here is the code.

Code: Select all      StaticJsonBuffer<200> jsonBuffer;
      JsonObject& root = jsonBuffer.parseObject((char *)payload);

      Serial.print("X = ");
      Serial.println((int)root["x"]);

      Serial.print("Y = ");
      Serial.println((int)root["y"]);


Thank you for your recommendation.

Re: Interperting data with WebSocketServer

PostPosted: Fri Feb 12, 2016 9:12 pm
by martinayotte
Great ! @primateio !
Although this solution is consuming more CPU cycle, it is the way to go for expandability !
It allow other folks to get thru same solution especially when they have much complex thing to transmit than simple X/Y coordinate ... ;)

Re: Interperting data with WebSocketServer

PostPosted: Tue Sep 18, 2018 7:29 am
by Espradio01
Hi all

I know this is an old post but could someone please help me splitting this data into variables :
Code: Select all#,test,place,1537272000,1537272000,Normal,1234,12

The data is received in the PAYLOAD .
I really just need to understand how to deal with it as most of the examples just show INT , like the question here.

Thank you in advance

D

Re: Interperting data with WebSocketServer

PostPosted: Tue Sep 18, 2018 7:42 am
by Pablo2048
Did you try to use sscanf?