Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable setting MACAddr for cyw43439 #280

Merged
merged 1 commit into from
Aug 14, 2024
Merged

Conversation

taigrr
Copy link

@taigrr taigrr commented Jul 13, 2024

cyw43439 boards don't seem to consistently set a MAC address from a seeded value, and always use a hardcoded MACAddr of 43:43:A2:12:1F:AC

Therefore, in order to use two Picos near each other, it's necessary to provide a Set() call for changing the address.

This issue is highlighted by others as well below:
raspberrypi/pico-sdk#1323

I initially opened an issue here:
soypat/cyw43439#52

However, after implementing it I felt it made more sense to get the code into this repo with build tags.

This change has been tested and validated against my gopher2040-w badges from Gophercon 2024, which use a pico board.

This is my first PR into this repo, so feel free to hit me with style nits or have me change my function names/signatures or just tell me it should go into the other repo.

@taigrr
Copy link
Author

taigrr commented Jul 13, 2024

cc @soypat @deadprogram @conejoninja

@taigrr taigrr changed the base branch from release to dev July 13, 2024 16:56
Copy link

@soypat soypat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions and suggestions

hci_cyw43439.go Show resolved Hide resolved
hciPacket[i] = address.MACAddress.MAC[len(address.MACAddress.MAC)-1-i]
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this documented somewhere? If this is a known HCI command then this should not be behind a cyw43439 build tag.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only works for this board. The opcode is vendor-specific

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this may belong in cyw43439 repo- given the hci packet header is a constant value and need not full hci logic to build. If the logic in this package is needed then this function may belong in an example directory under cyw43439 that uses this repo. In any case I'd avoid adding this exported API until its clearer it belongs here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#229 sets the MAC address using a standard opcode - does that work on CYW43439?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that first! didn't seem to work for me. I have two boards and neither worked with that PR, which is why I looked into the spec to see what was recommended, which is how I arrived at this

ocfSetBTMACAddr = 0x0001
)

func (a *Adapter) SetBdAddr(address Address) error {
Copy link

@soypat soypat Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of the naming- I'd prefer SetAddress since the type it receives is an Address... or even SetBluetoothAddress

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I can rename it. The function to get the Bluetooth address was named GetBdAddr which is where the name comes from

@taigrr
Copy link
Author

taigrr commented Jul 18, 2024

Thanks @soypat I've responded to each. Let me know which should become changes

@deadprogram
Copy link
Member

Seems like all feedback has been addressed 🥲

Now merging, thanks @taigrr for the addition and all the reviewers for such great feedback!

@deadprogram deadprogram merged commit f39483a into tinygo-org:dev Aug 14, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants