xiaozhizhong / flutter_simple_bluetooth_printer

MIT License
3 stars 2 forks source link

Can't not found writable characteristic Error #6

Open YahyaYousef opened 7 months ago

YahyaYousef commented 7 months ago

I'm trying to print a Raw Data from esc_pos_utils package put I'm getting this exception BTException{error: BTError.errorWithMessage, message: can't not found writable characteristic}

This is the function that prepare my data:

static Future<List<int>> getTicket() async {
    List<int> list = [];
    final profile = await CapabilityProfile.load();
    final generator = Generator(PaperSize.mm58, profile);
    //create image
    ByteData data = await rootBundle.load('assets/images/print_image.png');
    final Uint8List bytes = data.buffer.asUint8List();
    final image = decodeImage(bytes);
    //add image
    if (image != null) {
      list += generator.image(image);
    }
    //Thank
    list += generator.text(
      'Thank You For Visiting Our Shop',
      styles: PosStyles(
        align: PosAlign.center,
        bold: true
      ),
    );
    list+=generator.feed(1);
    return list;
  }

And I print the data like this:

 var data = await getTicket();
  printInvoice(bytes: Uint8List.fromList(data));
  Future<bool> printInvoice({required Uint8List bytes})async{
    var printed = await bluetoothManager.writeRawData(bytes);
    return printed;
  }
YahyaYousef commented 7 months ago

@xiaozhizhong Can You please help me as fast as you can?