diff --git a/libraries/Ethernet/src/Ethernet.cpp b/libraries/Ethernet/src/Ethernet.cpp index 2e0f1a94f..0f6450a7a 100644 --- a/libraries/Ethernet/src/Ethernet.cpp +++ b/libraries/Ethernet/src/Ethernet.cpp @@ -1,12 +1,8 @@ #include "Ethernet.h" -#define SSID_MAX_LENGTH 32 - int arduino::EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) { if (eth_if == nullptr) { - //Q: What is the callback for? - _initializerCallback(); - if (eth_if == nullptr) return 0; + return 0; } eth_if->set_dhcp(true); return _begin(mac, timeout, responseTimeout); @@ -51,6 +47,10 @@ int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPA } int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) { + if(eth_if == nullptr) { + return 0; + } + config(ip, dns, gateway, subnet); eth_if->set_dhcp(false); @@ -68,6 +68,9 @@ void arduino::EthernetClass::end() { } EthernetLinkStatus arduino::EthernetClass::linkStatus() { + if(eth_if == nullptr) { + return LinkOFF; + } return (eth_if->get_connection_status() == NSAPI_STATUS_GLOBAL_UP ? LinkON : LinkOFF); } @@ -77,7 +80,9 @@ EthernetHardwareStatus arduino::EthernetClass::hardwareStatus() { int arduino::EthernetClass::disconnect() { - eth_if->disconnect(); + if(eth_if != nullptr) { + eth_if->disconnect(); + } return 1; } @@ -99,4 +104,4 @@ void arduino::EthernetClass::MACAddress(uint8_t *mac_address) macAddress(mac_address); } -arduino::EthernetClass Ethernet; +arduino::EthernetClass Ethernet(static_cast(EthInterface::get_default_instance())); diff --git a/libraries/Ethernet/src/Ethernet.h b/libraries/Ethernet/src/Ethernet.h index 2fc2ef240..8783d651c 100644 --- a/libraries/Ethernet/src/Ethernet.h +++ b/libraries/Ethernet/src/Ethernet.h @@ -50,21 +50,15 @@ enum { // compatibility with Arduino ::maintain() DHCP_CHECK_REBIND_OK = 4 }; -typedef void *(*voidPrtFuncPtr)(void); - class EthernetClass : public MbedSocketClass { public: - // Initialise the Ethernet shield to use the provided MAC address and - // gain the rest of the configuration through DHCP. - // Returns 0 if the DHCP configuration failed, and 1 if it succeeded EthernetClass(EthernetInterface *_if) : eth_if(_if){}; - EthernetClass(){}; - - EthernetClass(voidPrtFuncPtr _cb) - : _initializerCallback(_cb){}; + // Initialise the Ethernet shield to use the provided MAC address and + // gain the rest of the configuration through DHCP. + // Returns 0 if the DHCP configuration failed, and 1 if it succeeded int begin(uint8_t *mac = nullptr, unsigned long timeout = 60000, unsigned long responseTimeout = 4000); EthernetLinkStatus linkStatus(); EthernetHardwareStatus hardwareStatus(); @@ -119,9 +113,7 @@ class EthernetClass : public MbedSocketClass { int _begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout); volatile EthernetLinkStatus _currentNetworkStatus = Unknown; - EthernetInterface net; - EthernetInterface *eth_if = &net; - voidPrtFuncPtr _initializerCallback; + EthernetInterface *eth_if = nullptr; arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress); }; diff --git a/libraries/GPS/src/GPS.h b/libraries/GPS/src/GPS.h index 998430ecc..e02d5e9db 100644 --- a/libraries/GPS/src/GPS.h +++ b/libraries/GPS/src/GPS.h @@ -25,8 +25,6 @@ namespace arduino { -typedef void* (*voidPrtFuncPtr)(void); - class GPSClass : public HardwareSerial { public: diff --git a/libraries/GSM/src/GSM.h b/libraries/GSM/src/GSM.h index a41e7692d..cf3652c26 100644 --- a/libraries/GSM/src/GSM.h +++ b/libraries/GSM/src/GSM.h @@ -65,8 +65,6 @@ namespace arduino { -typedef void* (*voidPrtFuncPtr)(void); - class GSMClass : public MbedSocketClass { public: diff --git a/libraries/WiFi/src/WiFi.h b/libraries/WiFi/src/WiFi.h index 1dd01df61..ad650fb14 100644 --- a/libraries/WiFi/src/WiFi.h +++ b/libraries/WiFi/src/WiFi.h @@ -46,8 +46,6 @@ extern "C" { namespace arduino { -typedef void* (*voidPrtFuncPtr)(void); - class WiFiClass : public MbedSocketClass { public: static int16_t _state[MAX_SOCK_NUM]; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy