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