Skip to content

Commit 4c0bbea

Browse files
committed
properly initialized and checked Ethernet init callback
1 parent 0108ded commit 4c0bbea

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: libraries/Ethernet/src/Ethernet.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
int arduino::EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
66
if (eth_if == nullptr) {
77
//Q: What is the callback for?
8-
_initializerCallback();
8+
//A: To call a specific function on your system before any initialization is performed
9+
if(_initializerCallback != nullptr) {
10+
_initializerCallback();
11+
}
912
if (eth_if == nullptr) return 0;
1013
}
1114
eth_if->set_dhcp(true);

Diff for: libraries/Ethernet/src/Ethernet.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class EthernetClass : public MbedSocketClass {
121121
volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
122122
EthernetInterface net;
123123
EthernetInterface *eth_if = &net;
124-
voidPrtFuncPtr _initializerCallback;
124+
voidPrtFuncPtr _initializerCallback = nullptr;
125125
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
126126
};
127127

0 commit comments

Comments
 (0)