Closed atesin closed 1 week ago
i answer myself (after rolling over whole internet and waking up a lot of people...):
◆ tm_year
int16_t tm::tm_year
years since 1900
so... the "124" means that PRESENTLY, HAD BEEN PASSED "124" years since 1900
what is OK...
i was printing a tm
struct fields directly.. it seem that the tm
structs are not intended to be used directly (or at least use with care) .... same with other numbers that start with "0" instead "1" (i.e. tm_mon 0 = january, etc)... so for printing better use ctime() or strftime() instead
... so, the only questions left i think are:
configTime()
writes configuration to flash?, and if does, what is the safer way to sync periodically without tearing flash?thanks
it seem that the tm structs are not intended to be used directly (or at least use with care)
See POSIX ctime reference, this is not something specific to either avr or esp8266 libc https://pubs.opengroup.org/onlinepubs/9799919799/
does configTime() writes configuration to flash?, and if does, what is the safer way to sync periodically without tearing flash?
No. Why would it? Where you got that idea from?
could anybody please split NTP-TZ-DST example into various smaller basic minimal ones to explain separate features?? (no intermediate functions, no macros, no spaghetti codes)
You are welcome to update the example(s)
could anybody please write a doxygen-like esp* sntp functions documentation thad nobody exactly knows?
See lwip documentation for the useful part. This is mentioned in the readme btw. SDK methods are not guaranteed to work correctly, please do not refer to NONOS examples or source using NONOS directly https://www.nongnu.org/lwip/2_1_x/sntp_8h.html
See POSIX ctime reference, this is not something specific to either avr or esp8266 libc https://pubs.opengroup.org/onlinepubs/9799919799/
what is that?... i see info on these pages:
No. Why would it? Where you got that idea from?
i think it prefectly could save config to flash with configTime(ts, srv1, srv2, srv3)
and then sync time with configTime()
just using stored config, like WiFi.begin()
does
See lwip documentation for the useful part. This is mentioned in the readme btw. SDK methods are not guaranteed to work correctly, please do not refer to NONOS examples or source using NONOS directly https://www.nongnu.org/lwip/2_1_x/sntp_8h.html
nice ... however it seem lwip sntp functions cannot be used directly in sketches (i tested and compiler complain me about sntp_init() not defined
) ... i would like to found some documentation about esp8266-arduino SNTP CORE functions (those used in NTP-TZ-DST without including any header, except <TZ.h>
maybe)
i am not a programmer but a sysadmin, i consider myself a self-learner guy, so sometimes things got harder to me... i am fairly new in programming and C and there are many things i dont know (i.e. using git, do debug, etc) and lot of things i dont even imagine i am sure xD
sub-frames are to blame... https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/time.h.html tm struct is both in c standard, and posix. my point here is this is not something platform-specific or unique to esp8266 implementation. cppreference page might've been a better link, as it mentions c standard.
i think it prefectly could save config to flash with configTime(ts, srv1, srv2, srv3) and then sync time with configTime() just using stored config, like WiFi.begin() does
not the case, and never mentioned in the example or the configTime() source)
its a helper function that does setenv("TZ", ...); tzset();
and then sets up sntp servers in a single call. TZ is a runtime value, independent of the sntp. SNTP servers are also runtime values, independent of TZ. It is up to the user to set up these strings, either hard-coded or retrieved from some kind of dynamic config store
i would like to found some documentation about esp8266-arduino SNTP CORE functions (those used in NTP-TZ-DST without including any header, except
maybe)
#include <sntp.h>
does that, right at the top. without the include compiler would now know how to call those functions, just the way c and c++ work. dry symbol documentation can be found at the lwip site, example gives a possible use-case in the code directly
i am not a programmer but a sysadmin, i consider myself a self-learner guy, so sometimes things got harder to me... i am fairly new in programming and C and there are many things i dont know (i.e. using git, do debug, etc) and lot of things i dont even imagine i am sure xD
We cannot presume how much user does or does not know about the programming environment, and pretty sure these examples were never intended to be used as isolated learning exercises. API usage example, yes. Semi-interactive documentation, probably.
Basic Infos
Platform
Hardware: nodemcu v3 lolin (with esp8266ex)
Core Version: 3.1.2
Development Env: arduino ide 2.3.3
Operating System: windows 10
Settings in IDE
Module: nodemcu 1.0
Flash Mode: i dont know
Flash Size: 4mb
lwip Variant: v2 low memory
Reset Method: dont know
Flash Frequency: dont know
CPU Frequency: 80mhz
Upload Using: serial
Upload Speed: 115200 baud 8n1 no flow control, send line mode,
<LF>
endlinesProblem Description
time()
function correctlyconfigTime(MYTZ, "pool.ntp.org");
saves configuration in flash? because if it does, which could be a safe way to get ntp time without wearing out the flash each time? (see what happened to this guy)time()
should return CURRENT UTC timestamp andlocaltime()
should translate to local time according timezone set earlierconfigTime()
by defining some macro constant or callback function to correct time when configTime() will set system timeMCVE Sketch
Debug Messages