I am developing app which sets time on the BLE device. For that to work I need to send array of values bigger that 127 (Values like 239,254, etc). But BLE setting value for characteristics supports byte array which has limit of value 128. So how can I send bigger values than 128 to BLE device from Android Device? PFA the code snippet, but it doesn't work. View Code Snippet
public static boolean writeble_Set_time_Healthyu(BluetoothGatt mBluetoothGatt) {
try {
Calendar calendar = Calendar.getInstance();
Date date = new Date();
calendar.setTime(date);
byte[] list_data = new byte[15];
list_data[0] = new Integer(Integer.parseInt(Integer.toString(254, 16), 16)).byteValue();
list_data[1] = new Integer(Integer.parseInt(Integer.toString(239, 16), 16)).byteValue();
list_data[2] = new Integer(Integer.parseInt(Integer.toString(1, 16), 16)).byteValue();
list_data[3] = new Integer(Integer.parseInt(Integer.toString(250, 16), 16)).byteValue();
list_data[4] = new Integer(Integer.parseInt(Integer.toString(7, 16), 16)).byteValue();
list_data[5] = new Integer(Integer.parseInt(Integer.toString(calendar.get(Calendar.HOUR), 16), 16)).byteValue();
list_data[6] = new Integer(Integer.parseInt(Integer.toString(calendar.get(Calendar.MINUTE), 16), 16)).byteValue();
list_data[7] = new Integer(Integer.parseInt(Integer.toString(calendar.get(Calendar.SECOND), 16), 16)).byteValue();
list_data[8] = new Integer(Integer.parseInt(Integer.toString(calendar.get(Calendar.DATE), 16), 16)).byteValue();
list_data[9] = new Integer(Integer.parseInt(Integer.toString(calendar.get(Calendar.MONTH) + 1, 16), 16)).byteValue();
list_data[10] = new Integer(Integer.parseInt(Integer.toString(Integer.parseInt((calendar.get(Calendar.YEAR) + "").substring(0, 1)), 16), 16)).byteValue();
list_data[11] = new Integer(Integer.parseInt(Integer.toString(Integer.parseInt((calendar.get(Calendar.YEAR) + "").substring(2, 3)), 16), 16)).byteValue();
list_data[12] = new Integer(Integer.parseInt(Integer.toString(Integer.parseInt((calendar.get(Calendar.YEAR) + "").substring(2, 3)), 16), 16)).byteValue();
list_data[13] = new Integer(Integer.parseInt(Integer.toString(0, 16), 16)).byteValue();
list_data[14] = new Integer(Integer.parseInt(Integer.toString(165, 16), 16)).byteValue();
List<BluetoothGattService> serviceList = mBluetoothGatt.getServices();
for (BluetoothGattService service : serviceList) {
List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics();
for (BluetoothGattCharacteristic characteristic : characteristics) {
characteristic.setWriteType(FORMAT_UINT32);
characteristic.setValue(list_data);
boolean status = mBluetoothGatt.writeCharacteristic(characteristic);
}
}
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}