Comments (19)
No, we use neither. The time is taken from the heater or set manually. The library just keeps track of the time and apparently doesn't always return reliable values. That's why @CZvacko needs to try my workaround.
from bsb-lan.
Oh, that's strange... @dukess, would it make sense to check if GetDateTime
returns zero and then repeat that function call? Because even if the clock is not set properly to current date, it shouldn't return 0, I guess?
from bsb-lan.
from bsb-lan.
With buggy version you mean older version of BSB-LAN?
from bsb-lan.
from bsb-lan.
Yep. With issue 527 #527 fredlcore @.> 3 декабря 2022 г. 12:34:55 написал:
…
With buggy version you mean older version of BSB-LAN? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.>
In my local version I edited esp32_time.h and removed the "- 1" on line 9 with "t.tm_mday = day". Even before issue 527 was fixed officially.
from bsb-lan.
Could you nevertheless download the most recent version from the master repository and try it again? There may be other issues that we fixed since then that may have an impact on it, so just to be sure...
from bsb-lan.
Could you nevertheless download the most recent version from the master repository and try it again? There may be other issues that we fixed since then that may have an impact on it, so just to be sure...
Today morning I downloaded the most recent version, flashed, then issue D0 command. Now after 12 hours (273 data readings), I have 2 rows with bad date (and graph corrupted).
from bsb-lan.
Ok, thanks for testing!
Could you change the line
getLocalTime(&now,0);
in BSB_LAN.ino
into
do {
getLocalTime(&now,0);
} while (now.tm_year < 2);
and test if the problem remains?
@dukess: I have no clue why this function is coded as it is:
bool getLocalTime(struct tm * info, uint32_t ms)
{
uint32_t start = millis();
time_t now;
while((millis()-start) <= ms) {
time(&now);
localtime_r(&now, info);
if(info->tm_year > (2016 - 1900)){
return true;
}
delay(10);
}
return false;
}
Why is there a while loop that repeatedly tries to calculate the current date/time?
For some reason it seems likely that the date calculation goes wrong, at least that would explain the check for tm_year being larger than (2016-1900=)116.
However, if it is likely to fail due to certain circumstances, it may be better to set the timeout (that this function actually provides for) not to 0 but to something like 10 or 100 or so.
So while thinking about it, @CZvacko, maybe you could first start by changing
getLocalTime(&now,0);
to
getLocalTime(&now,100);
and see if that does the trick.
from bsb-lan.
from bsb-lan.
Reminds me of bogus values I've received from a NTP server every now and then, when synchronizing the time in one of my sketches - which the NTPclient library I've used sadly doesn't handle.
My workaround was to do a couple of retries in those cases, similar to what is suggested here.
I'm not sure whether the cause of this in my case was a weak network connection (UDP over WLAN), or what else it was.
...and I must confess that I don't even know whether BSB-LAN in this setup uses NTP or RTC.
from bsb-lan.
@DE-cr The description does not say that the GetLocalTime() function implicitly calls or waits for NTP. But it looks exactly like this. Another reason is race condition. I want to try to rewrite the current date query using the gettimeofday() function, but I have no confidence that it will get better.
On my system, this problem does not show itself.
from bsb-lan.
- getLocalTime() returns a bool value to signal success - which BSB_LAN.ino does not evaluate.
- This may (or may not) help: https://forum.arduino.cc/t/esp32-time-library-sync-interval/902588
from bsb-lan.
Yes, getLocalTime() returns a status, but BSB-LAN does not evaluate it because we're not making use of NTP - and none of the code in the above-quoted function should. We set the time either based on the time of the heater or it's 1.1.1900. But since the date is set correctly in the logs at first and the error only occurs after hours or days, it doesn't make sense unless the ESP32 calls an NTP server unknown to me. That should not happen for various reasons or should at least be configurable.
from bsb-lan.
I just flashed device with "getLocalTime(&now,100)"
Now need wait few hours/days to see if happen again.
from bsb-lan.
Thanks!
from bsb-lan.
Any update, @CZvacko?
from bsb-lan.
Yes, it's fine now. I waited a few days to be sure.
from bsb-lan.
Thanks, goof to know! We'll change it according to your suggestion.
from bsb-lan.
Related Issues (20)
- [BUG] "/JS" POST request unexpected behavior HOT 8
- [BUG] Web Server Stopped Working HOT 4
- [FEATURE] Heating-Engineer Additional Parameters Access HOT 3
- [BUG] Constat reconnection to mqtt broker HOT 3
- [FEATURE REQUEST] Send BSB-LAN version to MQTT HOT 2
- [BUG] PPS Errors with BSB-LAN Versions > 2.0.16 HOT 117
- [FEATURE REQUEST] No wifi if started after wifi access point HOT 1
- [FEATURE REQUEST] Set date and time HOT 1
- [BUG] Set date and time reset after a while HOT 45
- [BUG] MQTT connection fails HOT 27
- [FEATURE REQUEST] Add support for WT32-ETH1 board HOT 4
- [BUG] SD card vs. flash memory HOT 5
- [BUG] Device hangs for some seconds on socket error with MQTT HOT 2
- [BUG] Heater function list disappeared in version 3.4.3 HOT 9
- [BUG] Set button is not working on parameter that require /I in the we interface HOT 4
- [BUG] BSB-LAN does not compile HOT 1
- [BUG]?: calculation of free space in filesystem HOT 1
- [BUG] v3.4.7 crashes ESP32/Wifi/BSB when submitting room temperature HOT 3
- Migrating BSB-LAN to ESP32 framework 3.0.0 HOT 4
- [BUG] Sketch too big HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bsb-lan.