Skip to content

Commit 72a4dde

Browse files
authored
sntp callback: use a recurrent schedule function (#6888)
1 parent 3e6c25c commit 72a4dde

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

cores/esp8266/Schedule.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void run_scheduled_functions();
4646

4747
// recurrent scheduled function:
4848
//
49-
// * Internal queue may not be a FIFO.
49+
// * Internal queue is a FIFO.
5050
// * Run the lambda periodically about every <repeat_us> microseconds until
5151
// it returns false.
5252
// * Note that it may be more than <repeat_us> microseconds between calls if
@@ -60,6 +60,7 @@ void run_scheduled_functions();
6060
// recurrent function.
6161
// * If alarm is used, anytime during scheduling when it returns true,
6262
// any remaining delay from repeat_us is disregarded, and fn is executed.
63+
6364
bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
6465
uint32_t repeat_us, const std::function<bool(void)>& alarm = nullptr);
6566

cores/esp8266/sntp-lwip2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,15 @@ int settimeofday(const struct timeval* tv, const struct timezone* tz)
455455
// apparently tz->tz_dsttime is a bitfield and should not be further used (cf man)
456456
sntp_set_daylight(0);
457457
}
458-
if (tv) /* after*/
458+
if (tv) /*after*/
459459
{
460460
// reset time subsystem
461461
tune_timeshift64(tv->tv_sec * 1000000ULL + tv->tv_usec);
462462

463463
sntp_set_system_time(tv->tv_sec);
464464

465465
if (_settimeofday_cb)
466-
schedule_function(_settimeofday_cb);
466+
schedule_recurrent_function_us([](){ _settimeofday_cb(); return false; }, 0);
467467
}
468468
return 0;
469469
}

0 commit comments

Comments
 (0)