diff --git a/adapter_hci.go b/adapter_hci.go index 6d7f044..f36bc09 100644 --- a/adapter_hci.go +++ b/adapter_hci.go @@ -50,6 +50,11 @@ func (a *hciAdapter) enable() error { } func (a *hciAdapter) Address() (MACAddress, error) { + var empty MAC + if a.hci.address.MAC != empty { + return a.hci.address, nil + } + if err := a.hci.readBdAddr(); err != nil { return MACAddress{}, err } diff --git a/gap_hci.go b/gap_hci.go index 0a9cd89..fa47519 100644 --- a/gap_hci.go +++ b/gap_hci.go @@ -358,8 +358,13 @@ func (a *Advertisement) Start() error { // uint8_t type = (_connectable) ? 0x00 : (_localName ? 0x02 : 0x03); typ := uint8(a.advertisementType) + localRandom := uint8(0) + if a.adapter.hci.address.isRandom { + localRandom = 1 + } + if err := a.adapter.hci.leSetAdvertisingParameters(a.interval, a.interval, - typ, 0x00, 0x00, [6]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x07, 0); err != nil { + typ, localRandom, 0x00, [6]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x07, 0); err != nil { return err }