From 2cdd3d22a573c660709f522e1661da57299c4b05 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Thu, 14 Feb 2019 16:08:38 +0100 Subject: [PATCH] misc: small fix or general refactoring i did not bother commenting --- modules/ble/ble_recon_events.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/ble/ble_recon_events.go b/modules/ble/ble_recon_events.go index 34eb7730..c3948f72 100644 --- a/modules/ble/ble_recon_events.go +++ b/modules/ble/ble_recon_events.go @@ -17,6 +17,7 @@ func (mod *BLERecon) onStateChanged(dev gatt.Device, s gatt.State) { dev.Scan([]gatt.UUID{}, true) } case gatt.StatePoweredOff: + mod.setCurrentDevice(nil) mod.gattDevice = nil default: @@ -29,12 +30,11 @@ func (mod *BLERecon) onPeriphDiscovered(p gatt.Peripheral, a *gatt.Advertisement } func (mod *BLERecon) onPeriphDisconnected(p gatt.Peripheral, err error) { + mod.setCurrentDevice(nil) if mod.Running() { - // restore scanning mod.Info("device disconnected, restoring discovery.") mod.gattDevice.Scan([]gatt.UUID{}, true) } - mod.setCurrentDevice(nil) } func (mod *BLERecon) onPeriphConnected(p gatt.Peripheral, err error) { @@ -42,7 +42,6 @@ func (mod *BLERecon) onPeriphConnected(p gatt.Peripheral, err error) { mod.Warning("connected to %s but with error: %s", p.ID(), err) return } else if mod.currDevice == nil { - // timed out mod.Warning("connected to %s but after the timeout :(", p.ID()) return }