Skip to content

Commit

Permalink
enable setting MACAddr for cyw43439
Browse files Browse the repository at this point in the history
  • Loading branch information
taigrr committed Jul 13, 2024
1 parent a668e1b commit 5cf67d8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions hci_cyw43439.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//go:build cyw43439

package bluetooth

const (
ogfVendor = 0x3f

ocfSetBTMACAddr = 0x0001
)

func (a *Adapter) SetBdAddr(address Address) error {
return a.hci.setBdAddr(address)
}

func (h *hci) setBdAddr(address Address) error {
hciPacket := make([]byte, len(address.MACAddress.MAC))
// Reverse the byte order as per spec
for i := range address.MACAddress.MAC {
hciPacket[i] = address.MACAddress.MAC[len(address.MACAddress.MAC)-1-i]
}

if err := h.sendWithoutResponse(ogfVendor<<ogfCommandPos|ocfSetBTMACAddr, hciPacket); err != nil {
return err
}

return nil
}

0 comments on commit 5cf67d8

Please sign in to comment.