Kevin Ruiz
Kevin Ruiz

Reputation: 31

Print to thermal printer (DPP 450) from Android app

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?

Upvotes: 0

Views: 1906

Answers (3)

Harlin
Harlin

Reputation: 1

For ESC/POS protocol, switch the dipswitch (below battery) number 4 (protocol) off.

Upvotes: 0

Kevin Ruiz
Kevin Ruiz

Reputation: 31

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! :)

Upvotes: 3

sleske
sleske

Reputation: 83645

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...

Upvotes: 0

Related Questions