title: Android BLE write byte[] including unsigned values
body: <p>this question started life here <a href="https://stackoverflow.com/questions/42965470/java-convert-string-hex-values-to-byte-recreating-this-obj-c-functionality/42965513?noredirect=1#comment73025843_42965513">here</a> but this appears to be a red herring!</p>
  
  <p>So, the issue is, I have a byte array of values that need to be written to a BLE device. </p>
  
  <pre><code>byte bytes[] = {0x04,0x08,0x0F,0x66,(byte)0x99,0x41,0x52,0x43,0x55,(byte)0xAA};
  ch.setValue(bytes);
  </code></pre>
  
  <p>If I log the output of this array I get (note the negative values): </p>
  
  <pre><code>[4, 8, 15, 102, -103, 65, 82, 67, 85, -86]
  </code></pre>
  
  <p>But in theory this should only be java's representation of the values and shouldn't affect the perceived values when they hit the Bluetooth device but this doesn't seem to be the case</p>
  
  <p>These values are required by the manufacturer so cannot be changed, however 2 of the values are out of the range of an unsigned byte/int and it appears that this is the reason the device isn't recognising the command.</p>
  
  <p>When I write this command to the characteristic I get a success code of 0 (Success) but the device doesn't act upon the command.</p>
  
  <p>So, my question is, am I sending this in the correct way, or should I be formatting/processing the byte array in order to maintain the perceived values contained within?</p>
  
  <p>Any advice greatly appreciated!!!</p>