Android Tutorial BlueTooth Printing via SPP

I finally have reliable, stable printing to a blue tooth printer (Citizen CMP-10 and CMP-20) from my Samsung 5570L Galaxy Mini Android Device running v2.3.6

Attached is a skeleton project (based on the Serial example posted here) in Basic4Android v1.8 that requires the following libraries

Core v1.77
Serial v1.20
ToggleLibrary 1.00

It may work with other versions but this is what works for me in my specific situation


To print you must first pair the phone/device to the printer

In the program you must place what you wish to print in PrintBuffer (string) variable and call StartPrinter (sub)

If the printer is not turned on it returns an error message and allows you to reprint

Hope this helps someone :)

Tim
 

Attachments

  • BTPrint.zip
    8.7 KB · Views: 6,606
Last edited:

imbault

Well-Known Member
Licensed User
Longtime User
For a very nice but really cheap printer check out these guys

http://rongtatech.com/

I get the RPP-02N model from Jeff for US$39 each

I have very satisfied customers - I just ordered another 20 units (already had 42 units from two previous orders)
Hi, I'm looking for a portable bluetooth printer, the one your describe seems very good

Just a question, can it print labels ?

Thanks
 

luke2012

Well-Known Member
Licensed User
Longtime User
Hi @timwil!
First Of All I say: "Thanks 4 sharing this!"

The Epson TM Printers are compatibile with ESC / POS commands ?
 

luke2012

Well-Known Member
Licensed User
Longtime User
@timwil So All the Printers that support this language works fine using the same ESC/POS script that I tested on a specific print model ?
 

luke2012

Well-Known Member
Licensed User
Longtime User
For a very nice but really cheap printer check out these guys

http://rongtatech.com/

I get the RPP-02N model from Jeff for US$39 each

I have very satisfied customers - I just ordered another 20 units (already had 42 units from two previous orders)

I have to integrate a Thermal printer for my italian customers. For DEV and test purpose the RPP-02N should be good, right?
Where I can bought it in the Europe marker ?
 

timwil

Active Member
Licensed User
Longtime User
Yes the ESC/POS is standard

I have purchased the printer for Bahamas and now for Nigeria all from China
 

timwil

Active Member
Licensed User
Longtime User
B4X:
Sub PrintBarCode(PrintData As String, ShowNumbers As Boolean)
   PrintBuffer.Append(Chr(29) & "h" & Chr(50) & CRLF)
   PrintBuffer.Append(Chr(29) & "w" & Chr(2) & CRLF)

   If ShowNumbers Then
      PrintBuffer.Append(Chr(29) & "H" & "2" & CRLF)
      PrintBuffer.Append(Chr(29) & "f" & "0" & CRLF)
   Else
      PrintBuffer.Append(Chr(29) & "H" & "0" & CRLF)
   End If

   PrintBuffer.Append(Chr(29) & "k" & Chr(4) & PrintData & Chr(0) & CRLF)
End Sub
 

imbault

Well-Known Member
Licensed User
Longtime User
Thanks
I changed
B4X:
PrintBuffer.Append(Chr(29) & "k" & Chr(4) & PrintData & Chr(0) & CRLF)
' for Code128
PrintBuffer.Append(Chr(29) & "k" & Chr(8) & PrintData & Chr(0) & CRLF)
 

imbault

Well-Known Member
Licensed User
Longtime User
Please @timwil , I have a question, just trying to send commands in order to change "page size" like explained in the Doc :
command format:
1A 5B 01
x_L x_H
y_L y_H
Width_L width_H
Height_L Height_H
Rotate
Input parameter::
x
Page refers to the recent position left top corner x –axis offset of the original point
relative label paper
y
Page refers to the recent position left top corner y –axis offset of the original point
relative label paper Width
Page width, x+Width value range is:[1,576]。
Height
Page height,Heigth value range is:[1, 1200]。
Rotate
Page rotation angle, Rotate value rang is:{0,1}. Page doesn’t rotate when Rotate is 0.
Do you know how to adapt that in B4A?

Many thanks
 

timwil

Active Member
Licensed User
Longtime User
I dont know what page size means as I use receipt paper that is line oriented instead of page oriented but to send it would be to add the characters as CHR() to the string

for example

printbuffer.append(chr(26))
printbuffer.append(chr(91))
printbuffer.append(chr(1))

or

printbuffer.append(chr(26) & chr(91) & chr(1))


this would add the 1A 5B 01 in your example above

1A = 26
5B = 91
01 = 1
 

imbault

Well-Known Member
Licensed User
Longtime User
I dont know what page size means as I use receipt paper that is line oriented instead of page oriented but to send it would be to add the characters as CHR() to the string

for example

printbuffer.append(chr(26))
printbuffer.append(chr(91))
printbuffer.append(chr(1))

or

printbuffer.append(chr(26) & chr(91) & chr(1))


this would add the 1A 5B 01 in your example above

1A = 26
5B = 91
01 = 1
Hi @timwil

In fact that label print has a label detector (the gap of the two labels , but i'm unable to perform a stupid form feed. Pressing the feed button is OK but
sending a CHR(12) moves the paper 0.5mm that's all, do you have a clever idea?
 
Top