react-native-bluetooth-escpos-printer
react-native-bluetooth-escpos-printer copied to clipboard
Cannot send print command to the device
Hello, I am using Evolute printer (https://www.evolute.in/fintech/impress/) and referring to the code to print receipt, following is my code, i am able to connect to the printer, but when i send printText command, there is no print or action on the printer side.
my app runs on android.
`` BluetoothManager.isBluetoothEnabled().then(enabled => { console.log('Bluetooth Enabled? ', enabled)
BluetoothManager.enableBluetooth().then(
r => {
var paired = []
if (r && r.length > 0) {
for (var i = 0; i < r.length; i++) {
try {
const bluetoothDevice = JSON.parse(r[i])
// console.log(bluetoothDevice.name)
paired.push(bluetoothDevice) // NEED TO PARSE THE DEVICE INFORMATION
if (bluetoothDevice.name === 'ESBAI4577') {
setPrinterAddress(bluetoothDevice.address)
console.log('Printer Address', bluetoothDevice.address)
}
} catch (e) {
//ignore
}
}
}
// console.log(JSON.stringify(paired))
BluetoothManager.connect(printerAddress) // the device address scanned.
.then(
async s => {
console.log('Connection Result: ', s)
await BluetoothEscposPrinter.printerInit()
await BluetoothEscposPrinter.setBlob(0)
await BluetoothEscposPrinter.printerLeftSpace(0)
await BluetoothEscposPrinter.printerAlign(
BluetoothEscposPrinter.ALIGN.CENTER,
)
await BluetoothEscposPrinter.printText(
'------------------------------\r\n',
{
encoding: 'UTF8',
widthtimes: 0,
heigthtimes: 0,
fonttype: 1,
},
)
await BluetoothEscposPrinter.printText(
'This is another text',
{},
)
await BluetoothEscposPrinter.printText(
'------------------------------\r\n',
{},
)
await BluetoothEscposPrinter.printText('\n\r\n\r\n\r', {})
console.log('Sent command to the printer')
},
e => {
// this.setState({
// loading: false,
// });
alert(e)
},
)
},
err => {
alert(err)
},
)
``
Thank you for such a wonderful library, any help appreciated.
Hi @rishihashbinary did you manage to solve this? I'm having the same problem with a brother QL-820NWB printer. The printer is recognized, successfully connected and no error is shown on print command but nothing is printed, no action at all in the printer. Thanks