0

I am developing an Android Java app that uses thermal printers to print delivery notes.

Actually I have two printer models that print ok via Bluetooth (using ESC/POS) but when I try to do it with the DPP-450 (which supports ESC/POS ), it connects ok via Bluetooth, but does not print anything.

The way I print is:

if (mbtSocket!=null && mbtSocket.isConnected()) {
    inReader = mbtSocket.getInputStream();
    outReader = mbtSocket.getOutputStream();
    int s = inReader.available();
    outReader.write(setInitp);
    String sendingmessage = "******************************" + "\n";
    byte[] send = sendingmessage.getBytes();
    outReader.write(send);
    sendingmessage = "Esto es una prueba de impresión" + "\n";
    send = sendingmessage.getBytes();
    outReader.write(send);
    outReader.flush();
    s = inReader.available();
    inReader.skip(0);
}

This piece of code works on my other two printers (Citizen CMP-40 and Star printer BTT), but not on the DPP-450.

Could some one help me please?

sleske
  • 81,358
  • 34
  • 189
  • 227
Kevin Ruiz
  • 21
  • 5

2 Answers2

2

I've found the issue.

It seems that this printer use the channel to determinate it, (no other try solved my issue), and later i adapted the code to my app, i post the way i solved it:

inReader = mbtSocket.getInputStream();
outReader = mbtSocket.getOutputStream();
ProtocolAdapter mProtocolAdapter = new ProtocolAdapter(inReader, outReader);
mPrinterChannel = mProtocolAdapter.getChannel(ProtocolAdapter.CHANNEL_PRINTER);
Printer printer = new Printer(mPrinterChannel.getInputStream(), mPrinterChannel.getOutputStream());
try{
    textBuffer.append("{reset}{center}{s}Thank You!{br}");
    printer.reset();
    printer.printTaggedText(textBuffer.toString());
    printer.feedPaper(110);
    printer.flush();  
} catch(Exception e){
    e.printStackTrace();
    Log.e("Error: " + e, "Error");
}

Hope this help some one else! :)

Kevin Ruiz
  • 21
  • 5
0

As the code works on other, similar printers, the code you present is probably not the problem.

You will have to troubleshoot this systematically:

  • Does the printer work on another computer? Maybe it is simply broken.
  • Can you connect to it using a simple program from your desktop computer? That rules out any Android-specific problems.

Try these steps, and then continue from there...

sleske
  • 81,358
  • 34
  • 189
  • 227
  • First thanks for ask. I've tried it and yes, those two steps works with no problem. The example from sdk provided by the printer manufacturer, has code for print like textBuffer.append("{reset}{right}{w}{h}TOTAL: {/w}$3.00 {br}"); textBuffer.append("{br}"); textBuffer.append("{reset}{center}{s}Thank You!{br}"); printer.reset(); printer.printTaggedText(textBuffer.toString()); But, correct me if I'm wrong, using ESC/POS, my code should works, right? – Kevin Ruiz Mar 09 '17 at 10:21
  • Sorry for the piece of code like this, i'm a bit new in this. – Kevin Ruiz Mar 09 '17 at 10:27