Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetworkPrinter disconnect after first print on WIN #27

Open
A7mdlbanna opened this issue Jun 18, 2023 · 6 comments
Open

NetworkPrinter disconnect after first print on WIN #27

A7mdlbanna opened this issue Jun 18, 2023 · 6 comments

Comments

@A7mdlbanna
Copy link

A7mdlbanna commented Jun 18, 2023

When I print using NetworkPrinter it prints only the first time and then it doesn't appear in .discover()

Reproduce:
connect ESC mm80 printer over WIFI to your computer.

Then use this snippet

      final profile = await CapabilityProfile.load();
      final printers = await NetworkPrinterManager.discover();
      print(printers.length); // at least one printer discovered
      NetworkPrinter printer = printers[0]; 
      var manager = NetworkPrinterManager(printer, PaperSize.mm80, profile);
      if(!printer.connected) {
        final res = await manager.connect()
        print(res.msg); // gives Success for the first time and then timeout
      }
      ConnectionResponse res = await manager.writeBytes(data, isDisconnect: false);
      print(res.msg,); // Success every time

      printers = await pos.NetworkPrinterManager.discover();
      print(printers.length); // 0
@A7mdlbanna
Copy link
Author

@kechankrisna any updates on what could be making this happen?

@grit-ameen
Copy link

any update on this

@grit-ameen
Copy link

call the connect method only once in initialization, don't call the connect method on every print, this works for me

@A7mdlbanna
Copy link
Author

i work with multiple printeres so i need to connect multiple times for one printer

Ex:

  • connects to Printer1

  • prints

  • disconnects from Printer1

  • connects to Printer2

  • prints

  • disconnects from printer2

and smoetimes i loop over the saved printers and prints like small reciepts if it's a restaurant containing a printer for each kitchen

@grit-ameen
Copy link

I have the same feature to do, let me work on these and I'll update if i encounter these issue,

@grit-ameen
Copy link

grit-ameen commented Feb 16, 2024

Hi @A7mdlbanna i have done this feature as print 2 network local IP printers create 2 NetworkPrinterManager and connect them at a time for handling multiple printers

eg:
_connect() async {
debugPrint('Connecting to printer');
var paperSize = PaperSize.mm80;
var profile = await CapabilityProfile.load();
NetWorkPrinter printerData1 = NetWorkPrinter(address: "192.168.100.105");
NetWorkPrinter printerData2 = NetWorkPrinter(address: "192.168.100.103");
var manager1 = NetworkPrinterManager(printerData1, paperSize, profile);
var manager2 = NetworkPrinterManager(printerData2, paperSize, profile);
await manager1.connect();
await manager2.connect();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants