Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow selecting a ble adapter with a macAddress #348

Closed
wants to merge 2 commits into from

Conversation

hu13
Copy link

@hu13 hu13 commented Feb 23, 2025

This proposes a solution to fix #284.

Testing:

I use the following main.go to run the test with this code change.

package main

import (
	"tinygo.org/x/bluetooth"
)

var adapter = bluetooth.NewAdapter("F4:D4:88:7E:15:0F")

func main() {
	// Enable BLE interface.
	must("enable BLE stack", adapter.Enable())

	// Start scanning.
	println("scanning...")
	err := adapter.Scan(func(adapter *bluetooth.Adapter, device bluetooth.ScanResult) {
		println("found device:", device.Address.String(), device.RSSI, device.LocalName())
	})
	must("start scan", err)
}

func must(action string, err error) {
	if err != nil {
		panic("failed to " + action + ": " + err.Error())
	}
}

a ble macAddress can be found by running this terminal cmd: system_profiler SPBluetoothDataType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to select a secondary adapter?
1 participant