NTP Client library
Posted: Fri Dec 18, 2015 8:12 am
I am trying to develop a NTP client library for ESP8266/Arduino to make adding NTP sync an easyer task.
Basically, I've thought about a contructor as
My problem is with that registering. I have a public function:
Then, inside
What could I do to allow registering this funtion as sync provider to hide ntp internals to my scketches?
Regards
Basically, I've thought about a contructor as
Code: Select all
and a NTPClient(String host, int interval)
Code: Select all
function to register sync function.NTPClient.begin()
My problem is with that registering. I have a public function:
Code: Select all
that connects to NTP server, decodes the response and returns a time_t variable.time_t ntpClient::getNtpTime()
Then, inside
Code: Select all
function I try to run boolean ntpClient::begin()
Code: Select all
I've also tried to use setSyncProvider(ntpClient::getNtpTime)
Code: Select all
I get a compile error here:setSyncProvider(this->getNtpTime)
Code: Select all
ntpClient.cpp:In member function 'boolean ntpClient::begin()
ntpClient.cpp:79:39: error: cannot convert 'ntpClient::getNtpTime' from type 'time_t (ntpClient::)() {aka long int (ntpClient::)()}' to type 'getExternalTime {aka long int (*)()}
setSyncProvider(ntpClient*:getNtpTime)
Error compiling project sources
What could I do to allow registering this funtion as sync provider to hide ntp internals to my scketches?
Regards