adafruit / adafruit/Adafruit_IO_Arduino
Fetch Mac address from Ethernet module instead of using hardcoded value.
- Dominant language
- C++
- Stars
- 222
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
### A user emailed Adafruit IO support suggesting an improvement to the IO library to fetch the Ethernet mac address before starting the module:
Hello! I'm Gavin, I made an adafruit.io related application, and adafruit's blog also reported on this application: https://blog.adafruit.com/2024/05/24/a-raspberry-pi-pico-board-with-dvi-video-and-ethernet/
I am using "Adafruit IO Arduino 4.3", the MAC address for Ethernet initialization is defined and initialized in: Adafruit_IO_Arduino/src
/AdafruitIO_Ethernet.h
But there are some unreasonable things about doing this:
If the user uses several devices: they need to change the MAC address of each device in the library, otherwise multiple devices will not work at the same time (because the devices have the same MAC address);
Can my suggestion be changed to this?
STEUP() in Sketch:
```cpp
Ethernet.begin(mac);
// connect to io.adafruit.com
adafruit_io.connect();
```
Change AdafruitIO_Ethernet.h to this, first read the MAC address from the WIZnet chip, and then re-initialize:
```cpp
void _connect() {
byte macAddress_[6];
Ethernet.MACAddress(macAddress_); //read mac address from Wiznet Chip
if (Ethernet.begin(macAddress_) == 0) {
_status = AIO_NET_DISCONNECTED;
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
AIO_DEBUG_PRINTLN("Ethernet FeatherWing not found! Please recheck "
"wiring connections.");
while(true)
delay(1); // do nothing, no point running without Ethernet hardware
}
} else {
// Ethernet.MACAddress(macAddress_);
// for (int i = 0; i < 6; i++) {
// Serial.print(macAddress_[i], HEX);
// if (i < 5) Serial.print(':');
// }
_status = AIO_NET_CONNECTED;
}
}
```
This eliminates the need to change the MAC address every time you enter the library file.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in Adafruit_IO_Arduino/src/AdafruitIO_Ethernet.h and inspect _connect() alongside the existing Ethernet initialization. Verify that the WIZnet MAC address is read before Ethernet initialization and that the connection status and no-hardware handling still work without a hardcoded MAC address.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot, networking
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100