react-native-bluetooth-escpos-printer icon indicating copy to clipboard operation
react-native-bluetooth-escpos-printer copied to clipboard

Error: COMMAND_NOT_SEND

Open soadtechdev opened this issue 5 years ago • 5 comments

I can't get it to print, it worked only once, then it didn't work again, can you help me?

useEffect(()=>{
  BluetoothManager.isBluetoothEnabled().then((enabled)=> {
    setEnableBlue(enabled);
    if(enabled){
      BluetoothManager.enableBluetooth().then((r)=>{
        var paired = [];
        if(r && r.length>0){
            for(var i=0;i<r.length;i++){
                try{
                  let obj=JSON.parse(r[i]);
                 if(obj.address==="34:81:F4:36:52:BD"){

                  BluetoothManager.connect(obj.address).then(async(s)=>{
                  console.log("S====",s)
                    setEstadoBlue("CONECTADO AL DISPOSITIVO :"+obj.name);
                  await BluetoothEscposPrinter.printText("ESTA IMPRIMIENDO sera que necesita mas texto\n\r",{})
                  },
                  (err)=>{
                    setEstadoBlue("SIN CONEXION AL DISPOSITIVO :"+obj.name)
                  })

                 }
                }catch(e){
                    //ignore
                }
            }
        }
        console.log(JSON.stringify(paired))
 
    },(err)=>{
       alert(err)
   });
     
    }
}, (err)=> {
  setEnableBlue(false)
    alert(err)
}); 
},[])

soadtechdev avatar Sep 11 '20 21:09 soadtechdev

At the end of your document, add this line and it will print: await BluetoothEscposPrinter.printText("\n\r\n\r\n\r",{}); Hope this helps :)

ssjuma avatar Nov 26 '20 15:11 ssjuma

same error with printPic on IOS. How to fix it?

ombogdan avatar Aug 11 '21 09:08 ombogdan

i have the same issue on IOS , Did any one Solve it ?

mohamedsalehamin avatar Oct 06 '21 12:10 mohamedsalehamin

this worked for me BluetoothManager.enableBluetooth().then( (r) => { var paired = []; if (r && r.length > 0) { for (var i = 0; i < r.length; i++) { try { paired.push(JSON.parse(r[i])); let obj=JSON.parse(r[i]); if (obj.address === "20:18:05:22:03:06") { BluetoothManager.connect(obj.address) .then((s)=>{ console.log("S====",s) BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.CENTER); BluetoothEscposPrinter.setBlob(0); BluetoothEscposPrinter.printText("EazyFlow\n\r", { encoding: "GBK", codepage: 0, widthtimes: 1, heigthtimes: 1, fonttype: 0, }); BluetoothEscposPrinter.setBlob(0); BluetoothEscposPrinter.printText("Facture\n\r", { encoding: "GBK", codepage: 0, widthtimes: 0, heigthtimes: 0, fonttype: 0, }); BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.LEFT); BluetoothEscposPrinter.printText("Label:Vente des marchandise\n\r", {}); BluetoothEscposPrinter.printText("Code:xsd201909210000001\n\r", {}); BluetoothEscposPrinter.printText( "Date:" +new Date().getDate()+"-"+(new Date().getMonth()+1)+"-"+new Date().getFullYear() + "\n\r", {} ); BluetoothEscposPrinter.printText("Number:18664896621\n\r", {}); BluetoothEscposPrinter.printText( "--------------------------------\n\r", {} ); BluetoothEscposPrinter.printText("Amount:64000.00\n\r", {}); BluetoothEscposPrinter.printText("Tax:0.00\n\r", {}); BluetoothEscposPrinter.printText("Total:64000.00\n\r", {}); BluetoothEscposPrinter.printText( "--------------------------------\n\r", {} ); BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.CENTER); BluetoothEscposPrinter.printText("Thanks for payment\n\r\n\r\n\r\n\r", {}); BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.LEFT); }) } } catch (e) { //ignore } } } console.log(JSON.stringify(paired)); }, (err) => { alert(err); } );

Benjamin1-pro avatar Dec 23 '22 15:12 Benjamin1-pro

this worked for me BluetoothManager.enableBluetooth().then( (r) => { var paired = []; if (r && r.length > 0) { for (var i = 0; i < r.length; i++) { try { paired.push(JSON.parse(r[i])); let obj=JSON.parse(r[i]); if (obj.address === "20:18:05:22:03:06") { BluetoothManager.connect(obj.address) .then((s)=>{ console.log("S====",s) BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.CENTER); BluetoothEscposPrinter.setBlob(0); BluetoothEscposPrinter.printText("EazyFlow\n\r", { encoding: "GBK", codepage: 0, widthtimes: 1, heigthtimes: 1, fonttype: 0, }); BluetoothEscposPrinter.setBlob(0); BluetoothEscposPrinter.printText("Facture\n\r", { encoding: "GBK", codepage: 0, widthtimes: 0, heigthtimes: 0, fonttype: 0, }); BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.LEFT); BluetoothEscposPrinter.printText("Label:Vente des marchandise\n\r", {}); BluetoothEscposPrinter.printText("Code:xsd201909210000001\n\r", {}); BluetoothEscposPrinter.printText( "Date:" +new Date().getDate()+"-"+(new Date().getMonth()+1)+"-"+new Date().getFullYear() + "\n\r", {} ); BluetoothEscposPrinter.printText("Number:18664896621\n\r", {}); BluetoothEscposPrinter.printText( "--------------------------------\n\r", {} ); BluetoothEscposPrinter.printText("Amount:64000.00\n\r", {}); BluetoothEscposPrinter.printText("Tax:0.00\n\r", {}); BluetoothEscposPrinter.printText("Total:64000.00\n\r", {}); BluetoothEscposPrinter.printText( "--------------------------------\n\r", {} ); BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.CENTER); BluetoothEscposPrinter.printText("Thanks for payment\n\r\n\r\n\r\n\r", {}); BluetoothEscposPrinter.printerAlign(BluetoothEscposPrinter.ALIGN.LEFT); }) } } catch (e) { //ignore } } } console.log(JSON.stringify(paired)); }, (err) => { alert(err); } );

this works as expected thanks @Benjamin1-pro

OhFarhan avatar Sep 23 '23 08:09 OhFarhan