Basic manufacturer string output is working! Should for sure be refined from here.

This commit is contained in:
freqyXin 2021-05-30 21:44:55 -07:00
parent e294599c16
commit f0c76853ee
3 changed files with 37 additions and 12 deletions

@ -53,7 +53,6 @@ func init() {
dust.PrintBanner()
ScanMgr = &scanStuff.Meta{
Count: 0,
Scans: make(map[int]*scanStuff.Scan),

@ -20,10 +20,11 @@ import (
"time"
//"errors"
"git.tcp.direct/kayos/prototooth"
projVars "protomolecule/src/vars"
bluetooth "git.tcp.direct/kayos/prototooth"
"github.com/prologic/bitcask"
"github.com/rs/zerolog/log"
projVars "protomolecule/src/vars"
)
var (
@ -34,10 +35,9 @@ var (
// serviceDb will hold definitions of various bluetook services and will ultimately be updated via an HTTP repository
serviceDb *bitcask.Bitcask
err error
err error
Manufacturers ManufData
// DataDir - should be defined by config or cmd flag
DataDir string = "./.eros-data/"
)
@ -114,11 +114,10 @@ type Payload struct {
// placeholder
}
// Ingest UUID will add the UUID to the manufacturer if it doesn't already exist
func (manuf *Manufacturer) IngestUUID(uuid bluetooth.UUID) bool {
contains := func (s []bluetooth.UUID, v bluetooth.UUID) bool {
contains := func(s []bluetooth.UUID, v bluetooth.UUID) bool {
for _, a := range s {
if a == v {
return true

@ -141,8 +141,35 @@ func (s *Scan) resultHandler(scanAdapter *bluetooth.Adapter, result bluetooth.Sc
//adbytes := payload.Bytes()
uuids := payload.ServiceUUIDOut()
rssi := result.RSSI
//manuf := uuids[0]
// manufBool := payload.HasServiceUUID(manuf)
EnumedManuf := ""
//---attempts to set the manufacturer value----
//range through the uuids in the payload and compare
//known manufacturers list
for range uuids {
//for every element within the manufacturers list
// check each UUID
for _, man := range eros.Manufacturers.Entries /* known maufacturer data from eros */ {
// pull the UUID the current element of the manufacturer list
currManufErosOut := man.UUIDs /* current element from manufacturer data */
// for each manufacturer's UUID's comapre check the
// advertisment payload for a match
for _, manusss := range currManufErosOut {
manufBool := payload.HasServiceUUID(manusss)
//if there is a UUID match then assign the Manufacturer's name
// to the output variable EnumedManuf
if manufBool == true {
EnumedManuf = man.Name
}
}
}
}
//
var sublog zerolog.Logger
//ManufOut := ManfCheck(payload)
@ -160,7 +187,7 @@ func (s *Scan) resultHandler(scanAdapter *bluetooth.Adapter, result bluetooth.Sc
log.Info().
Str("Name", fromEros.Name).
Str("MAC", fromEros.MAC).
Str("ManuF", fromEros.Manufacturer).
Str("ManuF", EnumedManuf). //needs to be changed back to fromEros.Manufacturer
Int16("Current_RSSI", fromEros.RSSIlast).
Int("Service_Count", len(fromEros.Services)).
Msg("EROS_RECALL")
@ -173,7 +200,7 @@ func (s *Scan) resultHandler(scanAdapter *bluetooth.Adapter, result bluetooth.Sc
// only each device
sublog = log.With().Int("Scan_ID", s.ID).
Str("LocalName", lname).Str("MAC", addr).
//Str("ManuF", manuf).
Str("ManuF", EnumedManuf).
Int16("RSSI", rssi).Logger()
// Skipping duplicate results unless tracking mode enabled (to store RSSI as devices move)
@ -189,7 +216,7 @@ func (s *Scan) resultHandler(scanAdapter *bluetooth.Adapter, result bluetooth.Sc
s.Activity = time.Now()
//dev := s.NewDevice(lname, addr, ManufOut, rssi)
dev := s.NewDevice(lname, addr, "", rssi)
dev := s.NewDevice(lname, addr, EnumedManuf, rssi)
//AdvServBuf := make([]byte, 255)
// Record all the services advertised, append them into the nested struct within Device