arduino-libraries / WiFiNINA

136 stars 105 forks source link

getTime() timestamp is exactly 2 days (172800 seconds) behind actual. #241

Closed Roamer105 closed 1 year ago

Roamer105 commented 1 year ago

I am using WiFi.getTime() to replace my NTP access/parsing code. I noticed that the returned timestamp is exactly 2 days in the past. Simply adding the missing 172800 seconds fixes the problem but of course it remains a problem.

I decided to use that method to get time mainly because the periodical UDP activity used to periodically access the NTP server (I synchronized once every hour) caused WiFiNINA to hang on the main activities (Web server and ModBus client) thus firing the watchdog. Using WiFi.getTime() relegates that activity is to the u-blox 10 firmware, away from potential WiFiNINA library issues.

Roamer105 commented 1 year ago

The behavior is identical with using WiFi.getTime(). Although executed within the firmware, it appears that getTime() synchronizes once every hour and the MKR1010 fails (hangs) exactly once every hour after start/restart.

Roamer105 commented 1 year ago

Egg on face. The 2 days issue ended up a problem in my epoch conversion routine. I am using RTCZero instead. The WiFi.getTime() works just fine.

The second part of my original post was a misdiagnosis of the symptoms at hand. The problem was NOT related to fetching NTP or anything else for that matter.

I use a MOFI router with CloudLink VPN and public IP through which I connect with the MKR-1010 from anywhere. While this works OK it will cause WiFiNINA to hang exactly every hour. There is some activity related to the CloudLink VPN that causes the rounter to not respond to ping for a short while but then also causing WiFiNINA to hang. After disabling the VPN for testing purposes, the MKR has not shown any connection or hanging issues for over 1 day. We know that the VPN causes the issue, but I have no idea about the exact reason why.