If I understand it right, in java you cannot define a value as unsigned int. So the MSB of a Byte will decide, if the value is positive or negative.
But I have to use all 8 Bits of the Byte for the value of the variable.
Does anyone have experience with this, and how is it possible still to send 8 Bit variables?
With the MCP everything is working fine. But it should work the same trough a mobile device.
Is it defined by the BLE protocol, that I must send bytes?
Could I also setup a characteristic to send and recieve floats or double?
What other opportunities do I have?
I tried it to mask with '& 0xFF'
links[1] = (byte) (i & (0xFF));
links[2] = (byte) ((i >> 8) & (0xFF));
links[3] = (byte) ((i >> 16) & (0xFF));
As example I take i = 201600
What I get:
links[1] = -128 (should be 0x80) <---Result is false
links[2] = 19 (should be 0x13) <---Result is right
links[3] = 3 (should be 0x03) <---Result is right
Did I wrong mask, or why its still negative and wrong value?