Skip to content

Commit

Permalink
hci: use current MAC address when Advertiser, allowing support for ra…
Browse files Browse the repository at this point in the history
…ndom advertiser addresses

Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Jan 9, 2025
1 parent 70ef92c commit a211012
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions adapter_hci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion gap_hci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit a211012

Please sign in to comment.