我在Ubuntu 20.04和Raspberry Pi OS 5.10上使用这个程序,但这不是与Linux相关的问题。
当我使用一个不同的蓝牙适配器来扫描蓝牙设备时,我遇到了一个Go程序叫Bettercap 2的问题(https://www.bettercap.org/和仓库:https://github.com/bettercap/bettercap)。
使用Realtek RTL8761b驱动器的适配器(MPOW MPBH456AB)时,它能够正常工作,但当我使用一个NordicSemi nrf52840适配器(https://www.nordicsemi.com/Products/Development-hardware/nrf52840-dongle)进行闪存,并使用Zephyr RTOS的hci_usb示例(https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/bluetooth/hci_usb),它应该将使用蓝牙的任何微控制器转换为任何计算机都能识别的常规蓝牙适配器,但它会抛出这个错误:
>> ble.recon on
panic: runtime error: slice bounds out of range [:1] with capacity 0
goroutine 1 [running]:
github.com/bettercap/gatt/linux/cmd.(*Cmd).SendAndCheckResp(0x1c637c0, 0xa0c760, 0x1c64fe8, 0x1c6501c, 0x1, 0x1, 0x0, 0x0)
/home/pi/go/pkg/mod/github.com/bettercap/gatt@v0.0.0-20210514133428-df6e615f2f67/linux/cmd/cmd.go:98 +0x1b4
github.com/bettercap/gatt/linux.(*HCI).resetDevice(0x18ac0a0, 0x93dc10, 0x18ac0a0)
/home/pi/go/pkg/mod/github.com/bettercap/gatt@v0.0.0-20210514133428-df6e615f2f67/linux/hci.go:273 +0x2f0
github.com/bettercap/gatt/linux.NewHCI(0xffffffff, 0x184fd01, 0xff, 0x2, 0x0, 0x0)
/home/pi/go/pkg/mod/github.com/bettercap/gatt@v0.0.0-20210514133428-df6e615f2f67/linux/hci.go:90 +0x4c0
github.com/bettercap/gatt.NewDevice(0x184fd1c, 0x2, 0x2, 0x3c, 0x184fd24, 0x1, 0x1)
/home/pi/go/pkg/mod/github.com/bettercap/gatt@v0.0.0-20210514133428-df6e615f2f67/device_linux.go:57 +0x114
github.com/bettercap/bettercap/modules/ble.(*BLERecon).Configure(0x18a2780, 0x0, 0x4)
/home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/modules/ble/ble_recon.go:165 +0x1cc
github.com/bettercap/bettercap/modules/ble.(*BLERecon).Start(0x18a2780, 0x1, 0x1b2c001)
/home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/modules/ble/ble_recon.go:183 +0x1c
github.com/bettercap/bettercap/modules/ble.NewBLERecon.func1(0x0, 0x0, 0x0, 0x84f358, 0xc)
/home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/modules/ble/ble_recon.go:56 +0x1c
github.com/bettercap/bettercap/session.(*ModuleHandler).Exec(0x1b2c0c0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/session/module_handler.go:74 +0x80
github.com/bettercap/bettercap/session.(*Session).Run(0x18fb2c0, 0x1c64e30, 0xc, 0x1, 0x1)
/home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/session/session.go:416 +0x284
main.main()
/home/pi/go/pkg/mod/github.com/bettercap/bettercap@v2.24.1+incompatible/main.go:94 +0x8c8
由于我不是Go开发人员,也从未使用过这种语言,因此对于它的含义我一无所知。 我看了看错误信息,似乎代码有问题,但我不熟悉Go,所以在修改任何内容之前我更愿意询问。
只有在使用nrf dongle时才会出现问题,否则它可以使用主机的蓝牙和其他Realtek dongle正常工作。
nrf dongle可与BlueZ堆栈配合使用,以下是结果:
bluetoothctl(具有BD地址) 扫描确实有效
$ sudo bluetoothctl
Agent registered
[bluetooth]# list
Controller EB:XX:XX:XX:XX:XX BlueZ 5.50 [default]
btmgmt(查找控制器) 扫描功能正常工作。
$ sudo btmgmt --index 0
[hci0]# auto-power
Found controller with index 0
[hci0]# find -l
然而,尽管已被弃用,hciconfig和hcitool仍可以识别Realtek dongle。但对于这个,以下是结果:
hciconfig(没有BD地址)
$ hciconfig
hci0: Type: Primary Bus: USB
BD Address: 00:00:00:00:00:00 ACL MTU: 27:7 SCO MTU: 0:0
UP RUNNING
RX bytes:1593 acl:0 sco:0 events:88 errors:0
TX bytes:285 acl:0 sco:0 commands:51 errors:0
hcitool (未找到控制器)
$ hcitool scan
Scanning ...
Inquiry failed: Operation not supported
所以,我认为该无线钥匙与BlueZ兼容良好,因为它是Linux官方蓝牙堆栈,这是个好兆头,但我认为Bettercap也使用BlueZ,在这种意义上,该无线钥匙应该可以工作。
我认为没有需要安装的驱动程序,因为当它刷写(J-Link)后,它就变成了通用蓝牙钥匙。
您有任何想法,可能出了什么问题吗?