mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
sntp callback: use a recurrent schedule function (#6888)
This commit is contained in:
parent
3e6c25c21b
commit
72a4dde64f
@ -46,7 +46,7 @@ void run_scheduled_functions();
|
|||||||
|
|
||||||
// recurrent scheduled function:
|
// recurrent scheduled function:
|
||||||
//
|
//
|
||||||
// * Internal queue may not be a FIFO.
|
// * Internal queue is a FIFO.
|
||||||
// * Run the lambda periodically about every <repeat_us> microseconds until
|
// * Run the lambda periodically about every <repeat_us> microseconds until
|
||||||
// it returns false.
|
// it returns false.
|
||||||
// * Note that it may be more than <repeat_us> microseconds between calls if
|
// * Note that it may be more than <repeat_us> microseconds between calls if
|
||||||
@ -60,6 +60,7 @@ void run_scheduled_functions();
|
|||||||
// recurrent function.
|
// recurrent function.
|
||||||
// * If alarm is used, anytime during scheduling when it returns true,
|
// * If alarm is used, anytime during scheduling when it returns true,
|
||||||
// any remaining delay from repeat_us is disregarded, and fn is executed.
|
// any remaining delay from repeat_us is disregarded, and fn is executed.
|
||||||
|
|
||||||
bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
|
bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
|
||||||
uint32_t repeat_us, const std::function<bool(void)>& alarm = nullptr);
|
uint32_t repeat_us, const std::function<bool(void)>& alarm = nullptr);
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ int settimeofday(const struct timeval* tv, const struct timezone* tz)
|
|||||||
sntp_set_system_time(tv->tv_sec);
|
sntp_set_system_time(tv->tv_sec);
|
||||||
|
|
||||||
if (_settimeofday_cb)
|
if (_settimeofday_cb)
|
||||||
schedule_function(_settimeofday_cb);
|
schedule_recurrent_function_us([](){ _settimeofday_cb(); return false; }, 0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user