This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

write to multiple characteristic

Hi Nordic's community,

I have a question about how to write values to different characteristic in one time ( the values to write are inferior to 2O bytes) with an Android app ?

it is permitted by the bluetooth specification ?

I do this like that in my Android's app:

writeCharacteristic(SELF_WAKE_UP_SERVICE_UUID, ALARM_CHARACTERISTIC_UUID, 0);

And in the callback method (onCharacteristicWrite(...)), i write to other characteristic like that:

@Override
    public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
        super.onCharacteristicWrite(gatt, characteristic, status);

        if (characteristic.getUuid().equals(UUID.fromString(ALARM_CHARACTERISTIC_UUID))) {

            writeCharacteristic(SELF_WAKE_UP_SERVICE_UUID, VIBRATION_ON_CHARACTERISTIC_UUID, mVibrationOn);

        } else if (characteristic.getUuid().equals(UUID.fromString(VIBRATION_ON_CHARACTERISTIC_UUID))) {

            writeCharacteristic(SELF_WAKE_UP_SERVICE_UUID, VIBRATION_OFF_CHARACTERISTIC_UUID, mVibrationOff);

        } 
    }

It works well, but i want to know if there is a more elegant way to do this ? for example, in one writeCharacteristic(...) call ?

Thanks.

Related