D
D
DivelNick2016-09-18 18:16:50
Java
DivelNick, 2016-09-18 18:16:50

How to assemble a byte array correctly?

There was a task to form an array, I have 3 values ​​\u200b\u200bthat need to be sent in one package via BLE. The first value is a letter and the two values ​​are -100 .. 100. The letter is fine, but the numbers are wrong. Previously, the numbers were sent in the following way


// left and right values ​​int -100 .. 100
value[0] = (byte) Left;
value[1] = (byte) Right;
// then value is sent over BLE

Now I send

byte[] value = new byte[3];
value[0] = (byte) 'C';
value[1] = (byte) Left;
value[2] = (byte) Right;
// then value is sent over BLE

What is the difference between the first and second case?
PS The device receives and processes everything correctly.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question