From 7f68d0d82c1ed1363b3d4a28d1990cd7797c4388 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Thu, 14 Feb 2019 11:06:05 +0100 Subject: [PATCH] misc: small fix or general refactoring i did not bother commenting --- modules/ble/ble_recon.go | 8 ++++---- modules/ble/ble_recon_events.go | 20 +++++++++---------- .../ble/{ble_recon_view.go => ble_show.go} | 10 +++++----- .../{ble_recon_sort.go => ble_show_sort.go} | 0 4 files changed, 19 insertions(+), 19 deletions(-) rename modules/ble/{ble_recon_view.go => ble_show.go} (95%) rename modules/ble/{ble_recon_sort.go => ble_show_sort.go} (100%) diff --git a/modules/ble/ble_recon.go b/modules/ble/ble_recon.go index d4c31197..650e087d 100644 --- a/modules/ble/ble_recon.go +++ b/modules/ble/ble_recon.go @@ -115,7 +115,7 @@ func (mod *BLERecon) Configure() (err error) { if mod.Running() { return session.ErrAlreadyStarted } else if mod.gattDevice == nil { - mod.Info("Initializing BLE device ...") + mod.Info("initializing device ...") // hey Paypal GATT library, could you please just STFU?! golog.SetOutput(ioutil.Discard) @@ -145,7 +145,7 @@ func (mod *BLERecon) Start() error { <-mod.quit - mod.Info("Stopping BLE scan ...") + mod.Info("stopping scan ...") mod.gattDevice.StopScanning() @@ -161,7 +161,7 @@ func (mod *BLERecon) Stop() error { } func (mod *BLERecon) pruner() { - mod.Debug("Started BLE devices pruner ...") + mod.Debug("started devices pruner ...") for mod.Running() { for _, dev := range mod.Session.BLE.Devices() { @@ -198,7 +198,7 @@ func (mod *BLERecon) enumAllTheThings(mac string) error { return err } - mod.Info("Connecting to %s ...", mac) + mod.Info("connecting to %s ...", mac) go func() { time.Sleep(mod.connTimeout) diff --git a/modules/ble/ble_recon_events.go b/modules/ble/ble_recon_events.go index 441da193..f3346562 100644 --- a/modules/ble/ble_recon_events.go +++ b/modules/ble/ble_recon_events.go @@ -8,19 +8,19 @@ import ( ) func (mod *BLERecon) onStateChanged(dev gatt.Device, s gatt.State) { - mod.Info("BLE state changed to %v", s) + mod.Info("state changed to %v", s) switch s { case gatt.StatePoweredOn: if mod.currDevice == nil { - mod.Info("Starting BLE discovery ...") + mod.Info("starting discovery ...") dev.Scan([]gatt.UUID{}, true) } case gatt.StatePoweredOff: mod.gattDevice = nil default: - mod.Warning("Unexpected BLE state: %v", s) + mod.Warning("unexpected state: %v", s) } } @@ -31,7 +31,7 @@ func (mod *BLERecon) onPeriphDiscovered(p gatt.Peripheral, a *gatt.Advertisement func (mod *BLERecon) onPeriphDisconnected(p gatt.Peripheral, err error) { if mod.Running() { // restore scanning - mod.Info("Device disconnected, restoring BLE discovery.") + mod.Info("device disconnected, restoring discovery.") mod.setCurrentDevice(nil) mod.gattDevice.Scan([]gatt.UUID{}, true) } @@ -39,31 +39,31 @@ func (mod *BLERecon) onPeriphDisconnected(p gatt.Peripheral, err error) { func (mod *BLERecon) onPeriphConnected(p gatt.Peripheral, err error) { if err != nil { - mod.Warning("Connected to %s but with error: %s", p.ID(), err) + 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()) + mod.Warning("connected to %s but after the timeout :(", p.ID()) return } mod.connected = true defer func(per gatt.Peripheral) { - mod.Info("Disconnecting from %s ...", per.ID()) + mod.Info("disconnecting from %s ...", per.ID()) per.Device().CancelConnection(per) }(p) mod.Session.Events.Add("ble.device.connected", mod.currDevice) if err := p.SetMTU(500); err != nil { - mod.Warning("Failed to set MTU: %s", err) + mod.Warning("failed to set MTU: %s", err) } - mod.Info("Connected, enumerating all the things for %s!", p.ID()) + mod.Info("connected, enumerating all the things for %s!", p.ID()) services, err := p.DiscoverServices(nil) if err != nil { - mod.Error("Error discovering services: %s", err) + mod.Error("error discovering services: %s", err) return } diff --git a/modules/ble/ble_recon_view.go b/modules/ble/ble_show.go similarity index 95% rename from modules/ble/ble_recon_view.go rename to modules/ble/ble_show.go index d73f1997..9842ab3f 100644 --- a/modules/ble/ble_recon_view.go +++ b/modules/ble/ble_show.go @@ -228,7 +228,7 @@ func (mod *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) { chars, err := p.DiscoverCharacteristics(nil, svc) if err != nil { - mod.Error("Error while enumerating chars for service %s: %s", svc.UUID(), err) + mod.Error("error while enumerating chars for service %s: %s", svc.UUID(), err) continue } @@ -247,14 +247,14 @@ func (mod *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) { if wantsToWrite && mod.writeUUID.Equal(ch.UUID()) { foundToWrite = true if isWritable { - mod.Info("Writing %d bytes to characteristics %s ...", len(mod.writeData), mod.writeUUID) + mod.Info("writing %d bytes to characteristics %s ...", len(mod.writeData), mod.writeUUID) } else { - mod.Warning("Attempt to write %d bytes to non writable characteristics %s ...", len(mod.writeData), mod.writeUUID) + mod.Warning("attempt to write %d bytes to non writable characteristics %s ...", len(mod.writeData), mod.writeUUID) } err := p.WriteCharacteristic(ch, mod.writeData, !withResponse) if err != nil { - mod.Error("Error while writing: %s", err) + mod.Error("error while writing: %s", err) } } @@ -280,7 +280,7 @@ func (mod *BLERecon) showServices(p gatt.Peripheral, services []*gatt.Service) { } if wantsToWrite && !foundToWrite { - mod.Error("Writable characteristics %s not found.", mod.writeUUID) + mod.Error("writable characteristics %s not found.", mod.writeUUID) } else { tui.Table(os.Stdout, columns, rows) mod.Session.Refresh() diff --git a/modules/ble/ble_recon_sort.go b/modules/ble/ble_show_sort.go similarity index 100% rename from modules/ble/ble_recon_sort.go rename to modules/ble/ble_show_sort.go