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,622
Last edited:

timwil

Active Member
Licensed User
Longtime User
Sounds like the issue is with the conversion to Greek

Are you sure the printer actually prints in Greek?

When you send the greek data to the printer does it print anything at all?

Do you have a sample program (outside of the b4a program) that prints in Greek?
 

padvou

Active Member
Licensed User
Longtime User
Sounds like the issue is with the conversion to Greek

Are you sure the printer actually prints in Greek?

When you send the greek data to the printer does it print anything at all?

Do you have a sample program (outside of the b4a program) that prints in Greek?
Dear Timwil,
it's the first time I try to print to this printer without using the windows driver, so I'm not sure if it does..
 

timwil

Active Member
Licensed User
Longtime User
So I guess the first thing is to confirm that it does - see if there is a sample/test program you can get from the printer website to confirm
 

padvou

Active Member
Licensed User
Longtime User
So I guess the first thing is to confirm that it does - see if there is a sample/test program you can get from the printer website to confirm
Dearn Timwil,
I stored a font that prints Greek characters using the zebra utility sending the following lines to the printer:
B4X:
! 0 200 200 240 1
T Luc10pt.cpf 0 0 0 αβγδabcd
FORM
PRINT
but I cannot understand how to successfully send them to the printer.
 

timwil

Active Member
Licensed User
Longtime User
I have used this printer but have never tried to print in another language

I only used this printer because I did not have a choice and would not like to ever see it again

Good Luck with your problem
 

jahswant

Well-Known Member
Licensed User
Longtime User
Lol @timwil his explanings are really ambigous.But don't abandon him you're the boss on this thread.Me also i prefer simple maleable chinese printers...
 

timwil

Active Member
Licensed User
Longtime User
Sorry if it seemed to be abandoning

I don't have this printer and can't begin to think of where to start
 

padvou

Active Member
Licensed User
Longtime User
Come next week, I'm picking up an iMZ220 and a star, so I'll update this thread with news..
o_O
 

padvou

Active Member
Licensed User
Longtime User
I send the greek characters using Chr(...)
But this is printed when extended characters are printed:
upload_2015-5-22_14-47-36.png

What are these characters printed between the letters?
Solved changing codepage and character set.
 
Last edited:

padvou

Active Member
Licensed User
Longtime User
Here's another thing:
the printout is long and after the
Printer.flush command
comes the
printer.close command
However, if the printing is not over yet, the last command stops the printing. Can this be avoided somehow so that the last command is issued after the printing is completed?
 

timwil

Active Member
Licensed User
Longtime User
put up a msgbox - that will give enough time for the printer to receive all the data
 

padvou

Active Member
Licensed User
Longtime User
put up a msgbox - that will give enough time for the printer to receive all the data
Probably something like "Click OK if printing was successful"?
I guess the printer does not return a successful printing ?
 

timwil

Active Member
Licensed User
Longtime User
B4X:
Sub Printer_Connected (Success As Boolean)
    If Success Then
        printer.Initialize(cmp20.OutputStream)
        printer.WriteLine(PrintBuffer.ToString)
        printer.Flush

        Msgbox("Printed!","")
        printer.Close
        cmp20.Disconnect
    Else
        If Msgbox2("", "Printer Error","Reprint","Cancel","",Null) = DialogResponse.POSITIVE Then
            StartPrinter
        End If
    End If
End Sub
 

timwil

Active Member
Licensed User
Longtime User
How do you read?

B4X:
Dim cmp20 As Serial
Dim printer As TextWriter

I personally have not read from the bluetooth. What exactly are you trying to read?
 

padvou

Active Member
Licensed User
Longtime User
How do you read?

B4X:
Dim cmp20 As Serial
Dim printer As TextWriter

I personally have not read from the bluetooth. What exactly are you trying to read?

I would like to read the stream (if any) coming from the printer back to the android device.
 

timwil

Active Member
Licensed User
Longtime User
The Bluetooth connection is bidirectional so conceivably that can be done

I don't know if the SPP profile supports it though

Give it a try

I assume you would do a textreader

I haven't done it so I cannot really say
 
Top