Skip to content

lwip2 fixes and time/ntp management #3835

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 1 commit into from
Nov 21, 2017
Merged

lwip2 fixes and time/ntp management #3835

merged 1 commit into from
Nov 21, 2017

Conversation

d-a-v
Copy link
Collaborator

@d-a-v d-a-v commented Nov 15, 2017

#1679: sntp is automatically started
#2505: honor DST in configTime()
fix clock_gettime() with micros64()
add settimeofday()
new example esp8266/NTP-TZ-DST.ino
--- lwip2 (mandatory for the above):
the above fixes
remove old and unwanted definitions of millis() and gettimeofday()
fix crashing with WiFi.softAPConfig(ip,ip,ip)

s_timezone_sec = timezone;
s_daylightOffset_sec = daylightOffset_sec;
//s_timezone_sec = timezone;
//s_daylightOffset_sec = daylightOffset_sec;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the variables have been removed, can these lines be removed as well?

Copy link
Member

@igrr igrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am i correct to assume that localtime_r and gmtime_r will still return the same result? I.e. libc doesn't know about the timezone offset?

@@ -0,0 +1,96 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a header here explaining what the example does, and the if/endif choices below. Also should include a public domain or cc0 license (like the original Arduino examples).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file also needs to be formatted same way as other sketches. Simple way to do this is to load it into arduino, then use Tools > Format sketch.

@d-a-v
Copy link
Collaborator Author

d-a-v commented Nov 15, 2017

Correct: localtime() and gmtime() return both local time with isdst=0 (hence both wrong).

So there are currently three bugs:

  • localtime() should set isdst to 1
  • gmtime() should show UTC
  • 
    

The example is updated with header, explanation, format and localtime/gmtime tests.

@devyte
Copy link
Collaborator

devyte commented Nov 17, 2017

@d-a-v I updated the branch and restarted travis, but it still fails. The reason seems to be a linker error about undefined reference settimeofday.

@d-a-v
Copy link
Collaborator Author

d-a-v commented Nov 17, 2017

It's because travis links against lwip1.4 where settimeofday() is not defined.
Should we add a wrapper in lwip1.4 for the sake of coherency ?

@d-a-v
Copy link
Collaborator Author

d-a-v commented Nov 17, 2017

I'm afraid we can't update the internal timestamp without modifying lwip1.4 (every useful stuff is static in src/core/sntp.c, timestamp can only be setup by ntp).

We can end up with:

  • no settimeofday() (travis should be teached about lwip2)
  • settimeofday() doing nothing
  • settimeofday() yelling

@everslick
Copy link
Contributor

I have an `undefined reference to `ping_start'` when linking against LWIP2

@d-a-v
Copy link
Collaborator Author

d-a-v commented Nov 20, 2017

Right. ping is in esp-lwip-v1.4's apps but not in current lwip's apps.
It is however in lwip's contrib.
It's two files to compile.
@igrr @devyte should it be in lwip2 ?

core: +settimeofday()
core: +coredecls.h +sntp-lwip2.c
core: fix clock_gettime() with micros64()
core: honor DST in configTime()
core: internal clock is automatically started
examples: +esp8266/NTP-TZ-DST.ino
lwip2: sntp client removed
lwip2: fix crashing with WiFi.softAPConfig(ip,ip,ip)
fix esp8266#3852
@d-a-v
Copy link
Collaborator Author

d-a-v commented Nov 20, 2017

@igrr PR 3835 is squashed into a single commit

@everslick
Copy link
Contributor

Interestingly ping_option and ping_resp are declared correctly.

@devyte
Copy link
Collaborator

devyte commented Nov 20, 2017

@d-a-v my only feedback about the ping files: try to keep the lwip directory as clean as possible, so that we have fewer headaches in the future if we ever need to do another migration. In other words, all files not distributed with lwip should probably be put elsewhere.

@d-a-v
Copy link
Collaborator Author

d-a-v commented Nov 20, 2017

@devyte ping may have been distributed in lwip-v1, now it is in their lwip-contrib.
Still, the fonctions are declared in espressif's SDK (tools/sdk/include/ping.h).
@everslick please make a new issue for this so further discussion happen there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants