您究竟是如何尝试发送该命令的?试试:
BTPrinter.printPOSCommand(function(data){
console.log("Success");
console.log(data)
},function(err){
console.log("Error");
console.log(err)
}, "0x1d")
如果这不起作用,您可以尝试编辑插件本身以添加方法,但这有点复杂。
在 pluginfolder/src/android 的 Bluetoothprint.java 文件中尝试以下操作:
得到以下方法:
boolean printPOSCommand(CallbackContext callbackContext, byte[] buffer) throws IOException {
try {
//mmOutputStream.write(("Inam").getBytes());
//mmOutputStream.write((((char)0x0A) + "10 Rehan").getBytes());
mmOutputStream.write(buffer);
//mmOutputStream.write(0x0A);
// tell the user data were sent
Log.d(LOG_TAG, "Data Sent");
callbackContext.success("Data Sent");
return true;
} catch (Exception e) {
String errMsg = e.getMessage();
Log.e(LOG_TAG, errMsg);
e.printStackTrace();
callbackContext.error(errMsg);
}
return false;
}
将方法属性byte[] buffer改为string buffer
并换行
mmOutputStream.write(buffer);
到:
mmOutputStream.write(buffer.getBytes());
还只是为了确保您的打印机支持您可以尝试直接放置的方法:
mmOutputStream.write(0x1d);
只是为了测试它是否有效。
编辑:
试试我找到的这个 byteArray:
public static byte[] FEED_PAPER_AND_CUT = {0x1D, 0x56, 66, 0x00};
BTPrinter.printPOSCommand(function(data){
console.log("Success");
console.log(data)
},function(err){
console.log("Error");
console.log(err)
}, FEED_PAPER_AND_CUT)