diff --git a/library.json b/library.json index ad4054e..df0358b 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "EtherCard", - "version": "1.1.0", + "version": "1.1.1", "keywords": "http, web, server, client, ethernet", "description": "EtherCard is an IPv4 driver for the ENC28J60 chip.", "homepage": "https://github.com/njh/EtherCard", diff --git a/library.properties b/library.properties index e7f9ed9..2227bbe 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=EtherCard -version=1.1.0 +version=1.1.1 author=Jean-Claude Wippler maintainer=Nicholas Humfrey sentence=EtherCard is an IPv4 driver for the ENC28J60 chip. diff --git a/src/EtherCard.h b/src/EtherCard.h index ff17ea5..f8ea407 100644 --- a/src/EtherCard.h +++ b/src/EtherCard.h @@ -368,10 +368,10 @@ class EtherCard : public Ethernet { /** @brief Configure network interface with DHCP * @param hname The hostname to pass to the DHCP server * @param fromRam Set true to indicate whether hname is in RAM or in program space. Default = false + * @param timeout Time to wait before failing (default is 60 seconds) * @return bool True if DHCP successful - * @note Blocks until DHCP complete or timeout after 60 seconds */ - static bool dhcpSetup (const char *hname = NULL, bool fromRam =false); + static bool dhcpSetup (const char *hname = NULL, bool fromRam = false, uint16_t timeout = 60000); /** @brief Register a callback for a specific DHCP option number * @param option The option number to request from the DHCP server diff --git a/src/dhcp.cpp b/src/dhcp.cpp index 960c366..0bcca9d 100644 --- a/src/dhcp.cpp +++ b/src/dhcp.cpp @@ -332,7 +332,7 @@ static char toAsciiHex(byte b) { return c; } -bool EtherCard::dhcpSetup (const char *hname, bool fromRam) { +bool EtherCard::dhcpSetup (const char *hname, bool fromRam, uint16_t timeout) { // Use during setup, as this discards all incoming requests until it returns. // That shouldn't be a problem, because we don't have an IPaddress yet. // Will try 60 secs to obtain DHCP-lease. @@ -356,7 +356,7 @@ bool EtherCard::dhcpSetup (const char *hname, bool fromRam) { dhcpState = DHCP_STATE_INIT; uint16_t start = millis(); - while (dhcpState != DHCP_STATE_BOUND && uint16_t(millis()) - start < 60000) { + while (dhcpState != DHCP_STATE_BOUND && uint16_t(millis()) - start < timeout) { if (isLinkUp()) DhcpStateMachine(packetReceive()); } updateBroadcastAddress();