Ethernet Library v2.0 - how to get retrieve DhcpServerIP

Status
Not open for further replies.

dispmipi

New member
Hi
Your help is deeply appreciated.
I am using the PJRC Ethernet v2.0 library, trying to retrieve the DHCP server IP address after a successfully DHCP call.
I notice the DHCPServer code was in the library but seems not exposed to user API.

So , I did follow:

* file Ethernet.cpp

Ardound line# 186: add section below

IPAddress EthernetClass::dhcpServerIP()
{
IPAddress ret;
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
W5100.getDhcpServerIp(ret.raw_address());
SPI.endTransaction();
return ret;
}


* file Ethernet.h

Ardound line# 97: add line below
static IPAddress dhcpServerIP();


* to call the function in Arduino .ino file

Serial.println(Ethernet.dhcpServerIP() );

Result: Error said,
Ethernet.cpp:191:8: error: 'class W5100Class' has no member named 'getDhcpServerIp'


Thanks in advance for advice.
 
I am replying to my own post.
Issue resolved.
I ended up by modifing the Arduino official Ethernet2 library to get the job done.
Thank you,
 
Hallo, people
Please, can you help me: i thought all questions about leasing time and dhcp - my device was connected to mikrotik, and i've got all test with lease time as 1min 10min 1h 3h and 12h
BUT!

*** There is a problem
if device-client of dhcp is primary in router all things are fine

if device-client is under switch or router and dhcp server in another subnet then with lease time 12hours my client is going down and lost ip in 6 hours period if no activity on port :-(

So, i see in library dhcp.cpp and .h but i don't see what to do.
 
Status
Not open for further replies.
Back
Top