jchri853
jchri853

Reputation: 354

Bluetooth LE Java byte array size on characteristic setValue

I am trying to send a value using Bluetooth LE on my Android phone with the following line of code.

I am getting an error that it exceeds the size of the array, which is 127 because of the 0xEA byte. I converted the byte to around 234. Is there a way to send this byte using the following line of code?

private void writeCharacteristic(BluetoothGatt gatt) 
     {BluetoothGattCharacteristic characteristic;
      Log.d(TAG, "Writing Data");
       characteristic = gatt.getService(SERVICE).getCharacteristic(DATA_IN);
       characteristic.setValue(new byte[]{0x08, 0x01, 0x03, 0x04, 0x52, 0x00, 0x02, 0x62, 0xEA});

       gatt.writeCharacteristic(characteristic);
    }

Upvotes: 0

Views: 1343

Answers (1)

JPS
JPS

Reputation: 624

To be able to use byte values above 127 in java, use (byte)0xEA.

Upvotes: 3

Related Questions