Answer the question
In order to leave comments, you need to log in
How to parse binary data in C?
Hello. Raised a web server on the ESP12 to return statics and web sockets for data exchange.
The question is, on the client side in javascript, I form binary data and send them via a web socket
var arrayBuffer = new ArrayBuffer(20);
var dataView = new DataView(arrayBuffer);
dataView.setUint8(0, 1);
dataView.setUint8(1, indexElement);
Answer the question
In order to leave comments, you need to log in
As a rule, you define a structure corresponding to the data, then create a variable with the type of this structure, read the data into it, and simply access the fields of the structure.
#pragma pack(push,1)
typedef _websocketPacket {
unsigned char one; // здесь ваша 1
unsigned char indexElement;
unsigned char rest[18];
} wsPacket;
#pragma pack(pop)
wsPacket myData;
The question is, on the client side in javascript, I form binary data and send them over a web socket
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question