fix: fixed device index use for BLE module (fixes #994)

This commit is contained in:
evilsocket 2024-08-09 18:00:08 +02:00
parent 93de427f9a
commit 76e136a18e
3 changed files with 11 additions and 6 deletions

View file

@ -4,9 +4,11 @@ import (
"github.com/bettercap/gatt"
)
var defaultBLEClientOptions = []gatt.Option{
func getClientOptions(deviceID int) []gatt.Option {
return []gatt.Option{
gatt.MacDeviceRole(gatt.CentralManager),
}
}
/*

View file

@ -5,9 +5,11 @@ import (
// "github.com/bettercap/gatt/linux/cmd"
)
var defaultBLEClientOptions = []gatt.Option{
func getClientOptions(deviceID int) []gatt.Option {
return []gatt.Option{
gatt.LnxMaxConnections(255),
gatt.LnxDeviceID(-1, true),
gatt.LnxDeviceID(deviceID, true),
}
}
/*

View file

@ -1,3 +1,4 @@
//go:build !windows
// +build !windows
package ble
@ -166,7 +167,7 @@ func (mod *BLERecon) Configure() (err error) {
golog.SetFlags(0)
golog.SetOutput(dummyWriter{mod})
if mod.gattDevice, err = gatt.NewDevice(defaultBLEClientOptions...); err != nil {
if mod.gattDevice, err = gatt.NewDevice(getClientOptions(mod.deviceId)...); err != nil {
mod.Debug("error while creating new gatt device: %v", err)
return err
}