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

padvou

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
Do you perhaps know how to do a textreader? :oops:
 

Bryanne Vega

Member
Licensed User
Longtime User
No I just got the printer and just realized it had a credit card swiper. I'm able to print (text only). I'm pretty sure reading wont be a problem, just gotta learn how to listen :/
 

timwil

Active Member
Licensed User
Longtime User
try the demo/sample program that they have included to make sure it will read and everything is working

presumably the reader is an input device and you would use an input stream to read it

I have never done it - try some things - if they work let us know
 

Bryanne Vega

Member
Licensed User
Longtime User
It worked.

B4X:
cmp20 is Serial.

Dim inText As AsyncStreams      

inText.Initialize(cmp20.InputStream,cmp20.OutputStream,"inText")
      

Dim th As String
th = BytesToString(Buffer, 0, Buffer.Length, "ASCII")

Just make sure the device is connected and it will read it.
I recieve 3 seperate packets from time to time. Is there a way to wait for all data to be received instead of fetching new data one by one?
 

timwil

Active Member
Licensed User
Longtime User
What are you receiving?

The AsyncStream has a stream finished event does it not?
 

Bryanne Vega

Member
Licensed User
Longtime User
I'm not too familiar.
B4X:
B45********885^C    /BRYANNE^20*******000000?
;45*********85=20********274?

It has CreditCard data so I **** it out.
 

Bryanne Vega

Member
Licensed User
Longtime User
A small note: you would need to be connected to the device, see the forums on how to or send me a message ! :)
 

rubach

Member
Licensed User
Longtime User
Hello,
I am developing a POS solution with a Datamax Onell, Apex 3 (bluetooth), I can print with AsyncStreams, with POS command, but I have a problems to read from the printer after print, I need setup a first line to print, the paper have a blak mark to define de invoice, sometimes work but sometimes fail to read.

Any know hoy can read the black mark?

Thank you!
 

timwil

Active 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)
 

mrjaw

Active Member
Licensed User
Longtime User
Cant purchase, would you post link?

THis printer RPP-02 can print with ESC/POS commands? I worked with something like that and I cant use the ESC/POS from B4A but I use another app and this it can.
 
Top