Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth barcode scanner #624

Open
thbl opened this issue Apr 27, 2020 · 29 comments
Open

Bluetooth barcode scanner #624

thbl opened this issue Apr 27, 2020 · 29 comments
Assignees
Labels

Comments

@thbl
Copy link

thbl commented Apr 27, 2020

Hi
I'm new to QZ, as i understand it i can use the HID api to read input from etc. a barcode scanner / keyboard ?

Tho i have tried claming device in demo and click open stream, i get no data from keyboard / barcode scanner ?

What am i doing wrong, using version 2.1

@tresf
Copy link
Contributor

tresf commented Apr 27, 2020

Barcode scanners generally ship with interfaces that are pre-configured. There are many different configurations, but in regards to connectivity, they generally support:

  • Keyboard emulation: If using a barcode scanner with keyboard emulation, QZ Tray is not needed, you can set focus to a hidden field and grab the data as if the keyboard were being used. Keyboard mode is out of scope for this project.
  • Raw HID: If using a barcode scanner with HID mode enable, QZ Tray can read from the barcode scanner using the HID interface: https://qz.io/wiki/hid-communication

Unfortunately, the default configuration of these devices isn't always obvious. In the case of my scanner, there was a booklet that shipped with it and I had to scan a configuration barcode to switch it from keyboard mode to HID mode.

Note, QZ Tray has been tested with Symbol (Zebra) and Honeywell barcode scanners in HID mode.

@thbl
Copy link
Author

thbl commented Apr 27, 2020

@tresf Thanks for your reply ! :)

HID is kind of serial emulation ?
Maby i should look for a SPP scanner instead, QZ should support this ?

@tresf
Copy link
Contributor

tresf commented Apr 27, 2020

HID is kind of serial emulation ?

Although some USB devices offer serial emulation, HID is quite different from serial.

Maby i should look for a SPP scanner instead, QZ should support this ?

I'm not sure what an SPP scanner is, but if you share the make/model of your barcode scanner, we can check quickly if it supports HID communication. Symbol (now part of Zebra) is the most popular barcode scanner in the United States and our product works with that just fine. Honeywell is another popular brand and we were able to get it working with some custom code (#288) so that is supported as well.

If your scanner is acting as a keyboard, you should see if it offers HID support, or share the product information with us so that we can check for you.

@thbl
Copy link
Author

thbl commented Apr 27, 2020

@tresf its just a cheep no brand bluetooth barcode scanner.
Tho in device maneger it says "HID..." but it writes on screen like a keyboard.

Do you have any experience with bluetooth reders ?
i looked at zebra & Honeywell but they looks exspensive ^^
thinking on maby buying this
https://tera-digital.com/collections/barcode-scanner-2d/products/tera-wireless-barcode-scanner-compatible-with-bluetooth#download

Thanks for your help so far ! :)

@tresf
Copy link
Contributor

tresf commented Apr 27, 2020

@tresf its just a cheep no brand bluetooth barcode scanner.

We're still interested, we try to be hardware agnostic and if there are cheap bluetooth barcode scanners being bought on mass, we'd love to support them like the big brands.

That said, bluetooth is an odd technology to interact with, so we'll need some more information. Firstly, yes, serial is a viable option for some Bluetooth devices, so I'll have to double-back a bit on my previous HID statements. This is because Bluetooth very specifically provides an RS232 emulation layer in the protocol. If you have a way to enable this, you can use our Serial API to communicate with the scanner.

In regards to the Tera digital brand, I have a feeling the comms will be very similar. Most often the cheaper hardware providers attempt to mimic the more expensive brands.

@thbl
Copy link
Author

thbl commented Apr 27, 2020

As i have read "HID MODE" is default for ble scanners, and only some support SPP mode (RS232 emulation)
The one i have don't support SPP mode, think i will buy the Tera one that supports SPP mode and do a test with that... :)

@tresf
Copy link
Contributor

tresf commented Apr 27, 2020

I have a Tera model arriving next Tuesday, so we can test viability.

@tresf tresf changed the title HID Dosen't work Bluetooth barcode scanner Apr 27, 2020
@thbl
Copy link
Author

thbl commented Apr 28, 2020

@tresf i also just oredre a Tera T5100, so will get back to you when it arrives and i have testet :D

@thbl
Copy link
Author

thbl commented Apr 30, 2020

@tresf just got my T5100 today
It has 3 BLE modes

  • Blutetooth HID mode
    Here it seams like it just work like a USB Keyboard, tho i can see it in QZ Tray HID list, it always past data like a keyboard.
  • Blutetooth SPP mode
    This mode emulate a serial / rs232, and can be openede over COM in QZ Tray
  • Blutetooth BLE mode
    Not sure what this mode is for, maby for mobile phones ?

So i guess the only way to make ble barcode reader work with QZ is to use the SPP mode with COM. Tho i think this will give some issues when reader goes in standby.

@thbl
Copy link
Author

thbl commented Apr 30, 2020

@tresf is it possible to listen for when BLE device connects / disconnect ?
To open / close COM
As when reader goes from active -> standby -> active You need to close & open COM for it to work again

@tresf
Copy link
Contributor

tresf commented Apr 30, 2020

@tresf is it possible to listen for when BLE device connects / disconnect ?
To open / close COM

Not really. You can continuously scan the COM ports and pop something up when a new one's discovered but the COM is relatively generic and if it's through Bluetooth I don't know if the OS removes and re-adds it each time it "connects", knowing it's the scanner would be quite hard, we'd need proper Bluetooth support to know that it's that actual scanner. Bluetooth support doesn't exist for Java proper, so it would be a pretty large enhancement to add it.

@thbl
Copy link
Author

thbl commented Apr 30, 2020

@tresf any sugestions on what else to do ? :)

@tresf
Copy link
Contributor

tresf commented Apr 30, 2020

@tresf any sugestions on what else to do ? :)

Mine will arrive on Friday and I'll know more. I don't have an SPP device to know the behavior. My experience with virtual COM ports is you can assign a number, so that might be a good way to control it, e.g. always use COM15 for scanner and you can have a way to check that port.

I don't know how this would work on Mac or Linux though. I'll know more when the hardware arrives, I guess. :D

@thbl
Copy link
Author

thbl commented Apr 30, 2020

@tresf in windows bluetooth maneger you can defind what virtual COM the bluetooth device should use.
Will do more testing tomorrow, but as i saw it the virtual ble com is always there even device is offline.
So main problem is to check what ever device is connected or not.

@tresf
Copy link
Contributor

tresf commented Apr 30, 2020

Blutetooth HID mode

Yeah they call it HID, but it's probably more accurately a HID keyboard, which we're locked out of communicating with for security/keylogging purposes. 🤣

Blutetooth BLE mode

I'd guess this is JSR-82, which is a proposal for Java to have Bluetooth support. It's implemented by a few open source libraries that we can include, but would offer a brand new tab to QZ Tray and take a few months to sort out. "BLE" I believe stands for "Bluetooth Low Energy" which I believe is a way for devices that go to sleep to have a way to wake up and be used immediately, a feature that would be great for QZ Tray, but would need to be slated for a later release.

Blutetooth SPP mode

I'm curious how the port behaves when the device sleeps or gets powered off. I think handling these scenarios is going to prove whether or not SPP is a viable solution. Since they offer this mode, it may be as easy as periodically checking that port, handling closing/opening, etc. This should be relatively easy if the COM port doesn't constantly change.

@tresf
Copy link
Contributor

tresf commented Apr 30, 2020

I'm curious how the port behaves when the device sleeps or gets powered off.

A good way to test this without QZ Tray is to install Putty, open to that COM port and see how Putty behaves. Putty is a nice way to testout the communication for a serial device without having QZ Tray in the middle. We should be able to mimic Putty.

@tresf tresf self-assigned this Apr 30, 2020
@thbl
Copy link
Author

thbl commented Apr 30, 2020

@tresf yea it would be great to have BLE support.
For SPP you can assign a static COM, but not 100% on the open/close after standby.
Will do more testing on the behavior tomorrow forgot the reader at office xD

@tresf
Copy link
Contributor

tresf commented Apr 30, 2020

Will do more testing on the behavior tomorrow forgot the reader at office xD

Mine will be in tomorrow too, we'll know more then.

@thbl
Copy link
Author

thbl commented May 1, 2020

@tresf
BLE Reader set to COM10

QZ
List serial ports always show COM10 even when reader is offline.

PUTTY
Reader offline -> open COM10 -> err:"Unable to open connection to COM10, Unable to open serial port"
Reader online -> open COM10 (Works)
When serial is open and reader goes offline/sleep mode, com windows is still showen in putty. But it dosent work before you close it and open a new window.

@tresf
Copy link
Contributor

tresf commented May 1, 2020

@thbl I ran out of time today, but when I get to this, I'll attempt to put together a small routine which automatically checks and opens communication to the device. I should have time time in the next few days.

@thbl
Copy link
Author

thbl commented May 2, 2020

@tresf
I found that for BLE there is actly already BLE build in most browsers.
"Web Bluetooth"
https://webbluetoothcg.github.io/web-bluetooth/
https://googlechrome.github.io/samples/web-bluetooth/

"LightBlue" app from android store can be used for find custom services/UUID

For Tera T5100 i found the BLE service to be 0000feea-0000-1000-8000-00805f9b34fb and the characteristic (data to read / notify) 00002aa1-0000-1000-8000-00805f9b34fb

I know this is a bit off topic, but wanted to share my findings as this has solved my app issue for the moment.. :)

@thbl
Copy link
Author

thbl commented May 2, 2020

@tresf
I found that for BLE there is actly already BLE build in most browsers.
"Web Bluetooth"
https://webbluetoothcg.github.io/web-bluetooth/
https://googlechrome.github.io/samples/web-bluetooth/

"LightBlue" app from android store can be used for find custom services/UUID

For Tera T5100 i found the BLE service to be 0000feea-0000-1000-8000-00805f9b34fb and the characteristic (data to read / notify) 00002aa1-0000-1000-8000-00805f9b34fb

I know this is a bit off topic, but wanted to share my findings as this has solved my app issue for the moment.. :)

Seams like its not possible to auto connect to a device tho..... :/
So think best way is if we can get the SPP serial to work some how with QZ @tresf looking forward to see if you can get this to work :D

@thbl
Copy link
Author

thbl commented May 2, 2020

@tresf maby this could be used in QZ to detected if device close com ?
https://stackoverflow.com/questions/45344383/detect-bluetooth-spp-disconnection-without-using-packets

@tresf
Copy link
Contributor

tresf commented May 4, 2020

@tresf maby this could be used in QZ to detected if device close com ?
https://stackoverflow.com/questions/45344383/detect-bluetooth-spp-disconnection-without-using-packets

I tried to continuously send data to the device in hopes that the interrupted connection would be caught, but it's not. Even Putty seems confused that the device has lost connection.

There's a barcode you can scan which will increase the default sleep time to 30 minutes with the downside of decreasing the battery life.

I'm also getting QZ Tray to become confused about whether or not the port is opened, requiring me to restart QZ Tray between tests.

Proper wake/sleep will likely require a bluetooth library and API expansion. Thoughts are welcome.

@tresf
Copy link
Contributor

tresf commented May 4, 2020

Perhaps a middleground is to set a JavaScript timeout that matches the scanner's default timeout which closes the port just before sleep occurs. I can assume that received data is the time it's going to start it's sleep countdown from. It's not ideal, but should at least close the connection out cleanly.

@thbl
Copy link
Author

thbl commented May 5, 2020

@tresf think it will give troubles to do a timeout function in JS.
If time dosent match 100% it will get stucked anyways

@thbl
Copy link
Author

thbl commented May 6, 2020

@tresf did you check if tera HID over cable works with qz ?

@tresf
Copy link
Contributor

tresf commented May 6, 2020

@tresf did you check if tera HID over cable works with qz ?

No I haven't but I'd expect this to work just fine, we're already integrated with Honeywell, Symbol (Zebra) without issue.

@tresf
Copy link
Contributor

tresf commented May 18, 2020

@tresf did you check if tera HID over cable works with qz ?

Albeit off-topic to the bluetooth portion of this bug report, I did try, but mine only offered Keyboard Emulation which I was unable to listen upon. I'd be happy to discuss this further over at #634.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants