muka/go-bluetooth

How to set it up so that it can be connected directly without pairing?

cyub opened this issue · 1 comments

cyub commented

I want to use the go-bluetooth package to configure wifi (WiFi setup over BLE). When operating our app, a pairing pop-up window always pops up. How to connect the ble device directly without popping up the pairing pop-up window. Our ble device driver uses bluez5.63. Can anyone give some advice?

cyub commented

I found that when using btmgmt to set pairable to false after Advertise, the central device, such as a mobile phone, etc., can no longer pop up the pairing window. This will solve the problem. The code example is as follows:

options := service.AppOptions{
	AdapterID:  adapterID,
	AgentCaps:  agent.CapNoInputNoOutput,
	UUIDSuffix: "-0000-1000-8000-00805F9B34FB",
	UUID:       "1234",
}

a, err := service.NewApp(options)
if err != nil {
	return err
}
defer a.Close()

...

ancel, err := a.Advertise(timeout)
if err != nil {
	return err
}

btmgmt := hw.NewBtMgmt(adapterID)
btmgmt.SetPairable(false)