misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2019-02-14 16:08:38 +01:00
commit 2cdd3d22a5
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -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
}