picandies
Posts: 216
Joined: Wed Nov 26, 2014 5:13 pm

Hardware shows no service avail

Fri Oct 11, 2019 8:31 pm

I am going in circles trying to get this scanner working...so I'll post my steps , in case there is something I've overlooked!

The scanner works fine in windows10 Bluetooth in serial spp mode (terminal shows scan number codes)
Windows10 has been unpaired, so as to not potentially interfere with the rpi connection.

RPI4 with Stretch. Using cutecom serial terminal. Need to scan barcode numbers & see them in the terminal
Connect by bluetooth SPP.

1) All latest RPI updates have been applied
2) All rpi prefernces turned on , including serial port & serial console.
3) Edited /.../bluez.service to include
ExecStart=/usr/lib/bluetooth/bluetoothd -C
ExecStartPost=/usr/bin/sdptool add SP
4)rebooted rpi
5)Under blootooth icon scanner shows up as :
BarCode Scanner spp
6) select above & Hit PAIR...waits a second , then replies: Paired Successfully, but this device has no services which can be used with the raspberry pi !!!!!
Have I overlooked something? Something else needed installed/configured?
After many hours, this is quite aggravating!

If I config the scanner to HID mode, it can pair (pair with: scanner HID) to the rpi & scans show up in a command window (not serial terminal)....so the scanner & BT itself seem functional.

User avatar
neilgl
Posts: 1187
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Hardware shows no service avail

Fri Oct 11, 2019 9:08 pm

What scanner is it?

User avatar
Douglas6
Posts: 4783
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Hardware shows no service avail

Fri Oct 11, 2019 11:08 pm

I'm not sure that UI widget is completely accurate. Have you tried using rfcomm to create a virtual serial port with the scanner?

Code: Select all

sudo rfcomm connect 0 <bdaddr>
Replacing <bdaddr> with the Bluetooth device address of your scanner. That should give you a virtual serial port at /dev/rfcomm0.

picandies
Posts: 216
Joined: Wed Nov 26, 2014 5:13 pm

Re: Hardware shows no service avail

Sat Oct 12, 2019 12:24 am

What scanner is it?


Trohestar N3 unit..a nice unit
I'm not sure that UI widget is completely accurate.
what do you mean by that?
Never heard of rfcomm or finding a bluetooth address...is there some info? ...will do some sleuthing.

User avatar
Douglas6
Posts: 4783
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Hardware shows no service avail

Sat Oct 12, 2019 12:49 am

I mean the UI widget looks for a limited number of services (HID, A2DP) that don't require additional software.

You will need rfcomm (there's a plethora of info on this forum). Try it. You can find the bdaddr using the terminal with bluetoothctl. Enter that, then enter 'paired-devices'. The bdaddr is six hex double-digits separated by colons. Type 'exit' to exit bluetoothctl.

picandies
Posts: 216
Joined: Wed Nov 26, 2014 5:13 pm

Re: Hardware shows no service avail

Sat Oct 12, 2019 5:23 am

WOW! That seemed to do the trick...I got the address using the bluetoothctrl & did the rfcomm with the address..
Then I was able to open the terminal at /dev/rfcomm0 & scan some codes...for some reason after about a 30 second-1minute, it would no longer scan...not sure why (maybe the scanner is timing out).

It seems strange that the bluetooth ICON would not establish communications, or at least have a disclaimer--how would someone know? I've been trying it with several different scanners, with no luck until your hel!

Anyhow, that is a leap forward!! Can this setup/config be done in python? Any good links are appreciated. I want to take some I/O actions when certain codes are read.

User avatar
Douglas6
Posts: 4783
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Hardware shows no service avail

Sat Oct 12, 2019 1:56 pm

I would start by running rfcomm from a systemd service.

Code: Select all

sudo nano /etc/systemd/system/rfcomm.service
Enter the following into that file:

Code: Select all

[Unit]
Description=RFCOMM service
After=bluetooth.service
Requires=bluetooth.service
 
[Service]
ExecStart=/usr/bin/rfcomm bind 0 <bdaddr>
 
[Install]
WantedBy=multi-user.target
Use 'rfcomm bind' instead of 'rfcomm connect'. Replace <bdaddr> as per. Now, enable it with

Code: Select all

sudo systemctl enable rfcomm
Either reboot, or start the service with:

Code: Select all

sudo systemctl start rfcomm
That will prepare rfcomm to establish a connection and create the serial port when /dev/rfcomm0 is opened.

Now you can use Python's PySerial module to open and read/write to the scanner. You might want to use try/except blocks to catch and print out any errors. There are many PySerial tutorials on the webs. It comes pre-installed on Raspbian.

picandies
Posts: 216
Joined: Wed Nov 26, 2014 5:13 pm

Re: Hardware shows no service avail

Sat Oct 12, 2019 4:29 pm

@Douglas6

Thanks for the tips...you are the Bluetooth wiz!!
Your expert help is very appreciated!

Return to “General discussion”