Skip to content

Updates for time.c #995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cores/esp8266/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ long random(long, long);
void randomSeed(unsigned long);
long map(long, long, long, long, long);

extern "C" void configTime(int timezone, int daylightOffset_sec,
extern "C" void configTime(long timezone, int daylightOffset_sec,
const char* server1, const char* server2 = nullptr, const char* server3 = nullptr);

#endif
Expand Down
7 changes: 3 additions & 4 deletions cores/esp8266/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern struct tm* sntp_localtime(const time_t *clock);
#define DIFF1900TO1970 2208988800UL

static int s_daylightOffset_sec = 0;
static int s_timezone_sec = 0;
static long s_timezone_sec = 0;
static time_t s_bootTime = 0;

// calculate offset used in gettimeofday
Expand All @@ -46,7 +46,7 @@ static void ensureBootTimeIsSet()
time_t now = sntp_get_current_timestamp();
if (now)
{
s_bootTime = - millis() / 1000;
s_bootTime = now - millis() / 1000;
}
}
}
Expand All @@ -56,7 +56,7 @@ static void setServer(int id, const char* name_or_ip)
if (name_or_ip)
{
//TODO: check whether server is given by name or IP
sntp_setservername(0, (char*) name_or_ip);
sntp_setservername(id, (char*) name_or_ip);
}
}

Expand Down Expand Up @@ -92,7 +92,6 @@ time_t mktime(struct tm *t)
time_t time(time_t * t)
{
time_t seconds = sntp_get_current_timestamp();
ensureBootTimeIsSet();
if (t)
{
*t = seconds;
Expand Down