fix: allowing ble.discover to be restarted (ref #74)

This commit is contained in:
evilsocket 2018-02-26 18:49:28 +01:00
commit 2d148b2b24

View file

@ -71,12 +71,17 @@ func (d BLERecon) Author() string {
}
func (d *BLERecon) Configure() (err error) {
// hey Paypal GATT library, could you please just STFU?!
golog.SetOutput(ioutil.Discard)
if d.gattDevice == nil {
// hey Paypal GATT library, could you please just STFU?!
golog.SetOutput(ioutil.Discard)
if d.gattDevice, err = gatt.NewDevice(defaultBLEClientOptions...); err != nil {
return err
}
if d.gattDevice, err = gatt.NewDevice(defaultBLEClientOptions...); err != nil {
return err
d.gattDevice.Handle(gatt.PeripheralDiscovered(d.onPeriphDiscovered))
d.gattDevice.Init(d.onStateChanged)
}
return nil
}
@ -119,9 +124,6 @@ func (d *BLERecon) Start() error {
return d.SetRunning(true, func() {
log.Debug("Initializing BLE device ...")
d.gattDevice.Handle(gatt.PeripheralDiscovered(d.onPeriphDiscovered))
d.gattDevice.Init(d.onStateChanged)
go d.pruner()
<-d.quit