1

bluetoothctl sees ITAG device, but python and pybluez doesn't on Raspberry Pi Zero W

This is what I get via bluetoothctl:

pi@rpitouch:~ $ sudo bluetoothctl
[NEW] Controller B8:27:EB:6A:C0:8F rpitouch [default]
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:6A:C0:8F Discovering: yes
[NEW] Device AC:37:43:F6:91:BF HTC BS BFED75
[NEW] Device AC:37:43:F6:13:98 HTC BS 9885EC
[CHG] Device AC:37:43:F6:91:BF RSSI: -66
[CHG] Device AC:37:43:F6:91:BF TxPower: 4
[NEW] Device FC:58:FA:A3:3A:76 ITAG
[CHG] Device AC:37:43:F6:13:98 RSSI: -61

The ITAG device is a cheap little Tile-style Chinese "find my keys" type bluetooth device, which is what I'm trying to find. The two HTC are probably our HTV Vive lighthouses.

Using Python 2 and jumping through all the hoops to install pybluez and gattlib and all that, using the attached code, I get:

pi@rpitouch:~ $ sudo python blue.py
found 1 bluetooth devices
 F8:34:41:8B:D0:25 - DESKTOP-NUBAQ2D
found 0 btle devices

The DESKTOP-NUBAQ2D is a desktop PC with built in bluetooth that talks to the HTC Vive lighthouses via BT.

I also tried the BeaconService option and got zero results too.

It looks like bluetoothctl and pybluez are scanning different things if they're finding different devices. Like bluetoothctl is looking for devices and pybluez is looking for hosts?

Some recommendations were to change service.discover(2) to a higher number, indicating that was 2 seconds of scan time, but it stops immediately whether it's 2 or 20... so maybe that discover(20) isn't working correctly?

Is there a verbose mode or some other options I can try or sometime I'm missing (maybe a configuration that needs to be tweaked for RPi Zero.. like it's not pointing to the correct device?)

I'm experienced on programming, but fairly green on python and this corner of the linux ecosystem, so being specific about which files or things to check is appreciated... or at least enough keywords that I can google the specifics.

Thanks!

# https://github.com/pybluez/pybluez
import bluetooth

nearby_devices = bluetooth.discover_devices(lookup_names=True)
print("found %d bluetooth devices" % len(nearby_devices))

for addr, name in nearby_devices:
    print(" %s - %s" % (addr, name))

#bluetooth low energy scan
from bluetooth.ble import DiscoveryService

service = DiscoveryService()
print("Starting scan")
devices = service.discover(20)

print("found %d btle devices" % len(devices))

for address, name in devices.items():
    print("name: {}, address: {}".format(name, address))
  • FWIW.. I stumbled across PyBlue and a BT guide for Raspberry Pi and I'm having much better luck: https://elinux.org/RPi_Bluetooth_LE – Trevor Gryffyn Apr 21 '19 at 21:50

0 Answers0