From 223af913b8d29072c0549c864d5a9ca9027fef12 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Tue, 19 Feb 2019 11:13:48 +0100 Subject: [PATCH] new: new ble.clear command to clear devices collected by ble.recon --- modules/ble/ble_recon.go | 7 +++++++ network/ble.go | 6 ++++++ 2 files changed, 13 insertions(+) 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) +}