ESP32 Network Time Protocol & freeRTOS

I've been trying to track down why a program broken into several freeRTOS tasks has one low priority task that never gets serviced if, and only if, I call configTime() in setup.

If I comment out that one function call to set the time from NTP everything works as I would expect, except for the time being wrong (obviously). All my tasks yield at some point and execution takes place within all priority levels. If I do set the time the highest priority tasks execute (although slower than without NTP sync) but the lowest is never entered. I even tried calling configTime() from an even lower priority task of its own but that made no difference.

I haven't had any success trying to find the inner workings of NTP for arduino-esp32 as some links in the code on github seem to be for blobs of esp8266 code and some are broken. Is anyone familiar with the way NTP time is handled and how it might interfere with the freeRTOS scheduler?

The issue is line 546799, it is missing the thing.

I get it. My question is too vague. I tried to build a minimal working example to show the issue but it "failed to fail'. I'm still in the process of trying to build up to the point at which it fails. Philosophically though, finding that commenting out a single call to a function in time.cpp made me feel like I'd already found the issue, and that it might be a known 'gotcha' when working with tasks and NTP. I guess it isn't.

I tend to use ESP32Time, GitHub - fbiego/ESP32Time: An Arduino library for setting and retrieving internal RTC time on ESP32 boards, for esp32 and time thingies. Might be of help or not.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.