Android Question POS printer: USB or BT?

udg

Expert
Licensed User
Hi all,
admittedly the subject is a bit deceiving. I'm not asking advice on which kind of printer to buy (unfortunately the customer already did it); rather, I'd like to hear from you whether an interface is preferable over the other (given both are available).
The context is easy. I had a B4J/Windows-only project working ok with an Epson TM-T20II printer. Then a customer asked for an Android version of it.
First step: convert existing code to B4xPages . Easier then expected. It took me less than one day
Second step: Adapt some UI elements from the 1024*768 fixed screen size to an old 10" Android tablet. Boring, but completed in an half day.

At that point the customer called, happily announcing to have just bought new tablets and printers ( so I had no chance of consulting..sigh ).
It seems (yes, at this moment I'm not 100% sure yet) that the tablet is a Vastking SA 10 while the printer should be a Starmicronics' mCP21LB

Now, looking at the specs, it seems that the tablet sports an USB-C connector that can work as an USB Virtual port and that the printer has its own USB (type B) port.
Both have BT 5.0 available too.

So (finally), what's my question? Here it is: Should I go the unknown "vitual usb port" path or switch to BT pairing?
If I read correctly the printer specs, that model doesn't use the ESC/EPSON mode so there's not so much I can re-use from the original TM-T20II module (which used javafx's "printBytes"/"printString" to send out data to the printer). Anyway, if using the USB interface is simply a matter of discover the virtual port name, then send out bytes according to the proper datasheet, it sounds easier and less error prone than BT. Am I right? What is your experience?
Thank you
 

agraham

Expert
Licensed User
If I could I would try both and then choose depending upon the experience and the environment (and type of user) of the intended application. BT is physically more convenient as the devices don't have to be tethered by a cable, but it does mean you might get possible pairing/operational problems with dimbo users.

Programming BT might be a bit simpler as it is just Serial library, AsyncStreams and go. You can pick up all the initialisation from my
Bluetooth ESC/POS Printer Class | B4X Programming Forum
Strip all the ESC/POS stuff and replace it with your own as in the end sending stuff to the printer comes down to

B4X:
' Send the contents of an array of bytes to the printer
' Remember that if the printer is expecting text the bytes will be printed as characters in the current code page
Public Sub WriteBytes(data() As Byte)
    If Connected Then
        Astream.Write(data)
    End If
End Sub

USB might take a bit more work. For my own use I would go BT as you can then charge on the go with possibly other benefits from leaving the USB port clear.
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Good sharing. I also have an old parallel port Epson thermal receipt printer working on Linux and exploring to use a Bluetooth thermal printer. I ordered one and waiting shipment from China.
 
Upvote 0

Peter Simpson

Expert
Licensed User
It's all down to personal preference and the situation that they are being used for.

I've developed apps for clients using B4A that print using Bluetooth and ethernet, I've also developed app (for testing purposes only) that use USB.

It's all down to what the printer is being used for. If the printer is supposed to be moved (mobile with a user) then Bluetooth is the only logical way forward, but if the printer is going to be static then use USB.

But saying that this is the B4A questions forum, so I would most probably just go with Bluetooth connectivity all the way as it's easy to integrate and there's no leads required ;)
 
Upvote 0

aeric

Expert
Licensed User
I haven’t seen any POS printer using WiFi. I only found WiFi+USB or Bluetooth printer to print sticker label or airways. Anyone has experience on WiFi printer? Is it same as printing through Ethernet?
 
Upvote 0

udg

Expert
Licensed User
Thanks all. So it seems that BT is the preferable way according to your experience and general advice.
As said, I've no special reason to stick to USB since I doubt I could reuse any significant part of the original module. The sw is now B4xPages-based so B4A and B4J (in my case) versions coexist . This is good since I could test on my PC anda have code working on an Android tablet almost "as is". The power of the B4X language and enviroment!

One doubt remains: would I (in the future) be able to use BT concurrently for printing and for a payment pad (you know, that device you use to accept credit cards and other contact-less payment types)? Or a BT chip can manage just one connection/pairing at time?

#Peter: to use a printer over Ethernet, is it possible to connect directly the PC and the printer through a cross-cable (having assigned fixed IPs to both) or at least an hub (ok, nowadays a switch) is always needed?
 
Upvote 0

Peter Simpson

Expert
Licensed User
#Peter: to use a printer over Ethernet, is it possible to connect directly the PC and the printer through a cross-cable (having assigned fixed IPs to both) or at least an hub (ok, nowadays a switch) is always needed?
Example for an Epson ethernet EPoS printer you can (as you already know) use your browser and type in the current EPoS printer IP address, you will end up viewing the Epson Net Config screen for the printer where you can make all sorts of setting changes.

If you were to connect a cross ethernet cable directly into the PC and type in the same IP address you will see the Epson Net Config screen in your browser, so yes you can connect directly to the printer with a cross cable.
 
Upvote 0

udg

Expert
Licensed User
so yes you can connect directly to the printer with a cross cable.
Thank you; very good news.
I had a plan B up the sleeve: an ESP32 (or similar) used to originate a small wi-fi network (just one device and a printer or even two devices and a printer).

This is because my solution often is used where there's no network available (and even tethering with a mobile isn't an option). So, anything (low-cost) that reliably connects A to B is welcomed :)
 
Upvote 0
Top