Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Ethernet Library v2.0 - how to get retrieve DhcpServerIP

  1. #1
    Junior Member
    Join Date
    Aug 2018
    Posts
    2

    Ethernet Library v2.0 - how to get retrieve DhcpServerIP

    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.

  2. #2
    Junior Member
    Join Date
    Aug 2018
    Posts
    2
    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,

  3. #3
    Junior Member
    Join Date
    Jul 2019
    Posts
    1
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •