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 // +build !baremetal
// Some documentation for the BlueZ D-Bus interface:
// https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc
package bluetooth package bluetooth
import ( import (

2
gap.go
View file

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

View file

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