Skip to content

Commit

Permalink
properly initialized and checked Ethernet init callback
Browse files Browse the repository at this point in the history
  • Loading branch information
maidnl committed Jun 17, 2024
1 parent 0108ded commit 4c0bbea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion libraries/Ethernet/src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
int arduino::EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
if (eth_if == nullptr) {
//Q: What is the callback for?
_initializerCallback();
//A: To call a specific function on your system before any initialization is performed
if(_initializerCallback != nullptr) {
_initializerCallback();
}
if (eth_if == nullptr) return 0;
}
eth_if->set_dhcp(true);
Expand Down
2 changes: 1 addition & 1 deletion libraries/Ethernet/src/Ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class EthernetClass : public MbedSocketClass {
volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
EthernetInterface net;
EthernetInterface *eth_if = &net;
voidPrtFuncPtr _initializerCallback;
voidPrtFuncPtr _initializerCallback = nullptr;
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
};

Expand Down

0 comments on commit 4c0bbea

Please sign in to comment.