Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 546529a

Browse files
authored
Merge pull request #901 from pennam/rm_initCallback
Ethernet, initCallback, ctor and eth_if
2 parents 14950ea + 50def68 commit 546529a

File tree

5 files changed

+16
-25
lines changed

5 files changed

+16
-25
lines changed

‎libraries/Ethernet/src/Ethernet.cpp‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
#include "Ethernet.h"
22

3-
#define SSID_MAX_LENGTH 32
4-
53
int 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

5349
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+
5454
config(ip, dns, gateway, subnet);
5555

5656
eth_if->set_dhcp(false);
@@ -68,6 +68,9 @@ void arduino::EthernetClass::end() {
6868
}
6969

7070
EthernetLinkStatus 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

7982
int 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()));

‎libraries/Ethernet/src/Ethernet.h‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,15 @@ enum { // compatibility with Arduino ::maintain()
5050
DHCP_CHECK_REBIND_OK = 4
5151
};
5252

53-
typedef void *(*voidPrtFuncPtr)(void);
54-
5553
class EthernetClass : public MbedSocketClass {
5654

5755
public:
58-
// Initialise the Ethernet shield to use the provided MAC address and
59-
// gain the rest of the configuration through DHCP.
60-
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
6156
EthernetClass(EthernetInterface *_if)
6257
: eth_if(_if){};
63-
EthernetClass(){};
64-
65-
EthernetClass(voidPrtFuncPtr _cb)
66-
: _initializerCallback(_cb){};
6758

59+
// Initialise the Ethernet shield to use the provided MAC address and
60+
// gain the rest of the configuration through DHCP.
61+
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
6862
int begin(uint8_t *mac = nullptr, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
6963
EthernetLinkStatus linkStatus();
7064
EthernetHardwareStatus hardwareStatus();
@@ -119,9 +113,7 @@ class EthernetClass : public MbedSocketClass {
119113
int _begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout);
120114

121115
volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
122-
EthernetInterface net;
123-
EthernetInterface *eth_if = &net;
124-
voidPrtFuncPtr _initializerCallback;
116+
EthernetInterface *eth_if = nullptr;
125117
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
126118
};
127119

‎libraries/GPS/src/GPS.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
namespace arduino {
2727

28-
typedef void* (*voidPrtFuncPtr)(void);
29-
3028
class GPSClass : public HardwareSerial {
3129
public:
3230

‎libraries/GSM/src/GSM.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565

6666
namespace arduino {
6767

68-
typedef void* (*voidPrtFuncPtr)(void);
69-
7068
class GSMClass : public MbedSocketClass {
7169
public:
7270

‎libraries/WiFi/src/WiFi.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ extern "C" {
4646

4747
namespace arduino {
4848

49-
typedef void* (*voidPrtFuncPtr)(void);
50-
5149
class WiFiClass : public MbedSocketClass {
5250
public:
5351
static int16_t _state[MAX_SOCK_NUM];

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /