fixing dumb scans
This commit is contained in:
parent
4f8dc7737b
commit
92ae207001
4
main.go
4
main.go
@ -33,10 +33,10 @@ func main() {
|
||||
//var foundDevice bluetooth.ScanResult
|
||||
|
||||
//turn the stuff on
|
||||
dust.Must("BLE stack", projVars.Adapter.Enable())
|
||||
dust.Must("BLE stack", projVars.ScanAdapter.Enable())
|
||||
|
||||
println("Scanning")
|
||||
err := projVars.Adapter.Scan(func(adapter *bluetooth.Adapter, result bluetooth.ScanResult) {
|
||||
err := projVars.ScanAdapter.Scan(func(adapter *bluetooth.Adapter, result bluetooth.ScanResult) {
|
||||
|
||||
if result.Address.String() == *projVars.Target {
|
||||
|
||||
|
@ -12,29 +12,35 @@ import (
|
||||
func Scanners() {
|
||||
|
||||
//create list of devices in the AO
|
||||
println("Creating Device Map")
|
||||
dust.FirstList()
|
||||
|
||||
println("Enabling Adapter")
|
||||
// Enable BLE interface.
|
||||
dust.Must("enable BLE stack", projVars.ScanAdapter.Enable())
|
||||
|
||||
//TODO: only scan a device once, skip if its in the map
|
||||
// Start scanning.
|
||||
println("scanning...")
|
||||
|
||||
err := projVars.ScanAdapter.Scan(func(scanAdapter *bluetooth.Adapter, device bluetooth.ScanResult) {
|
||||
if projVars.ScanList[device.LocalName()] != "" {
|
||||
|
||||
if projVars.ScanList[device.Address.String()] == "" {
|
||||
//could create a more
|
||||
//color.Yellow("Device Already in Mapped")
|
||||
} else {
|
||||
|
||||
color.Cyan("found device:")
|
||||
println(device.Address.String(), device.RSSI, device.LocalName())
|
||||
if device.LocalName() != projVars.ScanList[device.Address.String()] {
|
||||
color.Cyan("found device:")
|
||||
println(device.Address.String(), device.RSSI, device.LocalName())
|
||||
|
||||
//TODO: create localname for devices that dont broadcast one
|
||||
projVars.ScanList[device.LocalName()] = device.Address.String()
|
||||
//TODO: create localname for devices that dont broadcast one
|
||||
projVars.ScanList[device.Address.String()] = device.LocalName()
|
||||
|
||||
//fucking sanity check
|
||||
i := projVars.ScanList[device.LocalName()]
|
||||
color.Red(i)
|
||||
//fucking sanity check
|
||||
i := projVars.ScanList[device.Address.String()]
|
||||
color.Red(i)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
var ScanList map[string]string
|
||||
|
||||
//the BLE adapter --duh
|
||||
var Adapter = bluetooth.DefaultAdapter
|
||||
//var Adapter = bluetooth.DefaultAdapter
|
||||
var ScanAdapter = bluetooth.DefaultAdapter
|
||||
|
||||
//Device to be targeted --not fully implemented
|
||||
|
Loading…
Reference in New Issue
Block a user