get NTP server from DHCP

I’m trying to add to get the NTP server from DHCP to the Ethernet library of Arduino 1.8.13. For this I have changed the attached files for this.

But according to the message below I also have to add a class getNtpServerIP to the w5100.h file. Only I don't see what that class should look like.

Ethernet.cpp:194:8: error: 'class W5100Class' has no member named 'getNtpServerIP'

  • W5100.getNtpServerIP(ret.raw_address());*
  • ^*
    So hope that one of you can help me further. But maybe I'm also doing it all wrong this way. Then I would also like to hear it.

Dhcp.cpp (11.3 KB)

Dhcp.h (2.92 KB)

Ethernet.cpp (6.73 KB)

Ethernet.h (12.1 KB)

But according to the message below I also have to add a class getNtpServerIP to the w5100.h file. Only I don't see what that class should look like.

The message says that the class W5100Class doesn't have a method named "getNtpServerIP", which is correct. I guess the line 194 of Ethernet.cpp should read

	_dhcp.getNtpServerIP(ret.raw_address());

because there you implemented the method.

Does anyone know how to get ntp information from DHCP? Because I don't think I'm doing it right. Because when I perform the suggestion of pylon I get even more notifications ...

Dhcp.cpp:433:37: error: no 'IPAddress DhcpClass::getNtpServerIP()' member function declared in class 'DhcpClass'

  • IPAddress DhcpClass::getNtpServerIP()*
  • ^*
    Ethernet.cpp:27:26: error: 'IPAddress EthernetClass::_ntpServerAddress' is not a static data member of 'class EthernetClass'
  • IPAddress EthernetClass::_ntpServerAddress;*
  • ^*
    Ethernet.cpp: In static member function 'static int EthernetClass::begin(uint8_t*, long unsigned int, long unsigned int)':
    Ethernet.cpp:53:3: error: '_ntpServerAddress' was not declared in this scope
  • _ntpServerAddress = _dhcp->getNtpServerIP();*
  • ^*
    Ethernet.cpp:53:30: error: 'class DhcpClass' has no member named 'getNtpServerIP'
  • _ntpServerAddress = _dhcp->getNtpServerIP();*
  • ^*
    Ethernet.cpp: In static member function 'static int EthernetClass::maintain()':
    Ethernet.cpp:145:4: error: '_ntpServerAddress' was not declared in this scope
  • _ntpServerAddress = _dhcp->getNtpServerIP();*
  • ^*
    Ethernet.cpp:145:31: error: 'class DhcpClass' has no member named 'getNtpServerIP'
  • _ntpServerAddress = _dhcp->getNtpServerIP();*
  • ^*
    Ethernet.cpp: In static member function 'static IPAddress EthernetClass::ntpServerIP()':
    Ethernet.cpp:194:8: error: request for member 'getNtpServerIP' in 'EthernetClass::_dhcp', which is of pointer type 'DhcpClass*' (maybe you meant to use '->' ?)
  • _dhcp.getNtpServerIP(ret.raw_address());*
  • ^*

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.