1

My app is work fine in Samsung S6 and Nexus 5 and Nexus 7 with Android 5, however, it can't work in Nexus 5x with Android 6.


boolean success = mBluetoothGatt.writeCharacteristic(characteristic);


My app will send this command many times to set or get data from a hardware, however, it may return false after one or two command sent.(The first command will return true)

Does Android Marshmallow change something in BLE?

1 Answers1

3

A common cause of this is if you try to do more than one write or read in a row. You have to wait for the result of a previous read or write before doing the next one. For non-trivial applications this usually means setting up a job queue.

If this is not the cause then if you attach the Android source in your IDE you may be able to step through BluetoothGatt.writeCharacteristic() in the debugger and see exactly where it's returning false. The source I'm looking at has 6 places where it returns false, mostly "early outs", so it could be any one of those.

Doug Koellmer
  • 407
  • 2
  • 8