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