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 7, 2025
1 parent 4044d2a commit 451b9e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions adapter_hci.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func (a *hciAdapter) enable() error {
}

func (a *hciAdapter) Address() (MACAddress, error) {
if a.hci.address.MAC != [6]uint8{} {
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 @@ -354,8 +354,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 451b9e3

Please sign in to comment.