The time() function works as expected if sntp successfully sets the time over the network, otherwise the time does not advance with subsequent calls. I’m using 6.0f. Further I cannont figure out how to set the time with a C function, anybody know how to do that? Perhaps seeding the time by trying to set it will help the situation but I do need the ability to sync to a non sntp source as well. I’ll try the callback method to a custom sntp startup routine. Are there any catches to using it?
By time() function, are you referring to NAgetSntpTime()? Of course it would return a 0 if the SNTP thread has not made a connection with a time server. If you attach a callback function to the NAinstallSntpTime() function call, you will get a callback after the connection has been established. Then you call NAgetSntpTime() to get the current time. If you need a time before that occurs, other than using the real time clock, then use time ticks. Unfortunately, that won’t give you the current time of day.
By the way…how do you convert the number you get from the NAgetSntpTime() function to get a better representation of the time?
Okay, I take my comment back. after enabling the SNTP client, each function call to time() returns a zero. So, I see the same problem that you are seeing.
You must implement a callback function, taking care of the following status values: NASNTP_SUCCESS, NASNTP_SERVER_TIMEOUT, & NASNTP_INVALID_STATE. If the status you receive is NASNTP_SUCCESS, you can then read the time either using NAgetSntpTime() or NAgetSntpAsciiTime(). Be sure to return NASNTP_SUCCESS in order to keep the SNTP client running. Then, on a regular basis, you can either call the time() function, or use one of the SNTP functions. ctime() and NAgetSntpAsciiTime() format the text differently…