I need to send an ArrayBuffer via chrome.sockets.udp plugin.
The data is sent via Android ionic app to an emulator that runs on a computer.
I need to send the following fields:
var arrayBuffer = new ArrayBuffer(20);
var dv = new DataView(arrayBuffer,0);
console.log("ID=0 assign");
dv.setUint16(0,0);
console.log("SIZE=12 assign");
dv.setUint16(2,12);
console.log("CRC=0 assign");
dv.setUint16(4,0);
console.log("MSGcount assign");
dv.setUint16(6,0);
console.log("AppVersion assign");
dv.setUint32(8,0);
console.log("Port assign");
dv.setUint32(12,7602);
for (var i = 0; i <= 19; i++) {
console.log("byte number is " +i+ " " +dv.getInt8(i));
}
dv.setUint32(16,20000);
When I run this code I get the following result:
byte number is 12 0
byte number is 13 0
byte number is 14 29
byte number is 15 -78
the server should get the next result:
byte number is 12 78
byte number is 13 29
byte number is 14 0
byte number is 15 0
How should I insert the numbers in dataView to get the bytes in the order the server expects them to be?