1

I need to send message to custom device via BLE.

I am able to send message below 20 bytes. I used just:

 public boolean writeCharacteristic(byte[] value){

        if (mBluetoothGatt == null) {
            Log.e(TAG, "lost connection");
            return false;
        }
        BluetoothGattService Service = mBluetoothGatt.getService(UUID_SERVICE_GENERIC_ATTRIBUTE);
        if (Service == null) {
            Log.e(TAG, "service not found!");
            return false;
        }
        BluetoothGattCharacteristic charac = Service.getCharacteristic(UUID_WRITE);
        if (charac == null) {
            Log.e(TAG, "char not found!");
            return false;
        }

        charac.setValue(value);
        boolean status = mBluetoothGatt.writeCharacteristic(charac);
        return status;
    }

But I need to send longer message in "as short time as possible". I found: Android: Sending data >20 bytes by BLE

but I need to use synchronized method and onCharacteristicWrite (this should be the fastest way).

I found: http://blog.stylingandroid.com/bluetooth-le-part-6/, but not everything is clear for me.

Do you have some easy example how to send message via ble using synchronized methods?

Community
  • 1
  • 1
tauri
  • 293
  • 2
  • 6
  • 18
  • My approach will be to send the data using a simple for loop in your case. – Osman Esen Apr 13 '15 at 15:05
  • 1
    At the begging we tried this on iOS, and it took 5 seconds. We need to send all messages and receive answer in 1-2 seconds. That's why the idea using synchronized methods. – tauri Apr 14 '15 at 21:59

0 Answers0