Hey, I got an eps8266 and I am trying to create a joystick as input for further projects. I managed to get the HTML page and the javascript running. The transfer between server and client is done with a Websocket. My problem right now is that I don't get the payload which is an array of integers in the javascript to two integers on my board.
I managed to print the values with the following code:
The X value works fine, but posY only works for some values like -100. I tried to play around with the index but I didn't help. I hope you can help me, I think I have spent already way to much time on this.
If payload varies in length (<10, <100, <100) then how in the world do you know where to start parsing the second parameter. A more typical approach would be to print X, then a separator like ',' and then Y so the receiving code can key off of the separator and succeed.
if I use this, it prints out the values separated by an ','.
But I don't know how to convert my payload, which is uint8_t* datatype to two integers.
All I could find was something like this
atoi() works on strings. If your payload is uint8_t, that means an 8 bit value (0-255) so you still have the problem of not a consistent amount of chars per integer.