Reputation: 3025
I wait for onCharacteristicChanged()
callbacks to receive data via BLE. But if the BluetoothDevice sends too many packets of 20 bytes at once I get at most 10 notifications instead of the expected 46 for a 907 byte long message. Smaller amounts of data are notified just fine.
In onServicesDiscovered(BluetoothGatt gatt, int status) I register for notifications via:
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
mService = mGatt.getService(SERVICE_UUID);
mCharacteristic = mService.getCharacteristic(CHARACTERISTIC_UUID);
mGatt.setCharacteristicNotification(characteristic, enabled);
BluetoothGattDescriptor descriptor =
characteristic.getDescriptor(UUID.fromString(CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mGatt.writeDescriptor(descriptor);
}
}
Do I have to acknowledge somehow that I got the data in onCharacteristicChanged()
?
The BluetoothDevice is sending messages that are bigger than 20 bytes by splitting them up into 20 byte chunks. Usually those messages are smaller than 200 bytes. But when the BluetoothDevice sends messages that are over 900 bytes long, the app only gets notifications via onCharacteristicChanged()
for 200 of those bytes.
These bigger messages are received just fine on iOS.
Upvotes: 1
Views: 1418
Reputation: 196
The BLE stack is is currently kind of broken there is a known bug regarding too many packets and reading multiple characteristics. According to the slide s from the keynote the BT stack will be greatly improved in the L release (including slave AND central mode)
Upvotes: 1