-1

I am trying to send data from my android application to a microchip RN4871 Bluetooth Low Energy module.

I want to use the transparent UART mode.

After connecting with the module, I can send packets of 20 bytes with:

characteristic.setValue("data");
mBluetoothGatt.writeCharacteristic(characteristic);

But after 8 packets of 20 bytes (so 160 bytes), the BLE module does not print the new packages.

Even after a disconnect and reconnect from my device to my module, I can't send more than 8 packets of 20 bytes, I have to restart my BLE module to send it 8 packets again.

I have tried the solution proposed here: Android: Sending data >20 bytes by BLE without any success.

Do you know if there is anything I must do to send another serie of 8 packets of 20 bytes?

Community
  • 1
  • 1
Aznhar
  • 610
  • 1
  • 10
  • 30

1 Answers1

0

I finally found the answer. I was on a characteristics that only supports Writing. I change to a characteristics that also supports notifying and I send a descriptor a the begin to enable notify :

UUID uuid = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(uuid);
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
gatt.writeDescriptor(descriptor);

And it's now working fine, I can send has many packets of 20 bytes has I want to.

Aznhar
  • 610
  • 1
  • 10
  • 30