chipweinberger / flutter_blue_plus

Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android, iOS, macOS
Other
771 stars 468 forks source link

[Help]: Android 14: Does not write correct commands to device every second time. #788

Closed xyzbilal closed 9 months ago

xyzbilal commented 9 months ago

Requirements

Have you checked this problem on the example app?

No

FlutterBluePlus Version

1.13.8 and 1.31.13

Flutter Version

3.16.9 and 3.10.5

What OS?

Android

OS Version

Android 14

Bluetooth Module

esp 32

What is your problem?

Hi, firstly thanks for your great effort. We have a veird problem on xiomi device android Android 14 installed. on other versions of android everything is fine.

the problem is this. we create rfid inventory request with following hex commands. and write to esp with 100 milliseconds delays sequentily and we see that device take commands first time.


Receive Command
8001000000005358002b000000080001008b0000000f00fb536f757263655f30000000000a006a00000006

Receive Command
8001000000005358002b000000080001008b0000000f00fb536f757263655f30000000000a006a00000000

Receive Command
80010000000053580035000000080001008a0000000f00fb536f757263655f30000000000a006a000000000000000a006b00000000

Receive Command
8001000400005358003f00000008000100130000000f00fb536f757263655f3000000000080050000000000006001100000008004e00000000000800670014

then send AB command and we disconnect device. below is esp serial output.

Receive Command
ab

Device Disconnected

when we connect second time and try to send commands second time device receives only 0100 command instead of sequential commands mentioned below.

Receive Command
0100
Future<void> startInventory() async {

var list = [
  "8001000000005358002b000000080001008b0000000f00fb536f757263655f30000000000a006a00000006", 
 "8001000000005358002b000000080001008b0000000f00fb536f757263655f30000000000a006a00000000",
"80010000000053580035000000080001008a0000000f00fb536f757263655f30000000000a006a000000000000000a006b00000000",
];

 final cmdString =   CommandCreate.createInventoryCommand();
  list.add(cmdString);
try{

if(isContinuous){
   list.forEach((element) async{
      final arr = element.hexStringToByteArray;

  await utils.writeCharacteristic?.write(arr,
          withoutResponse: utils.writeCharacteristic!.properties.writeWithoutResponse,);
  });
}else{

 await utils.writeCharacteristic?.write(cmdString.hexStringToByteArray,
          withoutResponse: utils.writeCharacteristic!.properties.writeWithoutResponse,);
}

}catch (e) {
logger.w(e);
}     

}

below logs shows reads from location services periodically and these are out of topic.

D/[FBP-Android](24940): [FBP] onCharacteristicWrite:
D/[FBP-Android](24940): [FBP]   chr: 542eec3a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)

Logs

============Successful reads=========

I/flutter (24940): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): │ #0   BluetoothMessenger.startInventory.<anonymous closure> (package:ebisflutter/core/utils/rfid_utils/messenger.dart:283:13)
I/flutter (24940): │ #1   List.forEach (dart:core-patch/growable_array.dart:416:8)
I/flutter (24940): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24940): │ ! 8001000000005358002b000000080001008b0000000f00fb536f757263655f30000000000a006a00000006
I/flutter (24940): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): │ #0   BluetoothMessenger.startInventory.<anonymous closure> (package:ebisflutter/core/utils/rfid_utils/messenger.dart:283:13)
I/flutter (24940): │ #1   List.forEach (dart:core-patch/growable_array.dart:416:8)
I/flutter (24940): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24940): │ ! 8001000000005358002b000000080001008b0000000f00fb536f757263655f30000000000a006a00000000
I/flutter (24940): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): │ #0   BluetoothMessenger.startInventory.<anonymous closure> (package:ebisflutter/core/utils/rfid_utils/messenger.dart:283:13)
I/flutter (24940): │ #1   List.forEach (dart:core-patch/growable_array.dart:416:8)
I/flutter (24940): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24940): │ ! 80010000000053580035000000080001008a0000000f00fb536f757263655f30000000000a006a000000000000000a006b00000000
I/flutter (24940): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): │ #0   BluetoothMessenger.startInventory.<anonymous closure> (package:ebisflutter/core/utils/rfid_utils/messenger.dart:283:13)
I/flutter (24940): │ #1   List.forEach (dart:core-patch/growable_array.dart:416:8)
I/flutter (24940): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24940): │ ! 8001000500005358003F00000008000100130000000F00FB536F757263655F3000000000080050000000000006001100000008004E00000000000800670014
I/flutter (24940): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
D/[FBP-Android](24940): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicWrite:
D/[FBP-Android](24940): [FBP]   chr: 542eec3a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicWrite:
D/[FBP-Android](24940): [FBP]   chr: 542eec3a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicWrite:
D/[FBP-Android](24940): [FBP]   chr: 542eec3a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicWrite:
D/[FBP-Android](24940): [FBP]   chr: 542eec3a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onCharacteristicChanged:
D/[FBP-Android](24940): [FBP]   chr: 542ee91a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP] onCharacteristicChanged:
D/[FBP-Android](24940): [FBP]   chr: 542ee91a-edd1-11ea-adc1-001999bed156
I/flutter (24940): {EB000BCE00000000000F4E6F: EPC :EB000BCE00000000000F4E6F, TID : null, RSSI : null}
D/[FBP-Android](24940): [FBP] onCharacteristicChanged:
D/[FBP-Android](24940): [FBP]   chr: 542ee91a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP] onCharacteristicChanged:
D/[FBP-Android](24940): [FBP]   chr: 542ee91a-edd1-11ea-adc1-001999bed156
I/flutter (24940): {EB000BCE00000000000F4E6F: EPC :EB000BCE00000000000F4E6F, TID : null, RSSI : null}
D/[FBP-Android](24940): [FBP] onCharacteristicChanged:
D/[FBP-Android](24940): [FBP]   chr: 542ee91a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP] onCharacteristicChanged:
D/[FBP-Android](24940): [FBP]   chr: 542ee91a-edd1-11ea-adc1-001999bed156
I/flutter (24940): {EB000BCE00000000000F4E6F: EPC :EB000BCE00000000000F4E6F, TID : null, RSSI : null} 
D/[FBP-Android](24940): [FBP] onCharacteristicChanged:
D/[FBP-Android](24940): [FBP]   chr: 542ee91a-edd1-11ea-adc1-001999bed156

>>>>>>>>>>>>>>>>>>>>================= NO Response from device==================<<<<<<<<<<<<<<<<<<

I/flutter (24940): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): │ #0   BluetoothMessenger.startInventory.<anonymous closure> (package:ebisflutter/core/utils/rfid_utils/messenger.dart:283:13)
I/flutter (24940): │ #1   List.forEach (dart:core-patch/growable_array.dart:416:8)
I/flutter (24940): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24940): │ ! 8001000000005358002b000000080001008b0000000f00fb536f757263655f30000000000a006a00000006
I/flutter (24940): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): │ #0   BluetoothMessenger.startInventory.<anonymous closure> (package:ebisflutter/core/utils/rfid_utils/messenger.dart:283:13)
I/flutter (24940): │ #1   List.forEach (dart:core-patch/growable_array.dart:416:8)
I/flutter (24940): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24940): │ ! 8001000000005358002b000000080001008b0000000f00fb536f757263655f30000000000a006a00000000
I/flutter (24940): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): │ #0   BluetoothMessenger.startInventory.<anonymous closure> (package:ebisflutter/core/utils/rfid_utils/messenger.dart:283:13)
I/flutter (24940): │ #1   List.forEach (dart:core-patch/growable_array.dart:416:8)
I/flutter (24940): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24940): │ ! 80010000000053580035000000080001008a0000000f00fb536f757263655f30000000000a006a000000000000000a006b00000000
I/flutter (24940): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (24940): │ #0   BluetoothMessenger.startInventory.<anonymous closure> (package:ebisflutter/core/utils/rfid_utils/messenger.dart:283:13)
I/flutter (24940): │ #1   List.forEach (dart:core-patch/growable_array.dart:416:8)
I/flutter (24940): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (24940): │ ! 8001000800005358003F00000008000100130000000F00FB536F757263655F3000000000080050000000000006001100000008004E00000000000800670014
I/flutter (24940): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
D/[FBP-Android](24940): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicWrite:
D/[FBP-Android](24940): [FBP]   chr: 542eec3a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicWrite:
D/[FBP-Android](24940): [FBP]   chr: 542eec3a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicWrite:
D/[FBP-Android](24940): [FBP]   chr: 542eec3a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onMethodCall: writeCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicWrite:
D/[FBP-Android](24940): [FBP]   chr: 542eec3a-edd1-11ea-adc1-001999bed156
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onMethodCall: readCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicRead:
D/[FBP-Android](24940): [FBP]   chr: 2a67
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onMethodCall: readCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicRead:
D/[FBP-Android](24940): [FBP]   chr: 2a67
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
D/[FBP-Android](24940): [FBP] onMethodCall: readCharacteristic
D/[FBP-Android](24940): [FBP] onCharacteristicRead:
D/[FBP-Android](24940): [FBP]   chr: 2a67
D/[FBP-Android](24940): [FBP]   status: GATT_SUCCESS (0)
chipweinberger commented 9 months ago

this is a problem in your device firmware probably.

or a problem in your app.

It is not possible for me to help you further. This is not a bug in FBP.

Edit: I just noticed you said it only happen on Android 14. Thats more surprising. But still, probably a problem in your device firmware.

chipweinberger commented 9 months ago

if you have more details to add, please reopen the issue.

I think this is a device firmware issue.