Interperting data with WebSocketServer
Posted: Fri Feb 12, 2016 6:37 pm
I am using the ArduinoWebSocket library here. https://github.com/Links2004/arduinoWebSockets. I have my esp8266 acting as a server and using the demo code. I have it serving a webpage and I want to be able to send chunks of data with variables through the web-socket and interprete them. I basically need 2 int sent through, preferably in one datastream. The problem is, the library seems to get the payload as an uint8_t * array (unsigned char array). And the callback that it uses is like this.
Does anyone have any idea how I can send a string such as "x654y33" and be able to turn it into,
int x = 654;
int y = 33;
If i can get it into a String I can manipulate it pretty easy in arduino, but so far, everything I try either does not compile, or it does compile but crashes the esp8266 as soon as the websocket sends data.
Thanks in advance.
Code: Select all
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) {
delay(1);
switch (type) {
case WStype_TEXT:
DBG_OUTPUT_PORT.printf("[%u] get Text: %s\n", num, payload);
break;
}
Does anyone have any idea how I can send a string such as "x654y33" and be able to turn it into,
int x = 654;
int y = 33;
If i can get it into a String I can manipulate it pretty easy in arduino, but so far, everything I try either does not compile, or it does compile but crashes the esp8266 as soon as the websocket sends data.
Thanks in advance.