1
1
#include " Ethernet.h"
2
2
3
- #define SSID_MAX_LENGTH 32
4
-
5
3
int arduino::EthernetClass::begin (uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
6
4
if (eth_if == nullptr ) {
7
- // Q: What is the callback for?
8
- _initializerCallback ();
9
- if (eth_if == nullptr ) return 0 ;
5
+ return 0 ;
10
6
}
11
7
eth_if->set_dhcp (true );
12
8
return _begin (mac, timeout, responseTimeout);
@@ -51,6 +47,10 @@ int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPA
51
47
}
52
48
53
49
int 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
+
54
54
config (ip, dns, gateway, subnet);
55
55
56
56
eth_if->set_dhcp (false );
@@ -68,6 +68,9 @@ void arduino::EthernetClass::end() {
68
68
}
69
69
70
70
EthernetLinkStatus arduino::EthernetClass::linkStatus () {
71
+ if (eth_if == nullptr ) {
72
+ return LinkOFF;
73
+ }
71
74
return (eth_if->get_connection_status () == NSAPI_STATUS_GLOBAL_UP ? LinkON : LinkOFF);
72
75
}
73
76
@@ -77,7 +80,9 @@ EthernetHardwareStatus arduino::EthernetClass::hardwareStatus() {
77
80
78
81
79
82
int arduino::EthernetClass::disconnect () {
80
- eth_if->disconnect ();
83
+ if (eth_if != nullptr ) {
84
+ eth_if->disconnect ();
85
+ }
81
86
return 1 ;
82
87
}
83
88
@@ -99,4 +104,4 @@ void arduino::EthernetClass::MACAddress(uint8_t *mac_address)
99
104
macAddress (mac_address);
100
105
}
101
106
102
- arduino::EthernetClass Ethernet;
107
+ arduino::EthernetClass Ethernet ( static_cast <EthernetInterface*>(EthInterface::get_default_instance())) ;
0 commit comments