linux: include IsRandom bit in Address type

Unlike what I previously thought, BlueZ does expose it. Unfortunately it
doesn't seem to respect it: the bit is not included in D-Bus paths.

Windows also supports the bit, which I hope to fix in a future commit.
Like BlueZ, it appears to ignore it when connecting to a device.
This commit is contained in:
Ayke van Laethem 2020-06-11 15:51:24 +02:00
parent 6c7d25c022
commit 8129f7e092
No known key found for this signature in database
GPG Key ID: E97FF5335DFDFDED
3 changed files with 8 additions and 4 deletions

View File

@ -1,5 +1,8 @@
// +build !baremetal
// Some documentation for the BlueZ D-Bus interface:
// https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc
package bluetooth
import (

2
gap.go
View File

@ -54,8 +54,6 @@ type Address struct {
// random. Sometimes, it contains a hash.
// For more information:
// https://www.novelbits.io/bluetooth-address-privacy-ble/
//
// This field is unused under Windows and Linux.
IsRandom bool
}

View File

@ -163,8 +163,11 @@ func makeScanResult(dev *device.Device1) ScanResult {
}
return ScanResult{
RSSI: dev.Properties.RSSI,
Address: Address{addr, false}, // the 'IsRandom' bit is not supported
RSSI: dev.Properties.RSSI,
Address: Address{
MAC: addr,
IsRandom: dev.Properties.AddressType == "random",
},
AdvertisementPayload: &advertisementFields{
AdvertisementFields{
LocalName: dev.Properties.Name,