Skip to content
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

Use ESP8266 SDK SNTP to fix "benchmark" loop #75

Closed
3rwww1 opened this issue Jun 7, 2018 · 0 comments
Closed

Use ESP8266 SDK SNTP to fix "benchmark" loop #75

3rwww1 opened this issue Jun 7, 2018 · 0 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request high priority
Milestone

Comments

@3rwww1
Copy link
Contributor

3rwww1 commented Jun 7, 2018

estimate: 2j

The goal is to use the SDK library instead of our own "home-brew" NTP implementation, which has several problems:

  • the NTP "benchmark" is useless and causes an infinite loop, where a coolboard that has had only one wifi with no no internet configured never can start an AP again without erasing the SPIFFS (@simon-lacool, told you this was a bad idea...)
  • using the SDK is so much better anyway: less code to maintain, probably more reliable, etc.

The approaches differ a lot:

  • COOL approach: connect to Wifi, make NTP requests until we get an answer, or timeout (and, currently, we do not handle it correctly and let Bad Things© happen, such as dates in 2066, etc)
  • SDK approach. Basically, it runs down to "connect to wifi and at some point, you'll automagically be sync'ed with NTP".

Those differences create numerous caveats:

  • the way of finding out if the NTP sync was done recently is much more complex
  • handling offline or nomad connections, offline logging, etc, is tedious and not well documented
  • the SDK aims at providing timezone, DST aware date and time, and it is really not our use case.
  • the documentation is lacking and mostly in github issues conversations

Way I see it, the algorithm should look like this:

  • initialize a class variable bool ntpSynced = false in CoolBoard.cpp or CoolTime.cpp
  • configure a callback as seen in SDK example. it will be called on NTP sync success.
  • connect to wifi
  • (lots of code happening)
  • before sending the first log, wait max NTP_SYNC_TIMEOUT seconds (I think 10s) for ntpSynced to become true
  • if ntpSync is true: send MQTT messages, as we are certain the timestamp is correct
  • if ntpSync is false: bail out, as we can't handle anything good at this point before an RTC enhancement and a good error reporting funnel

Must reads:

@3rwww1 3rwww1 added the enhancement New feature or request label Jun 7, 2018
@3rwww1 3rwww1 added this to the sprint 1 milestone Jun 7, 2018
@3rwww1 3rwww1 assigned Kameeno and unassigned Kameeno Jun 12, 2018
@3rwww1 3rwww1 added medium priority bug Something isn't working labels Jun 13, 2018
@3rwww1 3rwww1 changed the title Use native ESP8266 SDK NTP Use ESP8266 SDK SNTP to fix "benchmark" loop Jun 13, 2018
@trap98 trap98 self-assigned this Jun 18, 2018
@3rwww1 3rwww1 self-assigned this Jun 19, 2018
@3rwww1 3rwww1 closed this as completed Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request high priority
Projects
None yet
Development

No branches or pull requests

3 participants