fixing tracking mode (yes again)

This commit is contained in:
kayos 2021-05-28 05:18:59 -07:00
parent 79577dc64e
commit 6e9176b99a

@ -111,31 +111,6 @@ func (s *Scan) resultHandler(scanAdapter *bluetooth.Adapter, result bluetooth.Sc
var sublog zerolog.Logger
//Services level logging
// TODO:
// Fix Loggin output here -- Prob shouldnt output this much info
// for each service discovered
// only each device
sublog = log.With().Int("Scan_ID", s.ID).
Str("LocalName", lname).Str("MAC", addr).
Str("ManuF", manuf).Int16("RSSI", rssi).Logger()
// Upon finding new and valid info we update the time for last activity
s.Activity = time.Now()
dev := s.NewDevice(lname, addr, manuf, rssi)
//AdvServBuf := make([]byte, 255)
// Record all the services advertised, append them into the nested struct within Device
for _, uuid := range uuids {
svc := &eros.Service{
UUID: uuid.String(),
}
dev.Services = append(dev.Services, *svc)
sublog.Debug().Str("UUID", svc.UUID).Msg("SERVICE_DISCOVERED")
}
layToRest := func(dev *eros.Device) {
sublog.Debug().Msg("Storing data with Eros")
eros.Remember(*dev)
@ -154,6 +129,41 @@ func (s *Scan) resultHandler(scanAdapter *bluetooth.Adapter, result bluetooth.Sc
Msg("EROS_RECALL")
}
//Services level logging
// TODO:
// Fix Loggin output here -- Prob shouldnt output this much info
// for each service discovered
// only each device
sublog = log.With().Int("Scan_ID", s.ID).
Str("LocalName", lname).Str("MAC", addr).
Str("ManuF", manuf).Int16("RSSI", rssi).Logger()
// Skipping duplicate results unless tracking mode enabled (to store RSSI as devices move)
if projVars.TrackingMode == false {
for _, dev := range s.Devices {
if addr == dev.MAC {
sublog.Debug().Msg("Skipping already scanned device")
return
}
}
}
// Upon finding new and valid info we update the time for last activity
s.Activity = time.Now()
dev := s.NewDevice(lname, addr, manuf, rssi)
//AdvServBuf := make([]byte, 255)
// Record all the services advertised, append them into the nested struct within Device
for _, uuid := range uuids {
svc := &eros.Service{
UUID: uuid.String(),
}
dev.Services = append(dev.Services, *svc)
sublog.Debug().Str("UUID", svc.UUID).Msg("SERVICE_DISCOVERED")
}
if !projVars.AttackMode {
layToRest(dev)
sublog.Debug().Msg("Skipping device connection")
@ -187,7 +197,7 @@ func (s *Scan) resultHandler(scanAdapter *bluetooth.Adapter, result bluetooth.Sc
// TODO: this will be running concurrently in a goroutine,
// so rather than set out timeout to be egregiously low we will just let it take its time
conTimeOut = time.Duration(5 * time.Second)
conTimeOut = time.Duration(50 * time.Millisecond)
if tick == nil {
endTime := time.After(conTimeOut)