xiaozhizhong / flutter_simple_bluetooth_printer

MIT License
3 stars 2 forks source link

Can't print when connected to printer "MHT-P80A", "FK-POS80-AT", on android #1

Open chuvanhoang888 opened 1 year ago

chuvanhoang888 commented 1 year ago

MHT-P80A image

FK-POS80-AT

image

Sir, How to fix this

xiaozhizhong commented 1 year ago

For MHT-P80A I didn't see any error logs. But for FK-POS80-AT I notice that there is an error: "can't not found writable characteristic". When printing with a Bluetooth printer,the printer device should have a writable characteristic. This error is throw when the plug-in couldn't find a writable characteristic. I didn't have those two printers so I couldn't test for you. You may install "nRF connect" App(or other Bluetooth kits) to connect to printer and try to find the problems. image

xiaozhizhong commented 1 year ago

https://github.com/NordicSemiconductor/Android-nRF-Connect

chuvanhoang888 commented 1 year ago

I noticed that your package is similar to this one. Both of my printers are working properly with this package. However, since this package uses connect function but not await as well as your package, I just wanted to fix the bug on your package.

Vào 18:13, Th 6, 17 thg 2, 2023 xiaozhizhong @.***> đã viết:

https://github.com/NordicSemiconductor/Android-nRF-Connect

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1434492646, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2BU47YUQAIFK2NV7VDWX5MN7ANCNFSM6AAAAAAU7INBE4 . You are receiving this because you authored the thread.Message ID: @.*** com>

xiaozhizhong commented 1 year ago

Did you forget to attach the package link? I didn't see the package link or name in your reply

chuvanhoang888 commented 1 year ago

Here Sir,

https://pub.dev/packages/flutter_pos_printer_platform

Vào 18:39, Th 6, 17 thg 2, 2023 xiaozhizhong @.***> đã viết:

Did you forget to attach the package link? I didn't see the package link or name in your reply

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1434520502, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2CKEJL6WD4GVY6JZOTWX5PQRANCNFSM6AAAAAAU7INBE4 . You are receiving this because you authored the thread.Message ID: @.*** com>

chuvanhoang888 commented 1 year ago

I need this package's "https://pub.dev/packages/flutter_pos_printer_platform" connect function to return true when BLE connection is successful but it doesn't, it always return false. I need it to wait until setCharacteristic() is done before return boolen

Vào 18:08, Th 6, 17 thg 2, 2023 xiaozhizhong @.***> đã viết:

For MHT-P80A I didn't see any error logs. But for FK-POS80-AT I notice that there is an error: "can't not found writable characteristic". When printing with a Bluetooth printer,the printer device should have a writable characteristic. This error is throw when the plug-in couldn't find a writable characteristic. I didn't have those two printers so I couldn't test for you. You may install "nRF connect" App(or other Bluetooth kits) to connect to printer and try to find the problems. [image: image] https://user-images.githubusercontent.com/18508389/219633238-05f1e670-0b06-4261-ab4d-53e00fe1b213.jpeg

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1434486330, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2HSU2U65B3DDW2JCXTWX5L3VANCNFSM6AAAAAAU7INBE4 . You are receiving this because you authored the thread.Message ID: @.*** com>

xiaozhizhong commented 1 year ago

@chuvanhoang888 I've made some enhancements on finding writable characteristic and create the branch v0.1.5, could you please give it a try by replacing following codes in your pubspec.yaml?

  flutter_simple_bluetooth_printer:
    git:
      url: https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer.git
      ref: v0.1.5

Changes:

  1. Add writable characteristic condition BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE;
  2. If no writable characteristic found, use characteristic with CLIENT_CHARACTERISTIC_CONFIG descriptor (Same as package flutter_pos_printer_platform);
  3. Add 'characteristicUuid' param to writeText & writeRawData. (If 'can't not found writable characteristic' error still occurs, you can specific the characteristicUuid to match the characteristic to write )
chuvanhoang888 commented 1 year ago

Thanks for your great support for the package. I will try the code again on Monday and get back to you

Vào 23:33, Th 6, 17 thg 2, 2023 xiaozhizhong @.***> đã viết:

@chuvanhoang888 https://github.com/chuvanhoang888 I've made some enhancements on finding writable characteristic and create the branch v0.1.5, could you please give it a try by replacing following codes in your pubspec.yaml?

flutter_simple_bluetooth_printer: git: url: https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer.git ref: v0.1.5

Changes:

  1. Add writable characteristic condition BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE;
  2. If no writable characteristic found, use characteristic with CLIENT_CHARACTERISTIC_CONFIG descriptor (Same as package flutter_pos_printer_platform);
  3. Add 'characteristicUuid' param to writeText & writeRawData. (If 'can't not found writable characteristic' error still occurs, you can specific the characteristicUuid to match the characteristic to write )

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1434886450, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2D4OK5XXMF65T5NA3LWX6R5FANCNFSM6AAAAAAU7INBE4 . You are receiving this because you were mentioned.Message ID: @.*** com>

chuvanhoang888 commented 1 year ago

For MHT-P80A I didn't see any error logs. But for FK-POS80-AT I notice that there is an error: "can't not found writable characteristic". When printing with a Bluetooth printer,the printer device should have a writable characteristic. This error is throw when the plug-in couldn't find a writable characteristic. I didn't have those two printers so I couldn't test for you. You may install "nRF connect" App(or other Bluetooth kits) to connect to printer and try to find the problems. image

@chuvanhoang888 I've made some enhancements on finding writable characteristic and create the branch v0.1.5, could you please give it a try by replacing following codes in your pubspec.yaml?

  flutter_simple_bluetooth_printer:
    git:
      url: https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer.git
      ref: v0.1.5

Changes:

  1. Add writable characteristic condition BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE;
  2. If no writable characteristic found, use characteristic with CLIENT_CHARACTERISTIC_CONFIG descriptor (Same as package flutter_pos_printer_platform);
  3. Add 'characteristicUuid' param to writeText & writeRawData. (If 'can't not found writable characteristic' error still occurs, you can specific the characteristicUuid to match the characteristic to write )

Hello Sir, Have a good day

1.I have tested v0.1.5 version on FK-POS80-AT printer, printing was done successfully, however out of 4 print times, 1 time printing failed.

1

  1. For the MHT-P80A printer, the printer is still not printing even though the writeText function returns true
  2. However, I see 1 Uuid feature: "BEF8D6C9-9C21-4C9E-B632-BD58C1009F9F" can make both machine "FK-POS80-AT" and "MHT-P80A" successful.

image image

chuvanhoang888 commented 1 year ago

Hello Sir, Have a good day

  1. I have tested v0.1.5 version on FK-POS80-AT printer, printing was done successfully, however out of 4 print times, 1 time printing failed. [image: image.png]
  2. For the MHT-P80A printer, the printer is still not printing even though the writeText function returns true
  3. However, I see 1 Uuid feature: "BEF8D6C9-9C21-4C9E-B632-BD58C1009F9F" can make both machine "FK-POS80-AT" and "MHT-P80A" successful. [image: image.png] [image: image.png]
  4. Have you added this "characteristicUuid" property for ios. On ios, printer "MHT-P80A" works normally and printer "FK-POS80-AT" gets error like on android

Vào Th 6, 17 thg 2, 2023 vào lúc 23:33 xiaozhizhong < @.***> đã viết:

@chuvanhoang888 https://github.com/chuvanhoang888 I've made some enhancements on finding writable characteristic and create the branch v0.1.5, could you please give it a try by replacing following codes in your pubspec.yaml?

flutter_simple_bluetooth_printer: git: url: https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer.git ref: v0.1.5

Changes:

  1. Add writable characteristic condition BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE;
  2. If no writable characteristic found, use characteristic with CLIENT_CHARACTERISTIC_CONFIG descriptor (Same as package flutter_pos_printer_platform);
  3. Add 'characteristicUuid' param to writeText & writeRawData. (If 'can't not found writable characteristic' error still occurs, you can specific the characteristicUuid to match the characteristic to write )

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1434886450, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2D4OK5XXMF65T5NA3LWX6R5FANCNFSM6AAAAAAU7INBE4 . You are receiving this because you were mentioned.Message ID: @.*** com>

xiaozhizhong commented 1 year ago

@chuvanhoang888

  1. For "I have tested v0.1.5 version on FK-POS80-AT printer, printing was done successfully, however out of 4 print times, 1 time printing failed", I noticed that your output error shows 'status 133', which might be a bug of Android. Please refer to https://github.com/dariuszseweryn/RxAndroidBle/wiki/FAQ:-Cannot-connect and https://issuetracker.google.com/issues/37121040. Maybe you can try add durations to each printing, or not calling disconnect after each printing but after all printing is done.
  2. For "For the MHT-P80A printer, the printer is still not printing even though the writeText function returns true", Some devices might has more than 1 writable characteristic, but not all those characteristic can handle your printing commands. This plugin will find out all writable characteristics but only use the first one. But even we use a wrong characteristic, the printing callback result might be still success. In this case, you should specific the characteristicUuid to tell this plugin which characteristic should be used.
  3. For "Have you added this "characteristicUuid" property for ios. On ios, printer "MHT-P80A" works normally and printer "FK-POS80-AT" gets error like on android". Not yet, I'm a little busy now and it's planned to the day after tomorrow.
chuvanhoang888 commented 1 year ago

Thanks for your feedback.

Vào 12:04, Th 2, 20 thg 2, 2023 xiaozhizhong @.***> đã viết:

@chuvanhoang888 https://github.com/chuvanhoang888

  1. For "I have tested v0.1.5 version on FK-POS80-AT printer, printing was done successfully, however out of 4 print times, 1 time printing failed", I noticed that your output error shows 'status 133', which might be a bug of Android. Please refer to https://github.com/dariuszseweryn/RxAndroidBle/wiki/FAQ:-Cannot-connect and https://issuetracker.google.com/issues/37121040. Maybe you can try add durations to each printing, or not calling disconnect after each printing but after all printing is done.
  2. For "For the MHT-P80A printer, the printer is still not printing even though the writeText function returns true", Some devices might has more than 1 writable characteristic, but not all those characteristic can handle your printing commands. This plugin will find out all writable characteristics but only use the first one. But even we use a wrong characteristic, the printing callback result might be still success. In this case, you should specific the characteristicUuid to tell this plugin which characteristic should be used.
  3. For "Have you added this "characteristicUuid" property for ios. On ios, printer "MHT-P80A" works normally and printer "FK-POS80-AT" gets error like on android". Not yet, I'm a little busy now and it's planned to the day after tomorrow.

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1436334284, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2D3LCDTY3NOR24XE5TWYL3NTANCNFSM6AAAAAAU7INBE4 . You are receiving this because you were mentioned.Message ID: @.*** com>

chuvanhoang888 commented 1 year ago

For ios: printer "MHT-P80A" works normally, but with printer "FK-POS80-AT" get error "Failed to write value for the characteristic. Error:The value's length is invalid."

[image: Screen Shot 2023-02-20 at 14.54.34.png]

Vào Th 2, 20 thg 2, 2023 vào lúc 12:04 xiaozhizhong < @.***> đã viết:

@chuvanhoang888 https://github.com/chuvanhoang888

  1. For "I have tested v0.1.5 version on FK-POS80-AT printer, printing was done successfully, however out of 4 print times, 1 time printing failed", I noticed that your output error shows 'status 133', which might be a bug of Android. Please refer to https://github.com/dariuszseweryn/RxAndroidBle/wiki/FAQ:-Cannot-connect and https://issuetracker.google.com/issues/37121040. Maybe you can try add durations to each printing, or not calling disconnect after each printing but after all printing is done.
  2. For "For the MHT-P80A printer, the printer is still not printing even though the writeText function returns true", Some devices might has more than 1 writable characteristic, but not all those characteristic can handle your printing commands. This plugin will find out all writable characteristics but only use the first one. But even we use a wrong characteristic, the printing callback result might be still success. In this case, you should specific the characteristicUuid to tell this plugin which characteristic should be used.
  3. For "Have you added this "characteristicUuid" property for ios. On ios, printer "MHT-P80A" works normally and printer "FK-POS80-AT" gets error like on android". Not yet, I'm a little busy now and it's planned to the day after tomorrow.

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1436334284, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2D3LCDTY3NOR24XE5TWYL3NTANCNFSM6AAAAAAU7INBE4 . You are receiving this because you were mentioned.Message ID: @.*** com>

xiaozhizhong commented 1 year ago

Can you please provide the commands? it seems that your printing commands are too long

chuvanhoang888 commented 1 year ago

Can you please provide the commands? it seems that your printing command

I use the package "esc_pos_utils" and only print a short piece of Unit8List code. Printer "MHT-P80A" performs normal printing

Screen Shot 2023-02-20 at 15 19 34

Screen Shot 2023-02-20 at 15 21 19

xiaozhizhong commented 1 year ago

Please copy and attch the bytess

chuvanhoang888 commented 1 year ago

Please copy and attch the bytess

`void _print2X1() async { if (selectedPrinter == null) return; //final codes = "Chu Van Hoang"; List bytes = [];

// Xprinter XP-N160I
final profile = await CapabilityProfile.load(name: 'XP-N160I');
// PaperSize.mm80 or PaperSize.mm58
final generator = Generator(PaperSize.mm80, profile);
bytes += generator.setGlobalCodeTable('CP1252');
bytes += generator.text('Test Print',
    styles: const PosStyles(align: PosAlign.center));
bytes += generator.text('Product 1');
bytes += generator.text('Product 2');
bytes += generator.text('Product 3');
bytes += generator.cut();
Uint8List bytess = Uint8List.fromList(bytes);
try {
  await _connectDevice();
  if (!_isConnected) return;
  final isSuccess = await bluetoothManager.writeRawData(bytess);
  if (isSuccess) {
    await bluetoothManager.disconnect();
  }
} on BTException catch (e) {
  print(e);
}

}`

chuvanhoang888 commented 1 year ago

Hello Sir, I just found an error when doing print on android that is: printout data is mising

final codes = "^XA\r\n^MMT\r\n^PW384\r\n^LL0253\r\n^LS0\r\n ^BY2,3,81^FT375,92^BCI,,N,N\r\n^FDILP-107661^FS\r\n^FT375,191^A0I,45,45^FH\ ^FDILP-107661^FS\r\n^FT374,27^A0I,23,24^FH\^FD^FS\r\n^FT372,59^A0I,23,24^FH \^FD^FS\r\n^PQ1,0,1,Y^PQ1^XZ\r\n";

Vào Th 2, 20 thg 2, 2023 vào lúc 15:31 xiaozhizhong < @.***> đã viết:

Please copy and attch the bytess

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1436542820, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2DLKLIIWQFU5CGFN5DWYMTU7ANCNFSM6AAAAAAU7INBE4 . You are receiving this because you were mentioned.Message ID: @.*** com>

xiaozhizhong commented 1 year ago

I googled "printout data is mising" but nothing came up, is this the original error text? The printing codes in example is in ZPL format for Zebra printers. If your printer dose not support ZPL, you should not use this codes for testing. See https://supportcommunity.zebra.com/s/article/ZPL-Command-Information-and-DetailsV2?language=en_US

chuvanhoang888 commented 1 year ago

can i contact you

Vào 8:51, Th 4, 22 thg 2, 2023 xiaozhizhong @.***> đã viết:

I googled "printout data is mising" but nothing came up, is this the original error text? The printing codes in example is in ZPL format for Zebra printers. If your printer dose not support ZPL, you should not use this codes for testing. See https://supportcommunity.zebra.com/s/article/ZPL-Command-Information-and-DetailsV2?language=en_US

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1439324882, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2D3KZDZLPTI66OXCNDWYVWK7ANCNFSM6AAAAAAU7INBE4 . You are receiving this because you were mentioned.Message ID: @.*** com>

xiaozhizhong commented 1 year ago

Sure. Email 97592100@qq.com

xiaozhizhong commented 1 year ago

@chuvanhoang888

  1. For "I have tested v0.1.5 version on FK-POS80-AT printer, printing was done successfully, however out of 4 print times, 1 time printing failed", I noticed that your output error shows 'status 133', which might be a bug of Android. Please refer to https://github.com/dariuszseweryn/RxAndroidBle/wiki/FAQ:-Cannot-connect and https://issuetracker.google.com/issues/37121040. Maybe you can try add durations to each printing, or not calling disconnect after each printing but after all printing is done.
  2. For "For the MHT-P80A printer, the printer is still not printing even though the writeText function returns true", Some devices might has more than 1 writable characteristic, but not all those characteristic can handle your printing commands. This plugin will find out all writable characteristics but only use the first one. But even we use a wrong characteristic, the printing callback result might be still success. In this case, you should specific the characteristicUuid to tell this plugin which characteristic should be used.
  3. For "Have you added this "characteristicUuid" property for ios. On ios, printer "MHT-P80A" works normally and printer "FK-POS80-AT" gets error like on android". Not yet, I'm a little busy now and it's planned to the day after tomorrow.

update: Added characteristicUuid for iOS

chuvanhoang888 commented 1 year ago

Hello,

Can you test this case on android

void _print2X1() async { if (selectedPrinter == null) return; List bytes = [];

// Xprinter XP-N160I final profile = await CapabilityProfile.load(name: 'XP-N160I'); // PaperSize.mm80 or PaperSize.mm58 final generator = Generator(PaperSize.mm80, profile); bytes += generator.setGlobalCodeTable('CP1252'); bytes += generator.text('Test Print', styles: const PosStyles(align: PosAlign.center)); bytes += generator.text('Product 1'); bytes += generator.text('Product 2'); bytes += generator.text('Product 3'); bytes += generator.cut(); Uint8List bytess = Uint8List.fromList(bytes); try { await _connectDevice(); if (!_isConnected) return; final isSuccess = await bluetoothManager.writeRawData(bytess); if (isSuccess) { await bluetoothManager.disconnect(); } } on BTException catch (e) { print(e); }

}`

Vào 21:22, Th 5, 23 thg 2, 2023 xiaozhizhong @.***> đã viết:

@chuvanhoang888 https://github.com/chuvanhoang888

  1. For "I have tested v0.1.5 version on FK-POS80-AT printer, printing was done successfully, however out of 4 print times, 1 time printing failed", I noticed that your output error shows 'status 133', which might be a bug of Android. Please refer to https://github.com/dariuszseweryn/RxAndroidBle/wiki/FAQ:-Cannot-connect and https://issuetracker.google.com/issues/37121040. Maybe you can try add durations to each printing, or not calling disconnect after each printing but after all printing is done.
  2. For "For the MHT-P80A printer, the printer is still not printing even though the writeText function returns true", Some devices might has more than 1 writable characteristic, but not all those characteristic can handle your printing commands. This plugin will find out all writable characteristics but only use the first one. But even we use a wrong characteristic, the printing callback result might be still success. In this case, you should specific the characteristicUuid to tell this plugin which characteristic should be used.
  3. For "Have you added this "characteristicUuid" property for ios. On ios, printer "MHT-P80A" works normally and printer "FK-POS80-AT" gets error like on android". Not yet, I'm a little busy now and it's planned to the day after tomorrow.

update: Added characteristicUuid for iOS

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1441882681, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2AVKYB77PL2PP3LRILWY5XDJANCNFSM6AAAAAAU7INBE4 . You are receiving this because you were mentioned.Message ID: @.*** com>

xiaozhizhong commented 1 year ago

I changed write withResponse to withoutResponse on iOS, Please try again to see if it's fixed.

chuvanhoang888 commented 1 year ago

[image: image.png] [image: image.png]

  1. I still can't print from the bytecode generated from the "flutter_esc_pos_utils" package on Android. However i tried splitting the bytecode and it prints successfully

https://pub.dev/packages/flutter_esc_pos_utils

  1. Printing on ios via FK-POS-80-AT printer still failed even though writable characterictis was found

service = '49535343-FE7D-4AE5-8FA9-9FAFD205E455'; bakeCharacteristic = '49535343-8841-43F4-A8D4-ECBE34729BB3';

                service = "E7810A71-73AE-499D-8C15-FAA9AEF0C3F2";
                bakeCharacteristic =

"BEF8D6C9-9C21-4C9E-B632-BD58C1009F9F";

[image: image.png]

Vào Th 5, 23 thg 2, 2023 vào lúc 22:59 xiaozhizhong < @.***> đã viết:

I changed write withResponse to withoutResponse on iOS, Please try again to see if it's fixed.

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/1#issuecomment-1442028921, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2BFGGB4TUW5KBI3CLTWY6CN5ANCNFSM6AAAAAAU7INBE4 . You are receiving this because you were mentioned.Message ID: @.*** com>