fixes for uS resolution ntp

This commit is contained in:
folkert van heusden 2024-05-07 14:27:31 +02:00
parent 8c8084ec5b
commit e41e37105a
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 5 additions and 5 deletions

View file

@ -17,8 +17,8 @@ private:
std::mutex lock; std::mutex lock;
std::string server; std::string server;
std::thread *th { nullptr }; std::thread *th { nullptr };
uint32_t millis_at_ts { 0 }; uint32_t micros_at_ts { 0 };
uint64_t ntp_at_ts { 0 }; // milliseconds! uint64_t ntp_at_ts { 0 }; // us!
public: public:
ntp(const std::string & upstream_server); ntp(const std::string & upstream_server);
@ -26,7 +26,7 @@ public:
void begin(); void begin();
std::optional<uint64_t> get_unix_epoch_ms(); std::optional<uint64_t> get_unix_epoch_us();
void operator()(); void operator()();
}; };

View file

@ -167,9 +167,9 @@ void dolog(const log_level_t ll, const char *fmt, ...)
uint64_t now = 0; uint64_t now = 0;
if (ntp_clock) { if (ntp_clock) {
auto temp = ntp_clock->get_unix_epoch_ms(); auto temp = ntp_clock->get_unix_epoch_us();
if (temp.has_value()) if (temp.has_value())
now = temp.value() * 1000; now = temp.value();
} }
#else #else
uint64_t now = get_us(); uint64_t now = get_us();