mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 05:23:19 -07:00
fix: fixed a bug in ble.recon which sometimes caused a crash if ble.recon off was called but no device was present
This commit is contained in:
parent
0cfe6eebcc
commit
f23c780eee
1 changed files with 12 additions and 10 deletions
|
@ -173,18 +173,20 @@ func (mod *BLERecon) Start() error {
|
|||
|
||||
<-mod.quit
|
||||
|
||||
mod.Info("stopping scan ...")
|
||||
if mod.gattDevice != nil {
|
||||
mod.Info("stopping scan ...")
|
||||
|
||||
if mod.currDevice != nil && mod.currDevice.Device != nil && mod.gattDevice != nil {
|
||||
mod.Debug("resetting connection with %v", mod.currDevice.Device)
|
||||
mod.gattDevice.CancelConnection(mod.currDevice.Device)
|
||||
}
|
||||
if mod.currDevice != nil && mod.currDevice.Device != nil {
|
||||
mod.Debug("resetting connection with %v", mod.currDevice.Device)
|
||||
mod.gattDevice.CancelConnection(mod.currDevice.Device)
|
||||
}
|
||||
|
||||
mod.Debug("stopping device")
|
||||
if err := mod.gattDevice.Stop(); err != nil {
|
||||
mod.Warning("error while stopping device: %v", err)
|
||||
} else {
|
||||
mod.Debug("gatt device closed")
|
||||
mod.Debug("stopping device")
|
||||
if err := mod.gattDevice.Stop(); err != nil {
|
||||
mod.Warning("error while stopping device: %v", err)
|
||||
} else {
|
||||
mod.Debug("gatt device closed")
|
||||
}
|
||||
}
|
||||
|
||||
mod.done <- true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue