Skip to content

Commit

Permalink
fixes for uS resolution ntp
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed May 7, 2024
1 parent 8c8084e commit e41e371
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ESP32/FvHNTP/FvHNTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ class ntp
std::mutex lock;
std::string server;
std::thread *th { nullptr };
uint32_t millis_at_ts { 0 };
uint64_t ntp_at_ts { 0 }; // milliseconds!
uint32_t micros_at_ts { 0 };
uint64_t ntp_at_ts { 0 }; // us!

public:
ntp(const std::string & upstream_server);
virtual ~ntp();

void begin();

std::optional<uint64_t> get_unix_epoch_ms();
std::optional<uint64_t> get_unix_epoch_us();

void operator()();
};
4 changes: 2 additions & 2 deletions log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ void dolog(const log_level_t ll, const char *fmt, ...)
uint64_t now = 0;

if (ntp_clock) {
auto temp = ntp_clock->get_unix_epoch_ms();
auto temp = ntp_clock->get_unix_epoch_us();
if (temp.has_value())
now = temp.value() * 1000;
now = temp.value();
}
#else
uint64_t now = get_us();
Expand Down

0 comments on commit e41e371

Please sign in to comment.