fix: made BLE module less verbose by switching some of the logs to debug ones

This commit is contained in:
evilsocket 2019-04-21 14:00:43 +02:00
commit 5a62546c50
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
3 changed files with 7 additions and 6 deletions

View file

@ -39,7 +39,7 @@ func NewBLERecon(s *session.Session) *BLERecon {
gattDevice: nil,
quit: make(chan bool),
done: make(chan bool),
connTimeout: time.Duration(10) * time.Second,
connTimeout: time.Duration(5) * time.Second,
currDevice: nil,
connected: false,
}
@ -264,6 +264,7 @@ func (mod *BLERecon) enumAllTheThings(mac string) error {
go func() {
time.Sleep(mod.connTimeout)
if mod.isEnumerating() && !mod.connected {
mod.Warning("connection timeout")
mod.Session.Events.Add("ble.connection.timeout", mod.currDevice)
mod.onPeriphDisconnected(nil, nil)
}

View file

@ -13,7 +13,7 @@ func (mod *BLERecon) onStateChanged(dev gatt.Device, s gatt.State) {
switch s {
case gatt.StatePoweredOn:
if mod.currDevice == nil {
mod.Info("starting discovery ...")
mod.Debug("starting discovery ...")
dev.Scan([]gatt.UUID{}, true)
} else {
mod.Debug("current device was not cleaned: %v", mod.currDevice)
@ -37,7 +37,7 @@ func (mod *BLERecon) onPeriphDisconnected(p gatt.Peripheral, err error) {
mod.Session.Events.Add("ble.device.disconnected", mod.currDevice)
mod.setCurrentDevice(nil)
if mod.Running() {
mod.Info("device disconnected, restoring discovery.")
mod.Debug("device disconnected, restoring discovery.")
mod.gattDevice.Scan([]gatt.UUID{}, true)
}
}
@ -54,7 +54,7 @@ func (mod *BLERecon) onPeriphConnected(p gatt.Peripheral, err error) {
mod.connected = true
defer func(per gatt.Peripheral) {
mod.Info("disconnecting from %s ...", per.ID())
mod.Debug("disconnecting from %s ...", per.ID())
per.Device().CancelConnection(per)
mod.setCurrentDevice(nil)
}(p)
@ -65,7 +65,7 @@ func (mod *BLERecon) onPeriphConnected(p gatt.Peripheral, err error) {
mod.Warning("failed to set MTU: %s", err)
}
mod.Info("connected, enumerating all the things for %s!", p.ID())
mod.Debug("connected, enumerating all the things for %s!", p.ID())
services, err := p.DiscoverServices(nil)
// https://github.com/bettercap/bettercap/issues/498
if err != nil && err.Error() != "success" {

View file

@ -332,7 +332,7 @@ 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.Debug("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)
}