From 5cf67d854edb1b73405be9a4c2675c6b23dd5b2b Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Sat, 13 Jul 2024 02:21:38 -0700 Subject: [PATCH] enable setting MACAddr for cyw43439 --- hci_cyw43439.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 hci_cyw43439.go diff --git a/hci_cyw43439.go b/hci_cyw43439.go new file mode 100644 index 0000000..3213f73 --- /dev/null +++ b/hci_cyw43439.go @@ -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<