Android Question Printing on sunmi innerprinter

Status
Not open for further replies.

sidug

Member
Licensed User
Hello together,

could someone help me how to print on the innerprinter at a sunmi device ?
 

Lello1964

Well-Known Member
Licensed User
Longtime User
Can you message me? id like to pay you to implement sunmi printing into my app. whattss app +61468582564
Hi,
hello it is very easy to print with sunmi.
You can use the sd library, which sunmi model do you have?
If it has an integrated printer, you can connect it to the device itself via Bluetooth and print via the sd library using the Bluetooth connection.

This Sd library link :


I hope I was helpful.
Unfortunately I don't speak English well, so it would be difficult to communicate via WhatsApp.

Raffaele
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
I know this is a old thread, however I am not sucessful in printing on sunmi machines.

I have t2 mini, d2 mini and V2 with me right now... I have tried each of the examples I have found on the forum and none worked.

Is there someone with experience with any of the innerprinter from Sunmi that could give a direction on how to use it?
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
What's your problem?
connect to printer ?
I CAN connect.. that is fine.. but I send anything to it and get no printing....

But if i connect using external bluetooth printer it works just fine... Only the sunmi that does no work.

I have downloaded RAWBT from play store and that one works, so there is no problem with the equipment.

Any ideas:?
 
Upvote 0

Lello1964

Well-Known Member
Licensed User
Longtime User
connect built-in printer via BT as InnnerPrinter, then print via Bt connection.
IMG_20220722_161905.jpg
IMG_20220722_161943.jpg
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
yes, I do exactly like you demonstrate, however I am using a more recent version of this equipment Sunmi V2 (3.2.27) android 7.1.1

It does connect like yors, using the innerprinter, but prints nothing

using an app like rawbt it works as bluetooth just fine.

Very strange
 
Upvote 0

Doctor Bit

New Member
yes, I do exactly like you demonstrate, however I am using a more recent version of this equipment Sunmi V2 (3.2.27) android 7.1.1

It does connect like yors, using the innerprinter, but prints nothing

using an app like rawbt it works as bluetooth just fine.

Very strange
I also have the same problem. In Sunmi V2 all works fine, in Sunmi T2 mini the same app doesn't print anything... Someone have any workaround?
 
Upvote 0
I got some sample code in Java does anyone want to wrap it for me

import com.sunmi.peripheral.printer.InnerPrinterCallback;
import com.sunmi.peripheral.printer.InnerPrinterException;
import com.sunmi.peripheral.printer.InnerPrinterManager;
import com.sunmi.peripheral.printer.InnerResultCallback;
import com.sunmi.peripheral.printer.SunmiPrinterService;

public class Printer {

private static String TAG = "Printer";
private String printerExceptionMessage;
private String lastFunctionProcessed;
private SunmiPrinterService mSunmiPrinterService;

public int init(Context context) {
try {
boolean result = InnerPrinterManager.getInstance().bindService(context, innerPrinterCallback);
} catch (InnerPrinterException e) {
Log.e(TAG, "Printer initialise error: " + e);
return -1;
}
return 0;
}

private InnerPrinterCallback innerPrinterCallback = new InnerPrinterCallback() {
@override
protected void onConnected(SunmiPrinterService service) {
Log.i(TAG, "Printer connected");
mSunmiPrinterService = service;
}

@override
protected void onDisconnected() {
Log.i(TAG, "Printer disconnected");
}
};

private InnerResultCallback printFinishedCallback = new InnerResultCallback() {
@override
public void onRunResult(boolean isSuccess) throws RemoteException {
Log.i(TAG, "printFinishedCallback: onRunResult=" + isSuccess);
}

@override
public void onReturnString(String result) throws RemoteException {
Log.i(TAG, "printFinishedCallback: onReturnString=" + result);
}

@override
public void onRaiseException(int code, String msg) throws RemoteException {
Log.i(TAG, "printFinishedCallback: onRaiseException=" + msg);
}

@override
public void onPrintResult(int code, String msg) throws RemoteException {
Log.i(TAG, "printFinishedCallback: onPrintResult=" + msg);
}
};

private InnerResultCallback printResultCallback = new InnerResultCallback() {
@override
public void onRunResult(boolean isSuccess) throws RemoteException {
Log.i(TAG, "printResultCallback: onRunResult = " + isSuccess);
}

@override
public void onReturnString(String result) throws RemoteException {
Log.i(TAG, "printResultCallback: onReturnString = " + result);
}

@override
public void onRaiseException(int code, String msg) throws RemoteException {
Log.i(TAG, "printResultCallback: onRaiseException = " + msg);
printerExceptionMessage = msg;
}

@override
public void onPrintResult(int code, String msg) throws RemoteException {
Log.i(TAG, "printResultCallback: onPrintResult = " + msg);
}
};

public String getPrinterExceptionMessage() {
return printerExceptionMessage;
}

private int getPrinterStatus() {
printerExceptionMessage = "";

if (mSunmiPrinterService == null) {
Log.i(TAG, "Error, mSunmiPrinterService == null");
printerExceptionMessage = "Printer service not initialised";
return -1;
}

try {
int printerStatus = mSunmiPrinterService.updatePrinterState();

Log.i(TAG, "printerStatus=" + printerStatus);
switch (printerStatus) {
case 1: // Normal
case 2: // under preparation
break;
case 3:
printerExceptionMessage = "Printer comms error";
return -2;
case 4:
printerExceptionMessage = "Printer is out of paper";
return -3;
case 5:
printerExceptionMessage = "Printer overheated";
return -4;
case 6:
printerExceptionMessage = "Printer cover open";
return -5;
case 7:
printerExceptionMessage = "Cutter error";
return -6;
case 8: // cutter recovered
case 9: // black mark not detected
break;
case 505:
printerExceptionMessage = "No printer detected";
return -7;
case 507:
printerExceptionMessage = "Printer firmware update failed";
return -8;
}
}
catch (Exception e) {
printerExceptionMessage = e.getMessage();
Log.e(TAG, "getPrinterStatus exception: " + e);
return -10;
}

return 0;
}

public int printBitmap(Bitmap bitmap) {
Log.i(TAG, "printBitmap:" + bitmap.toString());

int printerStatus = getPrinterStatus();
if (printerStatus != 0) return printerStatus;

try {
mSunmiPrinterService.lineWrap(1, printResultCallback);
mSunmiPrinterService.printBitmap(bitmap, printResultCallback);
mSunmiPrinterService.lineWrap(1, printResultCallback);
mSunmiPrinterService.commitPrinterBufferWithCallback(printFinishedCallback);
} catch (RemoteException e) {
Log.e(TAG, "printBitmap Exception:" + e);
return -10;
}

return 0;
}

}
 
Upvote 0
Status
Not open for further replies.
Top