11#include " Ethernet.h"
22
3- #define SSID_MAX_LENGTH 32
4-
53int arduino::EthernetClass::begin (uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
64 if (eth_if == nullptr ) {
7- // Q: What is the callback for?
8- _initializerCallback ();
9- if (eth_if == nullptr ) return 0 ;
5+ return 0 ;
106 }
117 eth_if->set_dhcp (true );
128 return _begin (mac, timeout, responseTimeout);
@@ -51,6 +47,10 @@ int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPA
5147}
5248
5349int arduino::EthernetClass::begin (uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
50+ if (eth_if == nullptr ) {
51+ return 0 ;
52+ }
53+
5454 config (ip, dns, gateway, subnet);
5555
5656 eth_if->set_dhcp (false );
@@ -68,6 +68,9 @@ void arduino::EthernetClass::end() {
6868}
6969
7070EthernetLinkStatus arduino::EthernetClass::linkStatus () {
71+ if (eth_if == nullptr ) {
72+ return LinkOFF;
73+ }
7174 return (eth_if->get_connection_status () == NSAPI_STATUS_GLOBAL_UP ? LinkON : LinkOFF);
7275}
7376
@@ -77,7 +80,9 @@ EthernetHardwareStatus arduino::EthernetClass::hardwareStatus() {
7780
7881
7982int arduino::EthernetClass::disconnect () {
80- eth_if->disconnect ();
83+ if (eth_if != nullptr ) {
84+ eth_if->disconnect ();
85+ }
8186 return 1 ;
8287}
8388
@@ -99,4 +104,4 @@ void arduino::EthernetClass::MACAddress(uint8_t *mac_address)
99104 macAddress (mac_address);
100105}
101106
102- arduino::EthernetClass Ethernet;
107+ arduino::EthernetClass Ethernet ( static_cast <EthernetInterface*>(EthInterface::get_default_instance())) ;
0 commit comments