* Keeps backwards compatibility with firmware that can't take all the information */ private void safeWriteToCharacteristic(TransactionBuilder builder, UUID uuid, byte[] data) { BluetoothGattCharacteristic characteristic = getCharacteristic(uuid); if (characteristic != null && (characteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) { builder.write(characteristic, data); } else { LOG.warn("Tried to write to a characteristic that did not exist or was not writable!"); } } @Override public boolean onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { if (super.onCharacteristicRead(gatt, characteristic, status)) { return true; } UUID characteristicUUID = characteristic.getUuid(); LOG.info("Unhandled characteristic read: " + characteristicUUID); return false; } /** * Handles a media command sent from the AsteroidOS device * @param characteristic The Characteristic information */ public void handleMediaCommand (BluetoothGattCharacteristic characteristic) { LOG.info("handle media command"); AsteroidOSMediaCommand command = new AsteroidOSMediaCommand(characteristic.getValue()[0]); GBDeviceEventMusicControl event = command.toMusicControlEvent(); evaluateGBDeviceEvent(event); } @Override public boolean getImplicitCallbackModify() { return true; } @Override public boolean getSendWriteRequestResponse() { return false; } }