diff --git a/modules/ble/ble_recon.go b/modules/ble/ble_recon.go index cd6c448a..88594866 100644 --- a/modules/ble/ble_recon.go +++ b/modules/ble/ble_recon.go @@ -57,6 +57,13 @@ func NewBLERecon(s *session.Session) *BLERecon { return mod.Stop() })) + mod.AddHandler(session.NewModuleHandler("ble.clear", "", + "Clear all devices collected by the BLE discovery module.", + func(args []string) error { + mod.Session.BLE.Clear() + return nil + })) + mod.AddHandler(session.NewModuleHandler("ble.show", "", "Show discovered Bluetooth Low Energy devices.", func(args []string) error { diff --git a/network/ble.go b/network/ble.go index 6f1592c9..c167ae17 100644 --- a/network/ble.go +++ b/network/ble.go @@ -104,3 +104,9 @@ func (b *BLE) EachDevice(cb func(mac string, d *BLEDevice)) { cb(m, dev) } } + +func (b *BLE) Clear() { + b.Lock() + defer b.Unlock() + b.devices = make(map[string]*BLEDevice) +}