-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
New Class MacAddress similar to IPAddress #6667
Conversation
@mrengineer7777 - Let me know when it is ready. |
@SuGlider Tested working. Test project here: https://github.com/mrengineer7777/MA_Test. |
Looks like I'll need to update CMakeLists.txt if we are happy with the file locations. |
Yes, it's just a matter of adding it. CMake/CI needs all files in place. Thanks! |
@SuGlider Updated. Success. |
@mrengineer7777 Thanks! I have an initial suggestion:
|
@mrengineer7777 - Talking to @me-no-dev, he made some nice suggestions also: 1- MacAddress6 should be named just MacAddress, as it is the default size for our SoCs and mostly known. MacAddress8 seems to make a lot of sense with IPv6. I also would suggest some adding to the code - in the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good! Just a few methods to make it closer to IPAddress class :-)
Same changing suggestions from Mac6 to Mac8.
@SuGlider I have also updated the test project |
Just learned how to squash commits using GitHub Desktop :) |
Adding New Classes MacAddress, MacAddress8 in the style of IPAddress. Note I didn't include Printable, as I don't understand how that works. If someone else wants to add it later, they are welcome to do so. This is my first time contributing to this repository, so please feel free to point out any mistakes. This library originated on arduino-esp32 (espressif/arduino-esp32#6667). It was suggested that I contribute to the Arduino core as well :)
Thanks David for adding this class! |
@SuGlider Thanks for adding Printable. As the library author I prefer to keep the implementation details in the .cpp file. I realize you are copying the format of IPAddress. I also have some questions. I'm a C guy learning c++, so forgive my ignorance. Should this be
What do these do? Are they needed for PrintTo()? It looks like they return a pointer to the class's private variables, which I consider extremely dangerous.
|
But, just the
Those are for const type pointer casting... Read Only. const uint8_t *ip_8 = MacAddress(0x00, 0xCD, 0x01, 0xFE, 0xB2, 0xF0);
const uint32_t *ip_64 = MacAddress(ip_8);
|
Ah, that's helpful.
Since it's read only and improves functionality I'll allow it. Now that I understand the functionality, I'll update my test project to verify the new operators. I'll post a link when I update, likely tomorrow. @SuGlider I would like to move the implementation details to the .cpp file. Any objections? |
Please fell free to change anything. |
@SuGlider I need help testing the printTo() function. I don't understand how to use it. I'll post the updates I've done so far while I wait for your reply. |
Updated test project. Does not test printTo() yet. https://github.com/mrengineer7777/MA_Test |
Printable is an Interface to a Print object: The common Classes that inherit from Print Class in ESP Arduino are:
Serial.begin(115200);
MacAddress addr(0x00, 0xCD, 0x01, 0xFE, 0xB2, 0xF0);
// it will print the mac address to Serial
addr.printTo(Serial);
Serial.println(); // the line above doesn't send \n
// it will print the mac address to a String
StreamString sstr;
addr.printTo(sstr);
Serial.println(sstr);
|
Passes test project. Ready for review. |
Chars must be uppercase to match toString() and pass test
daa71cb
to
d05cd87
Compare
@mrengineer7777 now it's time to finally review properly and merge your PR.
|
|
@me-no-dev I agree on combining MacAddress into one file. Will take some time for me to refactor this. |
Sure thing @mrengineer7777 :) Better be done once correctly, than having to change it later or even worst, having to live with it for the rest of your life 😆 |
any progress on this @mrengineer7777? Thanks a lot in advance for your contribution. |
@mrengineer7777 - it sounds like the branch of this PR doesn't allow us to change the code / rebase it. |
We may consider it for 3.0.0 instead of 3.0.0-RC1. |
Closing this PR in favour of #9304. Thanks @mrengineer7777 |
Description of Change
This adds new classes MacAddress and MacAddress8. MacAddress allows for better handling of MAC and BSSID addresses. MacAddress8 is for 8-byte EUI-64 as noted in esp_mac.h.
Test scenarios
Tested on Arduino Feather ESP32.
RC1
No new changes. Bugfixes accepted.
TESTING
See test project here: https://github.com/mrengineer7777/MA_Test.
Related links
Closes #6658.