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

Add MACAddress to config.yaml #5506

Merged
merged 8 commits into from
Dec 7, 2024
Merged

Add MACAddress to config.yaml #5506

merged 8 commits into from
Dec 7, 2024

Conversation

jp-bennett
Copy link
Collaborator

Allows setting a virtual MAC Address in config.yaml

@GUVWAF
Copy link
Member

GUVWAF commented Dec 4, 2024

Humans are generally not good at generating random numbers, I'm afraid this would higher the chance of deadbeef node number collisions even more.

We could probably also try getting an Ethernet MAC if there's no Bluetooth, right?

@jp-bennett
Copy link
Collaborator Author

Humans are generally not good at generating random numbers, I'm afraid this would higher the chance of deadbeef node number collisions even more.

We could probably also try getting an Ethernet MAC if there's no Bluetooth, right?

Honestly I was just copying from my local Ethernet device. We could encourage that, or maybe even automate it.

@GUVWAF
Copy link
Member

GUVWAF commented Dec 4, 2024

Yeah, I think that would be nice.
Or, even when there's no Bluetooth/Ethernet, generate a random one and write it to the config file (in case you do a "factory reset").

@jp-bennett
Copy link
Collaborator Author

Yeah, I think that would be nice. Or, even when there's no Bluetooth/Ethernet, generate a random one and write it to the config file (in case you do a "factory reset").

OK, I'll see about adding another option, to specify the network device to pull the MAC from. Should we consider the blank mac address an error condition? I'm thinking maybe yes, to prevent the proliferation of bogus devices.

@GUVWAF
Copy link
Member

GUVWAF commented Dec 4, 2024

Sounds good, and yes, I think that should generate an (easily interpretable) error.

uint8_t dmac[6];
getMacAddr(dmac);
if (dmac[0] == 128 && dmac[1] == 0 && dmac[2] == 0 && dmac[3] == 0 && dmac[4] == 0 && dmac[5] == 1) {
std::cout << "*** Blank MAC Address not allowed! " << std::endl;
Copy link
Member

Choose a reason for hiding this comment

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

What about: "MAC address should be set in 'config.yaml'"? Then it's easier to figure out how to fix it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. Still a WIP. I'll finalize the error message once the new options are available.

@jp-bennett
Copy link
Collaborator Author

Actually, is there a good reason we have the getMacAddr() function in portduino at all? That's not a standard Arduino function. I'm very much inclined to just pull the whole thing into the portduinoGlue file. Makes it all way easier

@GUVWAF
Copy link
Member

GUVWAF commented Dec 4, 2024

I think it would indeed by fine to remove it, it's indeed not an Arduino function.

@jp-bennett jp-bennett merged commit 4a34bf6 into master Dec 7, 2024
48 checks passed
@jp-bennett jp-bennett deleted the macaddr-config branch December 7, 2024 16:29
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.

3 participants