Android Question Problem with Android 5 Bluetooth POS Printer

rscheel

Well-Known Member
Licensed User
Longtime User
I have a problem that I have not been able to solve, with the printing with Android 5, I am using a Bluetooth POS printer, it does not always print, many times it does not find the printer or it finds it but it does not establish connection, other times it does not print the complete ticket.

Meanwhile I have a phone with android 8, this prints always, without failing.

I think it should be a problem with Android 5 because with different devices with Android 5 the same thing happens.

B4X:
Printer.Initialize2(BTConnection.OutputStream,"windows-1252") 
        
        Printer.WriteLine(Chr(27)&"t"&Chr(16))
        Printer.WriteLine("   SOCIEDAD FORESTAL M4 LTDA.")
        Printer.WriteLine(" ")
        Printer.WriteLine("PATENTE     : "& PATENTE_PRT)
        Printer.WriteLine("TARA    : "& ModConn.nf.Format(TARA_PRT))
        Printer.WriteLine("CARGA   : "& ModConn.nf.Format(CARGA_PRT))
        Printer.WriteLine("TOTAL   : "& ModConn.nf.Format(TOTAL_PRT))
        Printer.WriteLine("FECHA   : "& FECHA_PRT)
        Printer.WriteLine(" ")
        Printer.WriteLine("DESPACHADOR : "& DESPACHADOR_PRT)
        Printer.WriteLine("N° GUÍA : "& NGUIA_PRT)
        Printer.WriteLine(" ")
        Printer.WriteLine("Sr. Conductor revise su guía y")
        Printer.WriteLine("que tenga un buen viaje.")
        Printer.WriteLine(" ")
        Printer.WriteLine("        www.avlchile.cl")
        Printer.WriteLine(" ")
        Printer.WriteLine(" ")
        Printer.WriteLine(" ")

    Sleep(2000)
    Printer.Flush
    Printer.Close
 

Peter Simpson

Expert
Licensed User
Longtime User
@rscheel please try the apk file in the link below on your devices and let me know if you are having the same issues (if it works at all), it's based on the standard Epson ESC/POS Commands.

https://www.dropbox.com/s/6jkfie27mj7g1qp/Bluetooth.apk?dl=0

Screenshot_20180413-105026-2.png


Peter...
 
Last edited:
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
It is a mistake to use TextWriter with Bluetooth connections. You need to use AsyncStreams.

About the connections issue, there isn't too much that you can do. Turning off and on the Bluetooth adapter might help.

I am currently turning the bluetooth on and off every time I print, I have not tried the AsyncStreams, any print example with AsyncStreams?
 
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User

Attachments

  • Screenshot_2018-04-13-08-12-30.png
    Screenshot_2018-04-13-08-12-30.png
    69.8 KB · Views: 250
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
What printer do you have, I take it that you selected the printer in the popup and the app just tries to connect 5 times with absolutely no success?

I purchased 2 different BT printers (set to Epson emulations) and everything works well here...
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Hmm really,
The app was specifically developed on an identical BT printer as the one you posted above, actually Manfred got one first then because he got one I then got one just for the fun of it.

I got one of my small BT printer from where it was safely boxed up and stored (it's identical to yours), I just turned on one of my older spare phones, I came to this thread, I downloaded and installed the app from the link that I previously posted and the results are as follows.

Snap.
front.jpg


back.jpg


Enjoy...
 
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
@Peter Simpson

It really is the phone, it is a Huawei P8 Lite Android 5.0, it is practically impossible to establish connection with the printer, I have other phones with android 5.1, 6, 7 and 8 and the printing works perfectly. Change the code as indicated by @Erel and apparently the impression is faster and more stable.

B4X:
ProgressDialogShow2("Imprimiendo...", False)
            
    trama = Chr(27)&"t"&Chr(16)& CRLF & CRLF & _
                  "   SOCIEDAD FORESTAL M4 LTDA."& CRLF & CRLF & CRLF & _
                  "PATENTE     : "& PATENTE_PRT & CRLF & _
                  "CAMION      : "& COD_CAMION_PRT & CRLF & _
                  "TARA    : "& ModConn.nf.Format(TARA_PRT) &" Kg"& CRLF & _
                  "CARGA   : "& ModConn.nf.Format(CARGA_PRT) &" Kg"& CRLF & CRLF & _ 
                  "TOTAL   : "& ModConn.nf.Format(TOTAL_PRT) &" Kg"& CRLF & CRLF & _
                  "FECHA   : "& FECHA_PRT & CRLF & _
                  "DESPACHADOR : "& DESPACHADOR_PRT & CRLF & _
                  "N° GUÍA : "& NGUIA_PRT & CRLF & CRLF & _
                  "FORESTAL M4 LTDA."& CRLF & CRLF & _
                  "Sr. Conductor revise su guía y"& CRLF &  _
                  "que tenga un buen viaje."& CRLF & CRLF & _
                  "        www.avlchile.cl" _
                  & CRLF & CRLF & CRLF & CRLF

    'Log(trama)
    ast.charset = "windows-1252"
    ast.Write(trama)
    Sleep(4000)
    ast.Close
    ProgressDialogHide
    
    BtAdmin.Disable
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
trama = Chr(27)&"t"&Chr(16)& CRLF & CRLF & _
" SOCIEDAD FORESTAL M4 LTDA."& CRLF & CRLF & CRLF & _
"PATENTE : "& PATENTE_PRT & CRLF & _
"CAMION : "& COD_CAMION_PRT & CRLF & _
"TARA : "& ModConn.nf.Format(TARA_PRT) &" Kg"& CRLF & _
"CARGA : "& ModConn.nf.Format(CARGA_PRT) &" Kg"& CRLF & CRLF & _
"TOTAL : "& ModConn.nf.Format(TOTAL_PRT) &" Kg"& CRLF & CRLF & _
"FECHA : "& FECHA_PRT & CRLF & _
"DESPACHADOR : "& DESPACHADOR_PRT & CRLF & _
"N° GUÍA : "& NGUIA_PRT & CRLF & CRLF & _
"FORESTAL M4 LTDA."& CRLF & CRLF & _
"Sr. Conductor revise su guía y"& CRLF & _
"que tenga un buen viaje."& CRLF & CRLF & _
" www.avlchile.cl" _
&
CRLF & CRLF & CRLF & CRLF

You should really watch this video tutorial, specifically the section about smart strings literal:

 
Upvote 0
Top