Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Dhcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Ethernet.h"
#include "Dhcp.h"
#include "utility/w5100.h"
extern void ethernetIdle(void);

int DhcpClass::beginWithDHCP(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout)
{
Expand Down Expand Up @@ -244,7 +245,8 @@ uint8_t DhcpClass::parseDHCPResponse(unsigned long responseTimeout, uint32_t& tr
if ((millis() - startTime) > responseTimeout) {
return 255;
}
delay(50);
ethernetIdle();
delay(1);
}
// start reading in the packet
RIP_MSG_FIXED fixedMsg;
Expand Down
6 changes: 4 additions & 2 deletions src/Dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "Ethernet.h"
#include "Dns.h"
#include "utility/w5100.h"

extern void ethernetIdle(void);

#define SOCKET_NONE 255
// Various flags and header field values for a DNS message
Expand Down Expand Up @@ -120,6 +120,8 @@ int DNSClient::getHostByName(const char* aHostname, IPAddress& aResult, uint16_t
while ((wait_retries < 3) && (ret == TIMED_OUT)) {
ret = ProcessResponse(timeout, aResult);
wait_retries++;
ethernetIdle();
delay(1);
}
}
}
Expand Down Expand Up @@ -220,7 +222,7 @@ uint16_t DNSClient::ProcessResponse(uint16_t aTimeout, IPAddress& aAddress)
if ((millis() - startTime) > aTimeout) {
return TIMED_OUT;
}
delay(50);
ethernetIdle();
}

// We've had a reply!
Expand Down
3 changes: 3 additions & 0 deletions src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,6 @@ void EthernetClass::setRetransmissionCount(uint8_t num)


EthernetClass Ethernet;

void ethernetIdle(void) __attribute__ ((weak));
void ethernetIdle(void) {delay(10);};
3 changes: 3 additions & 0 deletions src/EthernetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Ethernet.h"
#include "Dns.h"
#include "utility/w5100.h"
extern void ethernetIdle(void);

int EthernetClient::connect(const char * host, uint16_t port)
{
Expand Down Expand Up @@ -62,6 +63,7 @@ int EthernetClient::connect(IPAddress ip, uint16_t port)
if (stat == SnSR::CLOSE_WAIT) return 1;
if (stat == SnSR::CLOSED) return 0;
if (millis() - start > _timeout) break;
ethernetIdle();
delay(1);
}
Ethernet.socketClose(_sockindex);
Expand Down Expand Up @@ -143,6 +145,7 @@ void EthernetClient::stop()
_sockindex = MAX_SOCK_NUM;
return; // exit the loop
}
ethernetIdle();
delay(1);
} while (millis() - start < _timeout);

Expand Down